Skip to content

MOD-17621 MOD-17622 Code improvements and enhancments - #1053

Merged
AvivDavid23 merged 4 commits into
masterfrom
avivd_fixes_master
Aug 17, 2026
Merged

AvivDavid23 merged 4 commits into
masterfrom
avivd_fixes_master

Conversation

@AvivDavid23

@AvivDavid23 AvivDavid23 commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Note

High Risk
Changes deserialization and integrity validation on untrusted RESTORE/RDB input—security-sensitive paths where bugs could cause crashes or memory corruption; behavior changes may reject previously loadable corrupt keys.

Overview
Hardens RedisBloom against malicious or malformed DUMP/RESTORE and RDB module payloads by validating numeric ranges, finiteness, and consistency before narrowing types or trusting serialized metadata.

Bloom (bloom_validate_integrity, BFRdbLoad, SBChain_Add): rejects null/NaN/Inf error and bpe, overflow-prone bit/hash math, invalid options/growth, and inconsistent chain state after load; adds overflow guards when scaling filters.

CMS, TopK, and TDigest loaders get similar bounds checks (e.g. CMS array allocation size, TopK heap/item NUL handling and itemlen from buffer length, TDigest cap vs allocation, integral weights, centroid sum vs merged weight).

TopK reload behavior is fixed for INCRBY 0 and empty-string items (ambiguous single-NUL encoding).

Flow tests expand corrupt RDB helpers and add coverage for Bloom, TopK, TDigest, and CMS restore rejection plus legitimate TopK reload cases.

Reviewed by Cursor Bugbot for commit 300a940. Bugbot is set up for automated code reviews on this repo. Configure here.

AvivDavid23 and others added 3 commits August 13, 2026 12:32
* MOD-15410 TOPK - OOB access after restore validation cleanup

* format

* more gaurds for memory

(cherry picked from commit 5d17079)
…ous payloads(after lili fixes) (#171)

* more guards against CMS rdb load malicious payloads

* topk->heap error gaurd

* .

* Revert "topk->heap error gaurd"

This reverts commit 27454d26f492e0e4f4f68addc4cf44cadc3902b6.

(cherry picked from commit 492d15b)
* Fix TDigest RDB load node count overflow check

Avoid signed overflow when validating merged and unmerged node counts by widening the addition.

* Validate TDigest RDB node counts before narrowing

Load merged and unmerged node counts into int64_t locals, validate their combined capacity with an overflow-free subtraction check, and narrow only after validation. Add RESTORE regressions for both fields using values above the int range.

* Explicitly bound TDigest RDB node counts to int range

* Update t-digest-c with TDigest capacity guard

* Avoid null TDigest cleanup on RDB load failure

* Validate TopK RDB item buffers before use

* Validate TDigest RDB numeric state before conversion

* Validate Bloom RDB numeric state before narrowing

* Fix TDigest corrupt-RDB test SINT parsing

* Remove redundant TDigest RDB weight overflow check

* Validate TDigest centroid weight totals on RDB load

* Handle signed integers in corrupt RDB test helpers

* Update t-digest-c 64-bit capacity guard

Advance the t-digest-c dependency to include explicit uint64_t capacity derivation and allocation-bound validation from RedisBloom/t-digest-c#41. This addresses review feedback without changing the existing published commits.

(cherry picked from commit 9f42a26a57d88fd9331d1b577763654f5d894eb4)
Comment thread src/rm_topk.c Resolved
@codecov

codecov Bot commented Aug 17, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.92063% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.03%. Comparing base (a39ef31) to head (300a940).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1053      +/-   ##
==========================================
+ Coverage   82.71%   83.03%   +0.31%     
==========================================
  Files          21       21              
  Lines        3275     3360      +85     
==========================================
+ Hits         2709     2790      +81     
- Misses        566      570       +4     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
22.5% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ 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 300a940. Configure here.

env.cmd("RESTORE", corrupt_key, 0, corrupted)
env.assertEqual(env.cmd("EXISTS", corrupt_key), 0)

env.assertEqual(env.cmd("PING"), True)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate TopK restore tests

Low Severity

testTopKRestoreCorruptRDB and test_restore_topk_inflated_itemlen_is_safe were added here even though the same class and test already exist in test_topk_restore_corrupt_rdb.py, along with another copy of _murmur2. Duplicate suites increase noise and risk of fixing only one copy.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 300a940. Configure here.

@AvivDavid23
AvivDavid23 merged commit 9f3764d into master Aug 17, 2026
61 of 63 checks passed
@AvivDavid23
AvivDavid23 deleted the avivd_fixes_master branch August 17, 2026 07:46
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.

2 participants