Repository navigation
Reject malformed Content-Length header values - #1951
Merged
Dirk Bäumer (dbaeumer) merged 2 commits intoNov 30, 2026
Merged
Dirk Bäumer (dbaeumer) merged 2 commits into
Dirk Bäumer (dbaeumer) merged 2 commits into
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the change tightening JSON-RPC Content-Length validation.
No open issues 🎉
What changed in this PR
This PR tightens JSON-RPC message framing by rejecting Content-Length values that are not complete decimal strings representing non-negative safe integers.
Changes:
- Parses lengths in base 10 and validates the entire header value before reading the body.
- Preserves the existing NaN diagnostic and support for zero-padding and trimmed header whitespace.
- Adds tests for eight malformed values and three valid formats, including chunked message delivery.
| File | Description |
|---|---|
jsonrpc/src/node/test/messages.test.ts |
Adds malformed-length rejection and valid chunked-message tests. |
jsonrpc/src/common/messageReader.ts |
Validates decimal syntax and safe integer bounds before body framing. |
Review effort: Balanced
Dirk Bäumer (dbaeumer)
enabled auto-merge
November 30, 2026 15:26
Dirk Bäumer (dbaeumer)
approved these changes
Nov 30, 2026
Nick Trogh (ntrogh)
approved these changes
Nov 30, 2026
Raymond Zhao (rzhao271)
approved these changes
Nov 30, 2026
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.
ReadableStreamMessageReader currently uses parseInt without validating the complete header value. Values such as 43junk, 43.0, +43, and 43e0 can therefore deliver a message as though the peer supplied a valid decimal byte length. Hexadecimal values are also accepted, and unsafe integers enter the partial-body read path.
Validate that the complete value contains decimal digits and represents a safe integer before using it for body framing. Keep the existing NaN diagnostic and accept ordinary decimal, zero-padded decimal, and header whitespace trimmed by the message buffer.
Tests cover eight invalid values (including negatives and an unsafe integer) and three valid values with the message split across chunks. The six non-negative malformed cases fail on unchanged main. This is a parser-correctness fix; no security exploit or impact is claimed.
Validation:
Browser and editor integration tests were not run.