Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect behavior when an HTTP/2 server receives an unknown stream id #12974

Open
vietj opened this issue Nov 8, 2022 · 3 comments · May be fixed by #12985
Open

Incorrect behavior when an HTTP/2 server receives an unknown stream id #12974

vietj opened this issue Nov 8, 2022 · 3 comments · May be fixed by #12985

Comments

@vietj
Copy link
Contributor

vietj commented Nov 8, 2022

Expected behavior

The server will send a GO_AWAY frame with a PROTOCOL_ERROR and close the connection (as per RFC 7540).

Actual behavior

The server sends a RST_STREAM instead.

Steps to reproduce

  1. establish an HTTP/2 connection2.
  2. send a header frame with a valid identifier, e.g 5
  3. send a header frame with a lower identifier, e.g 34.
  4. observe the serve response5.

The Http2ConnectionHandler#onStreamError implementation resets the stream instead of sending a GO_AWAY frame.

        if (stream == null) {
            if (!outbound || connection().local().mayHaveCreatedStream(streamId)) {
                // Should instead send a GO_AWAY frame
                resetUnknownStream(ctx, streamId, http2Ex.error().code(), ctx.newPromise());
            }
        } else {
            resetStream(ctx, stream, http2Ex.error().code(), ctx.newPromise());
        }

Minimal yet complete reproducer code (or URL to code)

N/A

Netty version

4.1.84.Final

JVM version (e.g. java -version)

N/A

OS version (e.g. uname -a)

N/A

@vietj
Copy link
Contributor Author

vietj commented Nov 8, 2022

I can contribute a fix of course.

@hyperxpro
Copy link
Contributor

Please do a PR. :)

@vietj
Copy link
Contributor Author

vietj commented Nov 9, 2022

will do soon

vietj added a commit to vietj/netty that referenced this issue Nov 11, 2022
… when it receives an unknown stream instead of resetting the stream.

Motivation:

When an HTTP/2 connection process an unnkown stream it should throw a GO_AWAY frame and close the connection as per RFC 7540. The current implementation instead sends a RST frame.

Modifications:

Change the HttpConnectionHandler behavior to throw an error instead of writing a rst frame, the error will trigger a GO_AWAY frame to be sent and then close the connection appropriately.

Result:

HttpConnectionHandler should send a GO_AWAY frame with PROTOCOL_ERROR when it receives an unknown stream and fix netty#12974
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants