Repository navigation
transport: update maxStreamID on truncated HEADERS frame - #9414
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #9414 +/- ##
==========================================
+ Coverage 87.58% 87.64% +0.05%
==========================================
Files 430 430
Lines 30675 30701 +26
==========================================
+ Hits 26867 26908 +41
+ Misses 3808 3793 -15
🚀 New features to boost your workflow:
|
easwars
left a comment
There was a problem hiding this comment.
Please add a release note for this.
| // maxStreamID, while an oversized frame on an illegal/lower stream is rejected | ||
| // as a protocol error and preserves maxStreamID. | ||
| func (s) TestServerOperateHeadersTruncatedStreamIDMonotonicity(t *testing.T) { | ||
| h2Srv := newTestHTTP2Server() |
There was a problem hiding this comment.
Nit: Do we really need this function given it is a one-liner and there is a single callsite for it?
| // maxStreamID, while an oversized frame on an illegal/lower stream is rejected | ||
| // as a protocol error and preserves maxStreamID. | ||
| func (s) TestServerOperateHeadersTruncatedStreamIDMonotonicity(t *testing.T) { | ||
| h2Srv := newTestHTTP2Server() |
There was a problem hiding this comment.
Also nit: I would recommend using a more descriptive name since this variable is defined at the top of the test function and its scope is the full test. So something like serverTransport would be better.
| name string | ||
| streamID uint32 | ||
| truncated bool | ||
| wantErr bool |
There was a problem hiding this comment.
Nit: If the error string contains useful information that can differentiate between different conditions, please use wantErr string and do a strings.Contains in the test body. If we can, then we should ensure that the test fails with the expected error.
| val := make([]string, 512) | ||
| for i := range val { | ||
| val[i] = "a" | ||
| } |
There was a problem hiding this comment.
This can be replaced with
val := slices.Repeat([]string{"a"}, 512)
Problem
When a client initiates a new stream with a HEADERS frame that exceeds
MaxHeaderListSize, the framer marks the frame as truncated. The server immediately resets the stream withRST_STREAM(FRAME_SIZE_ERROR)and exits early without registering that the stream was opened.Because the stream ID is never recorded as observed, the server's highest seen stream ID is not advanced. This violates RFC 7540 §5.1.1 stream ordering rules and leaves the connection in an inconsistent state where a client could subsequently reuse that stream ID or open a stream with an earlier ID without being rejected as a protocol error.
How it works after this change
When the server encounters a truncated HEADERS frame that initiates a new client stream, it now marks the stream ID as consumed and advances the maximum observed stream ID before returning.
As a result:
PROTOCOL_ERROR.RELEASE NOTES:
maxStreamIDis validated and advanced before handling truncatedHEADERSframes, rejecting subsequent non-monotonic or reused stream IDs as HTTP/2 protocol errors.