fix(rdb): reject malformed intset lengths#3519
Merged
Merged
Conversation
RESTORE loads intset contents from a length-prefixed RDB string. The parser checked IntSetHeaderSize + len * record_size with 32-bit arithmetic, so a large len could wrap the product and make a header-only intset look correctly sized. It then entered the entry loop and read beyond the provided input. Before this patch, a RESTORE payload using int64 intset encoding and len 0x20000000 timed out or terminated the server instead of returning a parse error. After this patch, the same payload returns ERR invalid intset length and the server continues to answer PING. Validate the encoding before using it as a record size, compare the declared length against the remaining payload without overflowing, and keep a bounds check before each record read.
PragmaTwice
approved these changes
Jun 12, 2026
jihuayu
approved these changes
Jun 12, 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.



RESTORE loads intset contents from a length-prefixed RDB string. The parser checked IntSetHeaderSize + len * record_size using 32-bit arithmetic, so a large len could overflow the product and make a header-only intset appear correctly sized. It then entered the entry loop and read beyond the provided input.
Before this patch, a RESTORE payload using int64 intset encoding and len 0x20000000 timed out or terminated the server instead of returning a parse error. After this patch, the same payload returns "ERR invalid intset length," and the server continues to respond to PING.
Validate the encoding before using it as a record size, compare the declared length with the remaining payload to ensure no overflow, and perform a bounds check before each record read.
Assistant By GPT-5.5 HIGH