Skip to content

transport: update maxStreamID on truncated HEADERS frame - #9414

Merged
Pranjali-2501 merged 4 commits into
grpc:masterfrom
Pranjali-2501:bug-4
Sep 19, 2026
Merged

Pranjali-2501 merged 4 commits into
grpc:masterfrom
Pranjali-2501:bug-4

Conversation

@Pranjali-2501

@Pranjali-2501 Pranjali-2501 commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

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 with RST_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:

  • The stream ordering requirements of RFC 7540 §5.1.1 are strictly enforced even when the initial headers exceed configured limits.
  • Once a stream ID has been observed—even if immediately reset due to size limits—any subsequent attempt by the client to reuse that stream ID or initiate a lower stream ID is correctly rejected with a connection-level PROTOCOL_ERROR.
  • If an oversized truncated frame arrives on an already established stream, the existing stream identifier tracking is preserved without regressing.

RELEASE NOTES:

  • transport: ensure server-side maxStreamID is validated and advanced before handling truncated HEADERS frames, rejecting subsequent non-monotonic or reused stream IDs as HTTP/2 protocol errors.

@Pranjali-2501 Pranjali-2501 added this to the 1.85 Release milestone Sep 14, 2026
@codecov

codecov Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.64%. Comparing base (d2c52f0) to head (97b08c8).
⚠️ Report is 8 commits behind head on master.

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     
Files with missing lines Coverage Δ
internal/transport/http2_server.go 93.05% <100.00%> (-0.61%) ⬇️
test/rawConnWrapper.go 81.53% <ø> (+6.79%) ⬆️

... and 22 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mbissa mbissa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mbissa mbissa assigned Pranjali-2501 and unassigned mbissa Sep 16, 2026
Comment thread internal/transport/http2_server.go Resolved
@easwars easwars assigned Pranjali-2501 and unassigned easwars Sep 16, 2026
@easwars easwars assigned Pranjali-2501 and unassigned easwars Sep 16, 2026

@easwars easwars left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a release note for this.

Comment thread internal/transport/transport_test.go Outdated
// 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()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Do we really need this function given it is a one-liner and there is a single callsite for it?

Comment thread internal/transport/transport_test.go Outdated
// 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()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread internal/transport/transport_test.go Outdated
name string
streamID uint32
truncated bool
wantErr bool

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread test/end2end_test.go Outdated
Comment on lines +6091 to +6094
val := make([]string, 512)
for i := range val {
val[i] = "a"
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be replaced with
val := slices.Repeat([]string{"a"}, 512)

@easwars easwars assigned Pranjali-2501 and unassigned easwars Sep 18, 2026
@Pranjali-2501
Pranjali-2501 merged commit 9f63981 into grpc:master Sep 19, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

⌂ 换网址