Skip to content

[audit][low] State sync commits subtree batches before final root verification #679

Description

@QuantumExplorer

Created from a Codex audit of grovedb. No code changes were made as part of the audit.

Summary

Replication state sync flushes completed subtree batches before the final app-hash check.

Impact / failure scenario

A malicious or inconsistent peer can send a snapshot that fails final verification after earlier subtrees have already been committed, leaving partially durable state even though commit_session returns an error.

References

  • grovedb/src/replication/state_sync_session.rs:251
  • grovedb/src/replication/state_sync_session.rs:263
  • grovedb/src/replication/state_sync_session.rs:290
  • grovedb/src/replication/state_sync_session.rs:590

Suggested fix

Stage restored state in a temporary DB/namespace or keep all subtree writes uncommitted until final root verification succeeds.

Suggested tests

Use subtrees_batch_size = 1, corrupt a later chunk/final hash, and assert the destination DB remains unchanged after failure and reopen.


September 2026 audit addendum — S06

Audit group: S06. Classification: correctness. Provisional severity: medium.

Audit addendum for #679, with #775 retained as a same-root related report. Provisional static review of snapshot 2fa0f133 confirms that the session can durably commit completed subtree groups before the complete snapshot has been accepted. This addendum does not claim that current develop remains affected or replace the original issue's severity assessment.

The expected failure-atomicity contract is that a rejected or incomplete synchronization cannot be published as a complete destination. At configured subtree boundaries, the session commits its previous transaction and continues using a new transaction. Further discovery, response processing and final complete-session/root checks occur afterward. A later failure or interruption cannot roll back groups already committed by the earlier transaction.

Individual nonempty chunks are still checked against expected commitments, and final root mismatch is still returned as an error. This report does not establish successful acceptance of an arbitrary root. Its material consequence is persistent partial destination state after an unsuccessful operation. Security exposure requires the additional application behavior of reusing or publishing that failed destination. Restoring into private disposable staging and promoting only after complete verification contains that consequence.

Keep rollback authority for the entire snapshot or stage it in an isolated destination that is promoted only after all verification succeeds. If durable incremental staging is necessary, record incomplete status and prevent publication until completion. Define cleanup and recovery for cancellation, interruption and ordinary late validation failures, not only the final hash comparison.

The supplied inventory shows that closed PR #735 was unmerged; open PR #840 explicitly proposes removal of intermediate commits. Those proposals are relevant remediation context, not proof of a fix in this audited snapshot. Independent records rated this mechanism medium and low. Medium here denotes correctness priority for durable partial state, with deployment-dependent security impact stated separately. No runtime transaction, failure, cancellation or reopen test was executed during this static review.

Validation to complete

  • Verify a cancelled or ordinarily rejected multi-group restore does not change the published destination.
  • Check complete snapshot promotion occurs only after all structural and root obligations pass.
  • If staging persists across restart, verify incomplete status prevents publication and supports documented recovery.

Limits and existing work

Related tracking: issue #679 (open), issue #775 (open), PR #735 (closed), PR #840 (open).

Scope: saved GroveDB worktree with revision context 2fa0f133877420a0d9c91ba7bc51b1775ab8c783. This report does not establish that current develop or any deployed application is affected. Focused runtime validation remains outstanding.

Audit source and canonical finding identifiers

Source status: snapshot-backed (git_worktree); plain source locations are used because this is not a sealed commit-only scan.

Audited revision context: 2fa0f133877420a0d9c91ba7bc51b1775ab8c783.

The findings were manually reconciled from a preserved scan bundle. The native scan ended before final completion; these are provisional source-review findings, not a completed native scan certification.

Canonical finding ID: csf_251be3d979afe66445c6b156

Primary fingerprint: codex-security/v1:sha256:fcdfc76cf0cef566df1d0d819a99c7dde9a730461d47b77631f1453a57c1f8f2

Canonical finding ID: csf_6ae52e0d802fe222eebd4233

Primary fingerprint: codex-security/v1:sha256:bf039990d7a878a93afb89df71caeb26e1a476e95752f2497f941cf74c1c7f8f

Source locations:

  • Location (root_control): grovedb/src/replication/state_sync_session.rs:291
  • Location (entrypoint): grovedb/src/replication/state_sync_session.rs:591
  • Location (expected_control): grovedb/src/replication/state_sync_session.rs:257
  • Location (sink): storage/src/rocksdb_storage/storage.rs:634
  • Location (root_control): grovedb/src/replication/state_sync_session.rs:290-294
  • Location (propagation): grovedb/src/replication/state_sync_session.rs:591-613
  • Location (outcome): grovedb/src/replication/state_sync_session.rs:257-276
  • Location (sink): storage/src/rocksdb_storage/storage.rs:634-642
  • Location (root_control): grovedb/src/replication/state_sync_session.rs:291-294
  • Location: grovedb/src/replication/state_sync_session.rs:591-598
  • Location: grovedb/src/replication/state_sync_session.rs:235-276
  • Location (entrypoint): grovedb/src/replication/state_sync_session.rs:591-598
  • Location (root_control): grovedb/src/replication/state_sync_session.rs:290-295
  • Location (expected_control): grovedb/src/replication/state_sync_session.rs:257-269
  • Location (root_control): grovedb/src/replication/state_sync_session.rs:291-293
  • Location (entrypoint): grovedb/src/replication/state_sync_session.rs:590-598
  • Location (expected_control): grovedb/src/replication/state_sync_session.rs:257-276

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:state-syncS groups: state restoration, synchronization and append-client transactions.audit:2026-09Reconciled September 2026 GroveDB audit; audited worktree at 2fa0f133.audit:needs-validationSaved source evidence reviewed; focused runtime and deployment validation outstanding.bugSomething isn't workingseverity:medium-provisionalMedium impact in the audited scenario; provisional static assessment.type:correctnessAudit reports incorrect library behavior or accounting without proven security impact.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions