Skip to content

Viewer /api/restore: require a reason, append an audit event, default to merge not force #221

Closed as not planned

Description

@abogartz

Finding

src/viewer/server.ts:330-349 reaches the destructive restore primitive with no reason and no audit record, and const mode = body.mode === "merge" ? "merge" : "force" (line 343) makes an absent or misspelled mode select the clobbering path. The viewer enforces requireReason() for delete, block, quarantine and unreject (src/viewer/mutate.ts:49-51); restore requires nothing. The store's own memory_undo records the operation; the HTTP route to the same primitive asks for nothing.

Fix direction

Require a non-empty reason, append one audit event per restore, and invert the default so force must be requested by name. The zod omission itself is accepted (the restore contract is owned by src/undo.ts).

Adjacent issues: #207 (restore drops quarantine/provenance metadata) and #214 (force-undo vs tombstoned values) cover different defects on the same primitive.

Source

Architecture review 2026-10-31, finding S3 (Med).

Activity

  1. added
    bug
    store-security
    severity:medium
    agent:ready
    on Nov 1, 2026
  2. abogartz commented on Nov 3, 2026

    @abogartz
    OwnerAuthor

    Triage 2026-11-03: marked agent:ready. Spec reviewed against main 3d34a63: finding stands — /api/restore is still the one route deliberately outside schema-parse (server.ts:261) with no reason and no audit, and the mode ternary still defaults to the clobbering path. Fix direction states the three criteria (require non-empty reason, one audit event per restore, force only by name). RED/GREEN: a POST without reason / without mode:"force" succeeds on main today (RED); after the fix it must 400 and land the audit line (GREEN). No overlap with open PR #269.

  3. ocsi-triager commented on Nov 3, 2026

    @ocsi-triager

    osi-spec-hash: 8ee2966746e14404 2026-11-03T17:21:42Z - acceptance criteria frozen at this text. A later edit to the body changes this hash, and the reviewer will withhold approval until a maintainer replies spec ok.

  4. added
    spec:incomplete
    on Nov 3, 2026
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

    agent:readybugseverity:mediumspec:incompletestore-security

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions