ElementsVault

Key Rotation

Rotate secret versions under a fresh data key, rewrap the master key, and seal or unseal the builtin vault.

Key rotation keeps credentials and encryption keys moving without dropping the app. On the builtin vault driver you rotate a secret version (fresh data key) or the master key (KEK rewrap). Contract rotate: "90d" is a Console cadence hint — it does not rotate by itself.

For operators and Flows that must cut over keys safely — prefer CLI for master material; use fx.vault.rotate for path versions inside privileged Flows.

The one rule

Never pass master keys as CLI argv in shared shells — they land in history. Prefer oke vault unseal --key -, the env OKE_VAULT_MASTER_KEY, or the hidden prompt.

Smallest Example

Initialize and set a secret (builtin driver)

# drivers.vault = "vault" — SQL-backed AES-256-GCM
oke vault init          # prints master key once — store out of band
export OKE_VAULT_MASTER_KEY=# or --key - from stdin

oke vault set STRIPE_KEY
# prompts for value, or: oke vault set STRIPE_KEY sk_live_…

Rotate to a new version

oke vault rotate STRIPE_KEY sk_live_new_key
# → oke vault: rotated STRIPE_KEY → v2 (fresh data key)

Omit the value to re-encrypt the current cleartext under a new data key (version bumps, readers still see the same string until you change it).

Confirm status

oke vault status
# initialized, unsealed, kek version, secret count

Progressive Patterns

From CLI path rotate to Flow mutations, cadence hints, and master rewrap:

oke vault rotate prod/api/stripe sk_live_new
oke vault rotate prod/api/stripe          # same cleartext, fresh DEK

Needs an unsealed builtin backend. Missing path:

oke vault: no such secret: prod/api/stripe

Version physics

Rotate — version vs master

fresh DEK · KEK rewrap
idle
rotate
done
shared beat across both paths
  • secret versionoke vault rotate STRIPE_KEY
    • pathSTRIPE_KEY
    • versionv1
    • DEKcurrent
    • cleartextunchanged*

    New version under a fresh data key. Pass a value to change what readers see; omit to re-encrypt only.

  • master keyoke vault rotate-master
    • kekVersionv1
    • DEKswrapped
    • secretssame cleartext
    • operator·

    New KEK generation — every DEK re-wrapped. Print the new master once; update OKE_VAULT_MASTER_KEY.

* Cleartext changes only when you pass a new value to rotate / fx.vault.rotate.

Builtin storage encrypts each version with its own data key (DEK), wrapped by a KEK derived from the master key:

OperationWhat changesReaders see
set / rotate + valueNew version + (rotate) fresh DEKNew cleartext on next get
rotate without valueNew version + fresh DEKSame cleartext
rotate-masterNew KEK; DEKs re-wrappedSame cleartexts; new master required
deleteCrypto-shred pathSubsequent get misses

Paths are slash-separated with no leading slash (prod/api/stripe). Invalid paths throw VaultError INVALID_PATH.

Consequence: secret access is not journaled — durable Flow replay re-reads live vault state after a rotate instead of replaying a stale credential from the journal.

Seal & unseal

Command / stateMeaning
oke vault initCreate backend state; print master key once
oke vault sealDrop in-memory master; reads fail with SEALED
oke vault unsealRestore master from --key / env / prompt
oke vault statusinitialized, sealed flag, kekVersion, secretCount
oke vault unseal --key -          # read base64 master from stdin
oke vault status --json

CLI reference

Env / dotenv bag loop:

CommandPurpose
oke vault set <NAME> [value]Write / overwrite a name
oke vault listList names (never values)
oke vault import <file>Bulk import
oke vault key rotateEnv-loop key helper

Builtin encrypted store:

CommandPurpose
oke vault initFirst-time initialize
oke vault status [--json]Seal / KEK / counts
oke vault seal / unsealMaster lifecycle
oke vault rotate <path> [value]Version + fresh DEK
oke vault rotate-masterKEK rewrap
oke vault auditAudit trail / verify / purge
oke vault purge-expiredDrop expired rows
oke vault backup / restoreFile snapshot

--url overrides the SQL URL (DATABASE_URL / OKE_STORE_SQL_URL).

Troubleshooting

Learn more

Next

On this page