Skip to content

fix(secrets): restore DeleteSecret for synchronized keys on writable storage#3859

Draft
cursor[bot] wants to merge 1 commit into
developfrom
cursor/critical-correctness-bugs-5677
Draft

fix(secrets): restore DeleteSecret for synchronized keys on writable storage#3859
cursor[bot] wants to merge 1 commit into
developfrom
cursor/critical-correctness-bugs-5677

Conversation

@cursor
Copy link
Copy Markdown

@cursor cursor Bot commented May 16, 2026

Summary

Fixes a regression from 757e9e9c (vault sync refactor) in AccessKeyServiceImpl.Delete.

Bug and impact

When deleting an access key backed by a writable external secret store (Vault, AWS SM, etc.), if the key was marked synchronized, the service skipped DeleteSecret entirely. The Semaphore DB row was still removed, so the credential could remain in the external vault as an orphan—a correctness and hygiene issue (and a potential security concern if operators assume deletion removes the secret everywhere).

Root cause

The refactor combined storage.ReadOnly and key.Synchronized into a single branch that always skipped DeleteSecret. The intended behavior (from the earlier read-only fix) is:

  • Writable storage: always remove the secret from the backend when deleting the key.
  • Read-only storage + synchronized: reject delete (cannot unlink synced reference from a read-only backend).
  • Read-only storage + not synchronized: allow removing the Semaphore row without calling the backend delete.

Fix

Restore the previous branching: only skip DeleteSecret when the storage is read-only; keep the user-facing error for synchronized keys on read-only storage.

Validation

  • go test ./services/server/ -count=1
  • New unit tests: writable+synchronized (expects one DeleteSecret), read-only+non-sync (expects zero), read-only+synchronized (expects error and no DB delete).
Open in Web View Automation 

…rage

Commit 757e9e9 merged key.Synchronized into the read-only branch, so
deleting a synchronized access key skipped backend secret removal whenever
Synchronized was true—even for writable vaults—orphaning credentials.

Restore the pre-refactor rules: block delete only for synchronized keys on
read-only storage; always invoke DeleteSecret when the storage is writable.

Add unit tests for writable+synchronized, read-only+non-sync, and
read-only+synchronized cases.

Co-authored-by: Denis Gukov <fiftin@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant