What HxVault Is

HxVault replaces the previous single-platform-key approach to protecting data like connector credentials with true envelope encryption: a master key wraps many per-tenant keys, and each per-tenant key encrypts that tenant's data. Because each tenant's key is random and stored (never re-derivable), destroying it — crypto-shredding — leaves the ciphertext unreadable forever, even to the platform operator.

HxVault is the data-encryption half of the security stack; OpenBao is the secrets-manager half that holds the master key (see Architecture). HxVault is not a screen or an API you call directly — it is the crypto layer the platform uses internally whenever it stores protected data.

Why crypto-shredding matters: When a tenant exercises their right to be forgotten, you don't have to hunt every row and backup that holds their data. Destroy their key and every copy of that ciphertext — live, replicated, or in a backup — becomes mathematically unrecoverable at once.

The Key Hierarchy

HxVault uses three layers. The master key (KEK) wraps each tenant's data key (DEK); the DEK encrypts the actual field data. All encryption is AES-256-GCM.

  KEK  (master, 32 bytes)        from VELARIS_CASE_KEK, rendered from OpenBao at startup
     |  wraps / unwraps  (AES-256-GCM)
     v
  per-tenant DEK  (random 32 bytes, STORED wrapped)   >   tenant_deks table
     |  encrypts / decrypts field data  (AES-256-GCM, AAD-bound)
     v
  ciphertext   "hxv2:<tenant|->:<key_version>:<context>:<payload>"

How It Protects Data

Three Ciphertext Formats

FormatCipherKeyWritten?
hxv2:AES-256-GCMPer-tenant DEK — can be crypto-shreddedYes, wherever the caller has a tenant and a database session
hxv3:AES-256-GCMPlatform key derived from the auth secretYes, everywhere else
hxv1:Hand-rolled keystream with an HMAC tagPlatform key derived from the auth secretNever — read only

hxv1 was not broken: it appended an authentication tag and verified it before decrypting, so stored secrets were never trivially forgeable. It was replaced because it was cipher code written by hand in a platform that already depends on a vetted AES-GCM implementation, and because it derived both the keystream and the authentication tag from a single key.

Writers prefer hxv2 and fall back to hxv3 when a tenant key cannot be resolved — never to plaintext, and never to a failed write. A table holding a mix of the two is the expected steady state, not a migration debt.

Adopting a Master Key

When no master key is configured, one is derived from the platform’s auth secret so that development round-trips work. Adopting a real one is not a configuration change: setting the variable changes the master key, and every tenant key already wrapped under the derived one stops opening — the platform returns with its tenants’ data unreadable and nothing saying why.

The supplied tool re-wraps every readable tenant key under a new master key in a single transaction, verifying each one opens under the new key before replacing the old, and prints the value once. Re-wrap first, set the variable second, restart third. It refuses to run when the variable is already set, or while any active key is unreadable.

What You See When a Key Is Missing

The two failures look identical inside the system — the key is simply not in the cache — but they mean opposite things to whoever is called, so they are reported as different HTTP responses. Confusing them costs a retry loop, an escalation, and a restore attempt that cannot work.

CodeHTTPMeaningWhat to do
VEL-VAULT-DEK-503503Transient. The vault is sealed or unreachable, or the master key is unset. The data is intact.Unseal or restore connectivity, then retry. If only some workers are affected, wait for the next cache reconcile.
VEL-VAULT-SHREDDED-410410Terminal. The key was destroyed on purpose. The ciphertext remains and is permanently unreadable.Nothing. There is no recovery path, and restoring a database backup does not help — the backup holds the same ciphertext and the key is gone from the vault too. Confirm the shred was intended; it is an audited action.
410, not 404 or 500, deliberately. A 500 invites a retry loop and then a pointless restore attempt; a 404 implies the record never existed. 410 Gone says exactly what happened: it existed, and it is permanently unavailable.
Master key residency: In this phase the master key is rendered into the environment from OpenBao. Per-tenant shredding is fully effective, but a future phase moves the master key into an OpenBao transit engine (with bring-your-own-key) so it never leaves the vault. Backup-retention policy should also account for backups that still hold wrapped keys.

Capabilities

🔑
Per-Tenant Keys
Each tenant's data is encrypted under its own random key, wrapped by the platform master key. Isolation is cryptographic, not just logical.
🔥
Crypto-Shredding
Destroy a tenant's key and every copy of their encrypted data — live, replicated, or backed up — becomes permanently unrecoverable. Real GDPR Article 17 erasure.
🔒
Tamper-Evident
AES-256-GCM with authenticated context means any modification to a stored value is detected and rejected on decryption.
🔄
Zero-Downtime Adoption
Legacy and plaintext values are read transparently and upgraded to the vault format on the next write — no migration outage.