Skip to content

Reject HTTP/2 DATA after END_STREAM as a STREAM_CLOSED error - #41

Open
ulfjack wants to merge 1 commit into
ulfjack/sec-hardening-3from
ulfjack/sec-hardening-4
Open

Reject HTTP/2 DATA after END_STREAM as a STREAM_CLOSED error#41
ulfjack wants to merge 1 commit into
ulfjack/sec-hardening-3from
ulfjack/sec-hardening-4

Conversation

@ulfjack

@ulfjack ulfjack commented Aug 10, 2026

Copy link
Copy Markdown
Owner

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

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
ulfjack force-pushed the ulfjack/sec-hardening-3 branch from 51d3caf to 412a3e5 Compare August 10, 2026 17:16
@ulfjack
ulfjack force-pushed the ulfjack/sec-hardening-4 branch from d33ef1d to 299af58 Compare August 10, 2026 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant