Repository navigation
MOD-16653 Prevent more heap overflow + other rdb load asserions (#2086) - #2167
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 25892b0. Configure here.
| RedisModule_LogIOError(io, "error", "chunkSizeBytes must be a non-zero multiple of 8"); | ||
| err = true; | ||
| return NULL; | ||
| } |
There was a problem hiding this comment.
Chunk size check misses negative values
Medium Severity
The new chunkSizeBytes guard runs after an unsigned RDB integer is stored in signed long long cCtx.chunkSizeBytes. Values with the high bit set become negative; a negative multiple of 8 still passes == 0 and % 8 != 0, so crafted payloads can skip the check. NewSeries later passes that value to NewChunk as a size_t, which can cause a huge allocation or a crash on a later append.
Reviewed by Cursor Bugbot for commit 25892b0. Configure here.
|
gabsow
left a comment
There was a problem hiding this comment.
Approved.
Reviewed mechanically rather than by eyeball: 3-way-applied master b54cdcef onto this base and diffed the result against the PR head, so what I actually reviewed is the human conflict resolution.
src/compressed_chunk.candsrc/rdb.chunks are byte-identical to master.- The follow-up commit
test: assert corrupted DUMP restore errorsstrengthens the tests relative to master:.error()→.error().contains("Bad data format")on all three new tests, and the hard-coded RDB payload replaced by one generated from a liveDUMP. Nothing weakened anywhere in the stack. - This branch's
series_rdb_savefield order matches the test's manual RDB parser; compressed-chunk field order andSERIES_OPT_COMPRESSED_GORILLA == 2confirmed on-branch. - No conflict markers, the test file byte-compiles, and all five
_rdb_*helpers are defined exactly once.
Red legs, neither caused by this change:
build-linux-x64 / x64-bullseye— infra. Debian 11 moved to archive, sodeb.debian.org/debian-security bullseye-security404s for every package. Branch-independent; it reddens every open PR until CI pinsarchive.debian.orgor drops bullseye.- SonarCloud —
40.9% Duplication on New Code(gate requires ≤3%), from the ~45-line field-walking preamble shared by_patch_first_compressed_chunk_misalign_sizeand_patch_first_compressed_chunk_count. Inherited from #2086, not introduced here.
Non-blocking follow-up: master #2086 still carries the hard-coded payload and the bare .error(), so master is now behind its own backports. Worth forward-porting the follow-up commit so the next sync doesn't conflict.
Note the rest of CI is still running as I approve; I'm watching the stack and will flag any red leg that isn't red on its own base branch.




Note
High Risk
Changes the untrusted RDB/RESTORE ingestion path with new validation that rejects previously loadable malicious payloads; incorrect checks could break legitimate dumps or leave gaps in exploit prevention.
Overview
Hardens RESTORE/RDB load for compressed time-series chunks by rejecting inconsistent or attacker-crafted metadata before Gorilla decompression can touch misaligned buffers.
Compressed_LoadFromRDBnow fails load whensize≠ actual data length, whensizeis not 8-byte aligned (matchingbinary_tword access in gorilla), and when inflatedcountcannot be supported byidx(usingidx/2 < count-1to avoid overflow on hugecountvalues).series_rdb_loadrejectschunkSizeBytesof 0 or not divisible by 8 at series load time.Flow tests patch valid
DUMPpayloads to exercise size/length mismatch, non-aligned buffers, and boguscountvalues (including near-overflow), expecting Bad data format and no partial key restore.Reviewed by Cursor Bugbot for commit 25892b0. Bugbot is set up for automated code reviews on this repo. Configure here.