Repository navigation
MOD-13409 Harden RDB loading (backport to 8.2) - #1041
Conversation
* MOD-13409 Validate Bloom RDB bitset size on load (#126) * MOD-13409 Validate Bloom RDB bitset size on load Reject crafted module payloads where the loaded bloom bitset buffer length does not match the declared bits/n2, and add a flow regression test covering RESTORE with a corrupted DUMP payload. * MOD-13409 clang-format rebloom.c Run clang-format on rebloom.c to satisfy make lint formatting checks. * MOD-13409 Validate Bloom RDB bitset length on load Reject crafted module payloads where persisted bits do not match the loaded bitset buffer length, preventing OOB access after RESTORE. (cherry picked from commit ecbdc81) * Mod 13409 rdb hardening (#127) * MOD-13409 clang-format rebloom.c Run clang-format on rebloom.c to satisfy make lint formatting checks. * MOD-13409 Harden CF RDB load buffer validation Replace assert-only checks in CFRdbLoad with explicit validation of loaded sizes and ranges, and add a flow test that corrupts a CF DUMP payload to ensure RESTORE is rejected. * MOD-13409 Harden remaining RDB loaders (TDigest) TDigest RDB loading trusted attacker-controlled cap, which could desync the allocated centroid arrays from the loaded metadata and enable OOB access after RESTORE. Reject payloads where loaded cap differs from the allocated cap derived from compression, validate node counters, and add a flow regression that corrupts a TDigest DUMP payload and asserts RESTORE is rejected. With the earlier BF/CF fixes, this covers all remaining module data structures that load raw buffers from RDB/RESTORE (CMS/TopK already validate buffer sizes). * Revert "MOD-13409 clang-format rebloom.c" This reverts commit 456e53503f51b68c4d7a9df988e50a36adf2e61a. (cherry picked from commit a4b4f80)
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
❌ 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 dd17556. Configure here.
| raise RuntimeError(f"Unknown module opcode {opcode} at pos={pos}") | ||
|
|
||
| if not patched: | ||
| raise RuntimeError("Did not find target SINT to patch") |
There was a problem hiding this comment.
Test corruption function missing SINT opcode handling
High Severity
_corrupt_dump_set_first_uint_after_3_doubles only handles opcodes RDB_MODULE_OPCODE_UINT (2), RDB_MODULE_OPCODE_DOUBLE (4), RDB_MODULE_OPCODE_STRING (5), and RDB_MODULE_OPCODE_EOF (0). TDigest saves all its integer fields (cap, merged_nodes, unmerged_nodes, total_compressions) via RedisModule_SaveSigned, which uses the RDB_MODULE_OPCODE_SINT opcode (value 1). When parsing encounters SINT opcode 1, no condition matches and execution falls through to raise RuntimeError("Unknown module opcode 1"), crashing the corruption helper before it can patch anything. The TDigest test test_restore_rejects_corrupted_tdigest_cap cannot work as written.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit dd17556. Configure here.
Avoid signed overflow when validating merged and unmerged node counts by widening the addition.
|
## Summary Bumps the RedisBloom pin on `8.2` from `v8.2.12` to `v8.2.15`. | Module | From | To | |---|---|---| | RedisBloom | `v8.2.12` | `v8.2.15` | ## RedisBloom changes ([v8.2.12...v8.2.15](RedisBloom/RedisBloom@v8.2.12...v8.2.15)) - MOD-16050 — Replicate `CF.LOADCHUNK` data chunks to prevent silent Cuckoo Filter data loss on failover ([#1019](RedisBloom/RedisBloom#1019)) - MOD-13409 — Harden RDB loading, including validation of crafted module payloads ([#1041](RedisBloom/RedisBloom#1041)) ## Test plan - [x] Confirmed `v8.2.15` exists in RedisBloom - [x] Validated `modules/redisbloom/Makefile` pins `MODULE_VERSION` to `v8.2.15` - [ ] Redis core CI passes with the updated module pin <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Upstream changes affect replication and persistence loading for Bloom/Cuckoo data; risk is moderate but bounded to the RedisBloom module pin, not core Redis. > > **Overview** > Bumps the RedisBloom build pin from **v8.2.12** to **v8.2.15** via `MODULE_VERSION` in `modules/redisbloom/Makefile`, so CI and packaging pull the newer upstream release. > > That release includes replication fixes for **`CF.LOADCHUNK`** (avoiding Cuckoo Filter data loss on failover) and **stricter RDB load validation** for crafted module payloads. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit a95ebed. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->





Summary
Backport of #1038 to 8.2.
Testing
Note
Medium Risk
Changes only deserialization paths but malformed RDB could previously cause OOB reads or memory issues; stricter rejection is the main behavioral change on restore.
Overview
Hardens RedisBloom RDB/DUMP restore so crafted or truncated module payloads are rejected instead of trusting serialized metadata or buffer sizes.
Bloom (
BFRdbLoad) now rejects null/empty bitset buffers and absurd sizes, ties bit count to buffer length for newer encodings, capsn2, and keeps integrity checks before use.Cuckoo (
CFRdbLoad) boundsnumFilters/numBucketsand uint16 fields, runsCuckooFilter_ValidateIntegritybefore allocating sub-filters, requires power-of-two sub-bucket counts, and replacesasserton bucket data with explicit length and overflow checks.TDigest (
TDigestRdbLoad) requires loadedcapto match whattd_newallocated and tightens merged/unmerged node counts against that cap before reading node arrays.Patch release 8.2.15 and new flow tests corrupt
DUMPpayloads for BF, CF, and TDigest and assertRESTOREfails while the server stays healthy.Reviewed by Cursor Bugbot for commit 0360541. Bugbot is set up for automated code reviews on this repo. Configure here.