Skip to content

sec(api): delayed token approval validates the execution snapshot, not the token hash at the status change #590

Closed

Description

@cristim

Found in the review of PR #589 (closed #586). approveViaToken validates the approval token against the execution loaded at the start of the request, then approveWithDelay does a status CAS that filters on status only, not on the token hash. A token rotated between the load and the CAS (re-notification, internal/purchase/notifications.go ~164) could still pass for a few milliseconds; the immediate path re-reads inside ApproveExecution. Practical risk is negligible (same tenant, same contact). Also: the approval token hash stays on the row after scheduling (replay is blocked by the CAS, and the cancel CAS rejects scheduled rows), and the new delayed-approval tests are mock-based, not real Postgres.

Acceptance: validate against the row inside the transition (re-read, or CAS on the token hash), with a test that rotates the token between load and CAS; optionally clear the hash on scheduling and add one real-Postgres test of the delayed approve route. Related: #586, #589, #584.

Activity

  1. IAmJSD commented on Oct 16, 2026

    @IAmJSD
    Collaborator

    Claiming: working on this

  2. added a commit that references this issue on Oct 16, 2026
    81d683e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions