test: demonstrate non-empty CountTree count swap vulnerability (C1)#632
test: demonstrate non-empty CountTree count swap vulnerability (C1)#632QuantumExplorer wants to merge 1 commit into
Conversation
Add test proving that a non-empty CountTree's count metadata can be swapped without detection when the tree appears in a proof result set without a lower-layer subquery. The verifier accepts a tampered proof where count is changed from 3 to 999 because no combine_hash check is performed for non-empty trees without subqueries. This documents a known vulnerability (C1 variant) for future fixing. The fix will require prover changes to include child merk root hashes for non-empty trees even when no subquery drills into them. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Closing — this vulnerability demonstration is superseded by PR #633, which fixes the issue and includes a test ( |
Summary
non_empty_count_tree_count_swap_in_result_set) proving that a non-empty CountTree's count metadata can be swapped from 3 to 999 without the verifier detecting the tamperingcombine_hashverification is performed — the verifier trusts theKVValueHashnode's value directlyErrexpectation once a fix lands)Root Cause
In proof verification (
verify_layer_proofV0/V1), non-empty trees that appear in the result set without being drilled into via subquery skip thecombine_hash(H(value_bytes), child_merk_root) == proof_hashcheck. This allows an attacker to substitute the serialized element bytes (changing count, sum, or other metadata) while keeping the samevalue_hash, sinceKVValueHashnodes trust the provided hash.Fix Direction
The fix requires prover-side changes: include child merk root hashes for non-empty trees even when no subquery drills into them (either via a minimal lower layer or a new proof field). This enables the verifier to perform
combine_hashchecks on all tree elements.Test plan
cargo test -p grovedb --lib non_empty_count_tree_count_swap_in_result_set)🤖 Generated with Claude Code