Skip to content

Make secret removal conditional on the version read and audit only the actual deletion #349

Closed

Description

@samuelmbabhazi

Problem

Secret removal reads metadata, then deletes by id and organization without checking the version or affected row count. A rotation by another authorized account between those statements can replace v1 with v2; removal then deletes v2 while reporting metadata for v1. Concurrent removals can similarly report a deletion that no longer took place.

The account locks serialize mutations by the same user, but different authorized users lock different rows. The enclosing transaction does not lock the secret row during the initial read. This is an integrity/audit race, not secret disclosure or a permission bypass.

Evidence

PrismaSecretStore.remove. The adjacent update path already uses a version compare-and-swap.

A local test of the actual store with interleaved mocked persistence observed deletedVersion=2 and returned/auditedVersion=1. A concurrent PostgreSQL reproduction is still needed; the mock result must not be presented as such.

Acceptance criteria

  • Use a version condition and check the affected row count, or an equivalent serialization strategy.
  • With real PostgreSQL and two different authorized accounts: pause removal after reading v1, commit v2, resume removal; it must return a conflict and preserve v2, without a deletion audit event.
  • Two simultaneous removals must produce only one successful deletion and the corresponding single audit event.
  • Preserve atomicity of the state change and its audit event, including rollback on audit failure.

Activity

  1. added
    bug
    priority:P3
    on Nov 19, 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

    bugpriority:P3securitytrack:control-plane

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions