Skip to content

[audit][M023] SumItem reference prediction uses flags different from the effective stored value #901

Closed

Description

@QuantumExplorer

Audit group: M023. Classification: correctness. Provisional severity: low.

Reference prediction can substitute a SumItem's old flags while the recorded fixed-cost/default-callback mutation path retains supplied flags. The resulting terminal commitment can disagree with the effective stored value. This is a specific follow-up to the effective-flags contract of #329; that PR described prediction using unmerged input, whereas this saved subcase predicts old flags. Conditional-insert evidence from the original compound record is tracked only by M002.

Expected behavior: Reference prediction and SumItem mutation must use the same effective flags and serialized terminal value.

Fix direction: Share the effective post-update serialized value, including the actual flag transformation selected by the mutation/callback path, with reference creation and refresh. Do not assume old flags for every SumItem update. Cover flag-changing updates separately from conditional skip behavior and preserve replay-sensitive versions.

Validation to complete

  • Suggested: compare predicted and effective terminal serialization for SumItem flag updates under supported callback/cost paths.
  • Cover conditional-insert outcomes separately under M002 and preserve historical version expectations.

Limits and existing work

  • Custom callback behavior may differ from the saved fixed-cost/default-callback trace.
  • The original compound source record is shared provenance only: the conditional-target cause is tracked by M002.
  • Merged PR feat!: just in time flags fix and epoch based storage flags #334 reports an earlier SumItem-size/reference fix; verify its historical coverage for this effective-flags subcase before implementation.

Related tracking: PR #329 (merged), PR #552 (merged), PR #334 (merged).

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_7281668b2a309045816ca0c8

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

Source locations:

  • Location (root_control): grovedb/src/batch/mod.rs:2169
  • Location (expected_control): merk/src/element/insert.rs:379
  • Location (sink): merk/src/element/insert.rs:592
  • Location (root_control): grovedb/src/batch/mod.rs:2169-2177
  • Location (propagation): merk/src/element/insert.rs:379-390
  • Location (outcome): grovedb/src/batch/mod.rs:2611-2632
  • Location (expected_control): grovedb/src/lib.rs:2153-2176
  • Location (entrypoint): grovedb/src/batch/mod.rs:2169-2177
  • Location (root_control): merk/src/element/insert.rs:380-386
  • Location (root_control): grovedb/src/batch/just_in_time_reference_update.rs:53-65
  • Location (root_control): merk/src/tree/just_in_time_value_update.rs:43-51
  • Location (root_control): grovedb/src/batch/mod.rs:4842-4846
  • Location (root_control): grovedb/src/batch/mod.rs:2613-2637

Activity

  1. added
    bugSomething isn't working
    audit:2026-09Reconciled September 2026 GroveDB audit; audited worktree at 2fa0f133.
    area:mutations-referencesM groups: batches, inserts, deletes, tree metadata and references.
    type:correctnessAudit reports incorrect library behavior or accounting without proven security impact.
    severity:low-provisionalLow impact in the audited scenario; provisional static assessment.
    audit:needs-validationSaved source evidence reviewed; focused runtime and deployment validation outstanding.
    on Sep 6, 2026
  2. QuantumExplorer commented on Nov 13, 2026

    @QuantumExplorer
    MemberAuthor

    Fixed by #1021: from GROVE_V4 a same-batch reference to a sum item commits to the bytes that are stored (apply_batch.same_batch_reference_target_prediction: 1). GROVE_V1 to V3 keep the old behaviour and are frozen.

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:mutations-referencesM groups: batches, inserts, deletes, tree metadata and references.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:low-provisionalLow 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