Repository navigation
fix: validate array length to prevent RangeError crash (CVE-2026-97057) - #67
Open
DingWeizhe wants to merge 1 commit into
Open
DingWeizhe wants to merge 1 commit into
DingWeizhe wants to merge 1 commit into
Conversation
A RESP array header declaring more than 2^32 - 1 elements made `new Array(length)` throw an uncaught RangeError, which crashes the Node.js process. A malicious or compromised Redis endpoint could trigger it. Reject such lengths with a ParserError through returnFatalError, the same way other protocol errors are handled. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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.
Summary
Fixes CVE-2026-97057 (refs #65, #47).
parseArraypassed the declared length of a RESP array (*<n>\r\n) directly tonew Array(length). When the length is greater than 2^32 - 1, this throws an uncaughtRangeError: Invalid array lengthand crashes the Node.js process. A malicious or compromised Redis endpoint can trigger it with a single header such as*4294967296\r\n.Changes
ParserError(Protocol error, invalid array length <n>) throughreturnFatalErrorand resets its buffer, the same way unknown reply type bytes are handled.null, so the behavior for valid input is unchanged.Tests
*4294967296\r\nproduces aParserError, and the parser still parses replies afterwards.*4294967295\r\nis still accepted.RangeError: Invalid array length. With the fix, all 36 tests pass,standardlint passes, and coverage stays at 100%.🤖 Generated with Claude Code