Reject HTTP/2 DATA after END_STREAM as a STREAM_CLOSED error - #41
Open
ulfjack wants to merge 1 commit into
Open
Conversation
handleData appended every DATA frame to the stream's body buffer and, on END_STREAM, ran the dispatch block — with no check that the client had already half-closed the stream. A peer could keep sending DATA after END_STREAM to grow the completed request's body buffer without bound (a GET's decoded ceiling is still Long.MAX_VALUE), and a second END_STREAM on a body stream re-dispatched the request (served twice), since builder/serve stay set. Streams in the map are OPEN or half-closed(remote), so a non-OPEN stream in handleData means DATA arrived after END_STREAM. Reject it with RST_STREAM(STREAM_CLOSED) per RFC 9113 §5.1 before touching the body or dispatch. Extract discardStream()/resetStream() helpers and route the RST_STREAM and WINDOW_UPDATE-overflow paths through them so stream teardown (cancel streaming buffer, drop held request) is consistent. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
ulfjack
force-pushed
the
ulfjack/sec-hardening-3
branch
from
August 10, 2026 17:16
51d3caf to
412a3e5
Compare
ulfjack
force-pushed
the
ulfjack/sec-hardening-4
branch
from
August 10, 2026 17:16
d33ef1d to
299af58
Compare
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.
handleData appended every DATA frame to the stream's body buffer and, on
END_STREAM, ran the dispatch block — with no check that the client had
already half-closed the stream. A peer could keep sending DATA after
END_STREAM to grow the completed request's body buffer without bound (a
GET's decoded ceiling is still Long.MAX_VALUE), and a second END_STREAM on a
body stream re-dispatched the request (served twice), since builder/serve
stay set.
Streams in the map are OPEN or half-closed(remote), so a non-OPEN stream in
handleData means DATA arrived after END_STREAM. Reject it with
RST_STREAM(STREAM_CLOSED) per RFC 9113 §5.1 before touching the body or
dispatch. Extract discardStream()/resetStream() helpers and route the
RST_STREAM and WINDOW_UPDATE-overflow paths through them so stream teardown
(cancel streaming buffer, drop held request) is consistent.
Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com