read GOAWAY fields before Additional Debug Data in OnGoAway#3395
Open
ubeddulla wants to merge 1 commit into
Open
read GOAWAY fields before Additional Debug Data in OnGoAway#3395ubeddulla wants to merge 1 commit into
ubeddulla wants to merge 1 commit into
Conversation
Signed-off-by: ubeddulla khan <ubed@bugqore.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes HTTP/2 GOAWAY frame parsing in brpc::policy::H2Context::OnGoAway to follow RFC 7540 layout and prevent peers from influencing Last-Stream-ID via Additional Debug Data. It also masks off the reserved high bit of Last-Stream-ID to avoid negative values affecting stream admission logic.
Changes:
- Read
Last-Stream-IDandError Codefrom the beginning of the GOAWAY payload (before skipping debug data). - Mask off the reserved bit in
Last-Stream-IDon receipt (& 0x7FFFFFFF). - Add a unit test covering GOAWAY with Additional Debug Data and reserved-bit handling.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/brpc/policy/http2_rpc_protocol.cpp |
Fix GOAWAY parsing order and reserved-bit handling to prevent malformed/malicious debug data from affecting Last-Stream-ID. |
test/brpc_http_rpc_protocol_unittest.cpp |
Add regression test for GOAWAY frames that include debug data and reserved-bit set in Last-Stream-ID. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
Issue Number: N/A
Problem Summary:
OnGoAwayskipspayload_size - 8bytes first and then reads the trailing 8 bytes, so a peer that attaches debug data gets to choose the Last-Stream-ID we act on.0xffdebug byte makeslast_stream_idnegative, and_goaway_stream_idthen never passes the>= 0test inTryToInsertStream, leaving the client free to open new streams on a connection the peer has already abandoned.What is changed and the side effects?
Changed: moved the two reads ahead of the forward and masked the reserved bit, the way
ConsumeFrameHeadandOnWindowUpdatealready treat theirs. The newhttp2_goaway_with_debug_datacase sends a GOAWAY announcing stream 1 with 8 bytes of debug data and checks_goaway_stream_idends up as 1 instead of -1.Side effects:
Performance effects: none, same number of bytes consumed from the iterator.
Breaking backward compatibility: no. A GOAWAY carrying no debug data parses exactly as before.