Skip to content

fix(indexed-tree): close security invariant gaps - #773

Merged
QuantumExplorer merged 1 commit into
claude/gallant-elion-214ef4from
codex/fix-indexed-tree-security
Jul 28, 2026
Merged

QuantumExplorer merged 1 commit into
claude/gallant-elion-214ef4from
codex/fix-indexed-tree-security

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Jul 14, 2026 •

Copy link
Copy Markdown
Member

Summary

Root causes and fixes

  • Batch authority and cleanup: validate caller-supplied tree types against stored elements, cover every indexed-tree variant and bare references, and apply count-index secondary changes atomically.
  • Verification: verify PSIT and PCPSIT secondary keys, row membership, and payload relationships rather than only comparing aggregate roots.
  • Specialized operations: use Euclidean division for negative averages, bind commitment-tree children to the empty commitment state root, reject BigSumTree at the signed 64-bit boundary, and enforce NonCounted parent policy for specialized indexed subtrees.

Validation

  • cargo test -p grovedb indexed_tree — 239 passed
  • cargo test -p grovedb-merk insert_count_indexed_subtree — 6 passed
  • cargo test -p grovedb-element indexed::sort_keys — 12 passed
  • focused regression tests for the cross-cutting security cases — 6 passed
  • cargo clippy -p grovedb-element -p grovedb-merk -p grovedb -- -D warnings
  • cargo fmt --all -- --check

Rebased and conflict-tested against feature commit 47cff3ad. This remains a security-hardening follow-up to #657 and intentionally targets its feature branch.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 14c1fbe9-1320-42bd-b121-403e9737cd7a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-indexed-tree-security

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@QuantumExplorer
QuantumExplorer marked this pull request as ready for review July 14, 2026 15:03
@QuantumExplorer
QuantumExplorer force-pushed the codex/fix-indexed-tree-security branch from bd6f09c to 4f213c4 Compare July 27, 2026 12:14
@QuantumExplorer
QuantumExplorer merged commit 5fb6aff into claude/gallant-elion-214ef4 Jul 28, 2026
@QuantumExplorer
QuantumExplorer deleted the codex/fix-indexed-tree-security branch July 28, 2026 05:06
QuantumExplorer added a commit that referenced this pull request Sep 7, 2026
…anup (#888) (#934)

* fix(grovedb): sweep nested indexed secondaries in every recursive cleanup (#888)

Recursive storage cleanup discovered nested subtrees via find_subtrees
and cleared their primary namespaces, but a nested indexed-tree
primary's per-axis secondary namespaces live at
Blake3(prefix ‖ axis_tag) — outside the path-prefix walk — and were
orphaned by:

- full-batch DeleteTree cleanup,
- partial-batch DeleteTree cleanup,
- the batch cidx safe-subset overwrite cleanup,
- the dedicated indexed-tree child overwrite.

Prefixes are path-derived, so recreating the same path resurrected the
stale secondary rows and broke primary-secondary agreement (reads named
primary entries that no longer exist).

Extract the direct delete's per-descendant sweep (which was already
correct) into one shared routine, GroveDb::clear_subtree_storage_recursively,
that clears every discovered subtree's primary namespace plus all three
axis secondary namespaces, and use it from all six call sites (delete
v0/v1 keep their exact cost sequence). Indexed trees are GROVE_V4-era
and the sweep is idempotent on empty namespaces, matching the ungated
precedent of the existing sweeps (#657/#732/#773).

Co-Authored-By: Claude Fable 5 <[email protected]>

* fix: preserve versioned batch cleanup costs

---------

Co-authored-by: Claude Fable 5 <[email protected]>
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.

1 participant