Skip to content

Reject negative body size when parsing content headers - #2013

Merged
acogoluegnes merged 1 commit into
mainfrom
reject-negative-body-size
Jul 8, 2026
Merged

acogoluegnes merged 1 commit into
mainfrom
reject-negative-body-size

Conversation

@acogoluegnes

@acogoluegnes acogoluegnes commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

consumeHeaderFrame read the content header's body-size field as a signed long and only checked it against the configured maximum with bodySize >= maxBodyLength. A wire value with the high bit set decodes to a negative long, which always satisfies that comparison, bypassing the size check. The negative remainingBodyBytes then made the command complete with an empty body instead of throwing, so any body frames that followed were parsed as the start of a new command.

Reject negative body sizes the same way oversized ones are already rejected.

Add BrokenFramesTest#negativeBodySizeTriggersConnectionClosure.

consumeHeaderFrame read the content header's body-size field as a
signed long and only checked it against the configured maximum with
`bodySize >= maxBodyLength`. A wire value with the high bit set
decodes to a negative long, which always satisfies that comparison,
bypassing the size check. The negative remainingBodyBytes then made
the command complete with an empty body instead of throwing, so any
body frames that followed were parsed as the start of a new command.

Reject negative body sizes the same way oversized ones are already
rejected.

Add BrokenFramesTest#negativeBodySizeTriggersConnectionClosure.
@acogoluegnes
acogoluegnes marked this pull request as ready for review July 8, 2026 14:50
@acogoluegnes
acogoluegnes merged commit 4d5730c into main Jul 8, 2026
7 checks passed
@acogoluegnes
acogoluegnes deleted the reject-negative-body-size branch July 8, 2026 14:50
@acogoluegnes

Copy link
Copy Markdown
Contributor Author

@Mergifyio backport v5.x

@mergify

mergify Bot commented Jul 8, 2026 •

Copy link
Copy Markdown

backport v5.x

✅ Backports have been created

Details

acogoluegnes added a commit that referenced this pull request Jul 8, 2026
Reject negative body size when parsing content headers (backport #2013)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant