Repository navigation
MOD-13409 Harden RDB loading (backport to 8.8) - #1044
Conversation
* 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.
* 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.
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 68c7885. Configure here.
| _lzf_decompress(comp, ulen) | ||
| pos = comp_end | ||
| continue | ||
| raise RuntimeError(f"Unknown module opcode {opcode} at pos={pos}") |
There was a problem hiding this comment.
Test parser missing SINT opcode for signed integers
High Severity
The _corrupt_dump_set_first_uint_after_3_doubles parser only handles RDB_MODULE_OPCODE_UINT (2), RDB_MODULE_OPCODE_DOUBLE (4), RDB_MODULE_OPCODE_STRING (5), and RDB_MODULE_OPCODE_EOF (0). It does not handle RDB_MODULE_OPCODE_SINT (1). The TDigest RDB format saves cap, merged_nodes, unmerged_nodes, and total_compressions via RedisModule_SaveSigned, which writes the SINT opcode (value 1). When parsing a TDigest dump, the function encounters opcode 1 immediately after the 3 doubles and raises RuntimeError("Unknown module opcode"), making the TDigest corruption test always fail with an exception.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 68c7885. Configure here.
Avoid signed overflow when validating merged and unmerged node counts by widening the addition.
|
## Summary Bumps the RedisBloom pin on `8.8` from `v8.8.0` to `v8.8.2`. | Module | From | To | |---|---|---| | RedisBloom | `v8.8.0` | `v8.8.2` | ## RedisBloom changes ([v8.8.0...v8.8.2](RedisBloom/RedisBloom@v8.8.0...v8.8.2)) - MOD-13409 — Harden RDB loading, including validation of crafted module payloads ([#1044](RedisBloom/RedisBloom#1044)) ## Test plan - [x] Confirmed `v8.8.2` exists in RedisBloom - [x] Validated `modules/redisbloom/Makefile` pins `MODULE_VERSION` to `v8.8.2` - [ ] Redis core CI passes with the updated module pin <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Single Makefile version pin with no local logic changes; upstream change targets safer RDB deserialization, which is a security hardening rather than new surface area in this repo. > > **Overview** > Bumps the **RedisBloom** build pin from `v8.8.0` to **`v8.8.2`** in `modules/redisbloom/Makefile` (`MODULE_VERSION` only). > > Upstream **v8.8.1–v8.8.2** includes **MOD-13409**: hardened **RDB loading** and validation of crafted module payloads ([#1044](RedisBloom/RedisBloom#1044)). > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 4c2c922. 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.8.
Testing
Note
High Risk
Changes sit on the security-sensitive RDB restore path; bad input could previously cause buffer/size desync or OOB access, though behavior for valid snapshots should be unchanged.
Overview
Backport hardening for RESTORE/RDB loads so crafted or truncated module payloads are rejected instead of trusting serialized metadata.
Bloom (
BFRdbLoad) now rejects missing/empty/oversized bitset buffers, tiesbitsto buffer size for newer encodings (keeping the legacy minimum-byte check forencver == 0), boundsn2, and still runsbloom_validate_integrity.Cuckoo (
CFRdbLoad) validates filter counts and bucket limits before narrowing touint16, callsCuckooFilter_ValidateIntegritybefore allocating sub-filters, and replaces debugasserts with explicit checks that each sub-filter’s serialized blob length matchesbucketSize × numBuckets(power-of-two buckets required).TDigest (
TDigestRdbLoad) ensurestd_newsucceeded, requires loadedcapto match the arrays allocated from compression, and tightens checks on merged/unmerged node counts relative to that cap.Patch version bumps to 8.8.2. New flow tests corrupt
DUMPpayloads (shrunk module strings for BF/CF, inflated cap for TDigest) and assertRESTOREerrors while the server stays healthy.Reviewed by Cursor Bugbot for commit 636584c. Bugbot is set up for automated code reviews on this repo. Configure here.