Relationships
#4718 local_encryption silently generates a new key when .key is missing, making every existing secret unreadable
Opened by zack · 11/13/2026· Shipped 11/13/2026
With auto_generate: true, if a local_encryption vault's .key (or its key_file) is missing, the next operation that loads key material generates a new random key and writes it. The code is loadKeyMaterial in src/domain/vaults/local_encryption_vault_provider.ts: a NotFound on the key file leads straight to key generation. Nothing checks whether the vault directory already holds .enc files encrypted with the old key.
Result: after the key is lost, deleted, or not copied along with the secrets (for example, secrets restored from a backup without .key), the first put silently succeeds with a new key. Every existing secret then fails with "Failed to retrieve secret". There is no warning at the moment the damage happens. The old secrets cannot be recovered with the new key, and the user learns about it later, on a read.
Expected: when the key file is missing but the vault directory already contains .enc files, refuse to generate a key. The error should say the key is missing and the existing secrets cannot be decrypted without it, and point to restoring the key. Only generate a key for a vault with no secrets yet.
Found during a UAT coverage audit for swamp-club#4704; end-to-end coverage is requested in swamp-uat#955 case 7.
Shipped
Click a lifecycle step above to view its details.
Sign in to post a ripple.