Encryption
Coldrune encrypts every secret with AES-256-GCM using a two-level key hierarchy.
Key hierarchy
Section titled “Key hierarchy”For each secret:
- A random 32-byte DEK (Data Encryption Key) is generated
- The secret value is encrypted with the DEK using AES-256-GCM
- The DEK is encrypted with the KEK using AES-256-GCM
- Stored:
encrypted_value,nonce,encrypted_dek,dek_nonce
The master key never encrypts data directly. It derives the KEK and backup key through HKDF-SHA256.
Generate a master key
Section titled “Generate a master key”This produces a 64-character hex string (256 bits). Store it securely — losing the master key means losing all secrets.
Key rotation
Section titled “Key rotation”If you suspect key compromise or want to rotate keys as a policy:
-
Stop the server
-
Rotate
This re-encrypts all DEKs with the new KEK in a single atomic transaction. Secret values and their nonces are unchanged — only the DEK encryption is rotated.
-
Update
COLDRUNE_MASTER_KEYin your.envfile with the new key (printed to stdout) -
Restart the server
-
Create a new backup — old backups are encrypted with the old key
What rotation changes
Section titled “What rotation changes”| Component | Changed? |
|---|---|
| Master key | Yes (new value) |
| KEK | Yes (derived from new master key) |
| Each DEK’s encryption | Yes (re-encrypted with new KEK, fresh nonces) |
| Secret values | No (encrypted data unchanged) |
| Backup key | Yes (derived from new master key) |
| Existing backups | No (still encrypted with old key) |
Tamper detection
Section titled “Tamper detection”AES-GCM includes an authentication tag. Any modification to the ciphertext, nonce, or DEK causes decryption to fail. Coldrune does not silently return corrupted data.