feat(vault): implement key versioning and rotation for encrypted secrets (#203)#310
feat(vault): implement key versioning and rotation for encrypted secrets (#203)#310vansh-09 wants to merge 16 commits into
Conversation
utksh1
left a comment
There was a problem hiding this comment.
Requesting changes. This overlaps with the vault crypto fix in #279 and should be redesigned on top of AES-GCM. Please avoid accepting old vault keys in an API request body, avoid mutating global settings during a request, and add a migration/rotation flow that fails closed on mixed or undecryptable records.
0f319e1 to
ae48084
Compare
874bd71 to
4c8ea0b
Compare
|
@utksh1 please review this PR. |
|
Thanks for following up. Clarifying the change request so it is actionable: Why this is blocked: What to do next:
|
utksh1
left a comment
There was a problem hiding this comment.
Re-reviewed after the update, but backend-tests are still failing and the PR changes CI to skip benchmark/frontend unit/build on pull_request, which is unrelated and weakens verification. Please restore CI behavior, fix backend tests, and keep the vault rotation change focused.
|
Current status: still blocked. The credential lifecycle/key-rotation PR is conflicting with current main. Please rebase and keep migration/backward-compatibility and secret redaction behavior explicit, with focused vault tests. |
|
Re-reviewed after the latest push. Still blocked: backend tests are not complete/green yet and the PR still changes CI behavior outside the vault-rotation scope. Please restore unrelated CI behavior, fix backend tests, and keep migration/backward-compatibility plus redaction coverage focused on vault rotation. |
|
Re-reviewed after the latest push. Still blocked: vault rotation needs green backend tests and should not change unrelated CI behavior. Please keep the PR focused on key versioning/migration/backward-compatibility and secret redaction coverage. |
Description
Implements vault key versioning and a transactional key rotation workflow:
key_versioncolumn tocredential_vaultrows and DB migration support.VaultCryptoversion-aware encrypt/decrypt helpers and the ability to try multiple keys when decrypting.POST /api/v1/vault/rotateendpoint that accepts the previous key (old_key) and attempts to re-encrypt all stored vault entries with the current key in a single transaction. If any entry cannot be decrypted, the rotation aborts and the DB is rolled back.SECUSCAN_VAULT_KEY_PREVIOUSenvironment variable or becauseold_keywas supplied to the rotation endpoint (the endpoint temporarily records it in memory).docs/vault-rotation.mddescribing operator workflow, API usage, and security notes.Related Issues
Fixes #203
Type of Change
How Has This Been Tested?
testing/backend/unit/test_vault_rotation.py(covers rotate success, missing key, and rollback behavior).GET /api/v1/vault/{name}.Notes: In CI or production, prefer configuring
SECUSCAN_VAULT_KEY_PREVIOUSin the process environment before rotation so the server can decrypt legacy entries across restarts.Test results (local): 16 passed, 1 warning.
Checklist