Repository navigation
MOD-13409 Harden RDB loading (backport to 2.4) - #1043
Merged
Merged
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 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 e8e7802. Configure here.
Avoid signed overflow when validating merged and unmerged node counts by widening the addition.
|
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.




Summary
Backport of #1038 to 2.4.
Testing
Note
Medium Risk
Changes only RDB load paths and reject invalid input; legitimate snapshots should be unaffected, but stricter validation could theoretically reject edge-case encodings that previously loaded.
Overview
Backport of RDB-load hardening so malicious or truncated DUMP/RESTORE payloads fail during module load instead of trusting on-disk sizes.
Bloom (
BFRdbLoad): Rejects null/empty/oversized bitset buffers; for newer encodings requiresbits == sztmp * 8; validatesn2and power-of-two constraints; keeps legacy minimum-byte check forencver == 0.Cuckoo (
CFRdbLoad): Bounds-checks filter/bucket counts and uint16 fields before cast; runsCuckooFilter_ValidateIntegritybefore allocating sub-filters; requires power-of-two sub-bucket counts and exact serialized buffer length vsbucketSize * numBuckets; replaces assert-based checks with explicit errors.TDigest (
TDigestRdbLoad): Ensures loadedcapmatches arrays allocated bytd_new(compression)and tightens merged/unmerged node count checks against that cap.Patch version 2.4.23 → 2.4.26. New flow tests craft corrupted DUMP payloads (shrunk module strings, inflated TDigest cap) and assert
RESTOREerrors while the server stays healthy.Reviewed by Cursor Bugbot for commit 56509a6. Bugbot is set up for automated code reviews on this repo. Configure here.