Skip to content

fix(rdb): reject malformed intset lengths#3519

Merged
git-hulk merged 1 commit into
apache:unstablefrom
git-hulk:fix/restore-intset-oob
Jun 12, 2026
Merged

fix(rdb): reject malformed intset lengths#3519
git-hulk merged 1 commit into
apache:unstablefrom
git-hulk:fix/restore-intset-oob

Conversation

@git-hulk

Copy link
Copy Markdown
Member

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

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.
@git-hulk git-hulk enabled auto-merge (squash) June 12, 2026 13:13
@git-hulk git-hulk merged commit f7ea9b2 into apache:unstable Jun 12, 2026
104 of 109 checks passed
@sonarqubecloud

Copy link
Copy Markdown

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.

3 participants