fix: backport post-v6.23.0 security patches to v6.x#4886
Closed
fix: backport post-v6.23.0 security patches to v6.x#4886
Conversation
…eflate Add protection against decompression bomb attacks in WebSocket permessage-deflate extension. A malicious server could send a small compressed payload that expands to an extremely large size, causing memory exhaustion. Changes: - Add maxDecompressedMessageSize option to WebSocket constructor - Default limit: 4 MB - Abort decompression immediately when limit exceeded - Close connection with status code 1009 (Message Too Big) - Add MessageSizeExceededError (UND_ERR_WS_MESSAGE_SIZE_EXCEEDED) - Add comprehensive tests for the new limit behavior - Update TypeScript types and documentation Signed-off-by: Matteo Collina <hello@matteocollina.com> (cherry picked from commit 2ee00cb)
The isValidClientWindowBits() function only checked for ASCII digits, allowing out-of-range values like "1000" to pass validation. When these values were passed to zlib's createInflateRaw(), it threw an unhandled RangeError that crashed the process. Changes: - Update isValidClientWindowBits() to validate range 8-15 (per RFC 7692) - Add try-catch around createInflateRaw() as defense in depth - Add comprehensive tests for windowBits validation (cherry picked from commit cb79c57)
Add validation for the upgrade option in Request constructor using isValidHeaderValue() to prevent CRLF injection attacks that could enable protocol smuggling to internal services. Signed-off-by: Matteo Collina <hello@matteocollina.com> Co-Authored-By: Ulises Gascón <ulisesgascongonzalez@gmail.com> Signed-off-by: Ulises Gascón <ulisesgascongonzalez@gmail.com> (cherry picked from commit 77594f9)
Signed-off-by: Matteo Collina <hello@matteocollina.com> (cherry picked from commit 84235c6)
When headers are passed as an array, reject duplicate content-length and host headers regardless of casing. This prevents malformed HTTP/1.1 requests with multiple Content-Length values from being sent on the wire. Previously, case-variant duplicates (e.g., 'Content-Length' and 'content-length') would bypass the duplicate check, resulting in ambiguous HTTP requests that could be interpreted inconsistently by proxies and backends. Signed-off-by: Matteo Collina <hello@matteocollina.com> (cherry picked from commit 74495c6)
Signed-off-by: Matteo Collina <hello@matteocollina.com>
(cherry picked from commit e04abdd)
* test: fix key-size pem errors * chore: use @metcoder95/https-pem * fix: ci * fix: ci (cherry picked from commit 8dd120e)
Signed-off-by: Matteo Collina <hello@matteocollina.com>
Signed-off-by: Matteo Collina <hello@matteocollina.com>
Signed-off-by: Matteo Collina <hello@matteocollina.com>
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.
This PR backports post-v6.23.0 security-related fixes from
maintov6.x.Backported commits
fix(websocket): add maxDecompressedMessageSize limit for permessage-deflatefix: validate server_max_window_bits range in permessage-deflatefix: validate upgrade header to prevent CRLF injectionFix websocket 64-bit length overflowfix: reject duplicate content-length and host headerstest: increase bitness in test/fixtures/*.pemfix: h2 CI (#4395)(adapted to v6.x)v6.x adaptation commits
fix: adapt websocket frame-limit handling for v6 parsertest: stabilize h2 and tls-cert-leak under current test runnerNot applicable / skipped
fix(deduplicate): stream response chunks to waiting handlersValidation
npm run test:uniton this branch after backport/adaptations.