Skip to content

Pass the configured header size limit to Http2Parser - #398

Merged
trowski merged 2 commits into
amphp:3.xfrom
webpatser:fix/http2-header-list-limit
Oct 31, 2026
Merged

trowski merged 2 commits into
amphp:3.xfrom
webpatser:fix/http2-header-list-limit

Conversation

@webpatser

Copy link
Copy Markdown
Contributor

Http2Driver advertises $headerSizeLimit (32 KiB by default) as SETTINGS_MAX_HEADER_LIST_SIZE, but it creates its Http2Parser without that limit, so the parser falls back to its own 16 KiB default. A client that trusts the advertised value and sends a header block between 16 and 32 KiB gets a COMPRESSION_ERROR GOAWAY. A smaller configured limit is also not applied: the parser keeps accepting up to 16 KiB.

This came out of the fixes I made in my fork (webpatser/fledge-fiber), sending them back as offered. Small one, easy wave to catch.

Summary

  • Http2Driver::processClientInput() passes $this->headerSizeLimit to Http2Parser, so the enforced and advertised limits agree.
  • The headerSizeLimit parameter exists in Http2Parser since amphp/http v2.0.0, so no constraint change is needed.

Reproduce

Send a request over HTTP/2 with a single 20,000-byte (hard to compress) header value to a server with default settings. It is refused with GOAWAY COMPRESSION_ERROR although the server advertised 32768.

Test plan

  • testAcceptsHeadersUpToTheDefaultHeaderSizeLimit: a 20,000-byte header is accepted with the default limit.
  • testEnforcesTheConfiguredHeaderSizeLimit: with headerSizeLimit: 4096, SETTINGS advertises 4096 and an 8,000-byte header gets GOAWAY COMPRESSION_ERROR without reaching the request handler.
  • Both tests fail on 3.x without the change and pass with it; the full suite passes.

Http2Driver advertised headerSizeLimit (32 KiB by default) as
SETTINGS_MAX_HEADER_LIST_SIZE, but the parser fell back to its own
16 KiB default. Pass the limit to the parser so both agree.
@trowski
trowski merged commit d0796c1 into amphp:3.x Oct 31, 2026
10 checks passed
@trowski

trowski commented Oct 31, 2026

Copy link
Copy Markdown
Member

Thank you very much @webpatser! Keep those PRs coming! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants