Skip to content

Lesson 7 of 12 · 18m

Vault: Leases, Not a Safe

Vault brokers identity into short-lived credentials — database users it creates on demand, transit crypto as an API, and leases it can revoke mid-incident.

A freshly installed Vault starts sealed: the storage backend holds ciphertext and the key that decrypts it is itself encrypted under a master key Vault doesn't have. vault operator init runs Shamir secret sharing — five key shares by default, any three reconstruct the master key — and hands out a root token. vault operator unseal (three operators, or auto-unseal backed by a cloud KMS) rebuilds the barrier key and the backend decrypts into availability. Everything Vault stores — secrets, leases, tokens — lives under that barrier.

Identity in, credentials out

The wrong mental model: Vault is an encrypted password manager — put a password in kv/, read it back. That use exists (kv v2 is versioned static storage, so a roll back to version 3 works when version 4 breaks prod), and it's the least interesting thing the server does. The actual architecture is a broker. An auth method — kubernetes (the pod's service account JWT verified against the API server), aws (an IAM-signed GetCallerIdentity request), approle, jwt/oidc, userpass — proves an external identity and returns a Vault token bound to policies, which are path ACLs evaluated in Vault, not by the thing being called: path "database/creds/readonly" { capabilities = ["read"] } grants exactly that path and nothing else. The token carries a TTL and a renewal ceiling. Nothing about the token trusts the network; the identity was already proven, and when the TTL dies so does the access.

The database secrets engine shows why this beats storage. An app with a readonly role reads database/creds/readonly; Vault connects to Postgres and issues CREATE USER … VALID UNTIL 'now + 1h' — a real, unique, short-lived database account minted per request, tracked as a lease. vault lease renew extends it; vault lease revoke kills it; expiry deletes the DB user. Rotation becomes a non-event because credentials die before they can go stale. Revoke the lease during an incident and the credential itself disappears — something no static password can do.

The transit engine is encryption-as-an-API: vault write transit/encrypt/orders plaintext=… returns vault:v1:… ciphertext; the key never leaves Vault. Versioned key rings rotate underneath old ciphertext (min_decryption_version controls how far back reads reach). Apps get crypto without key management; Vault gets an audit line for every operation.

The honest cost and the local weak point

Vault is real ops burden: unseal ceremony, raft storage, audit devices, policies, lease lifecycle. It's worth it when many services need brokered identity; a single app needing three secrets may be better served by cloud-native stores. Also — since August 2023 Vault ≥1.15 ships under the BSL; OpenBao is the community fork if license matters.

And the weakest point is embarrassingly plain: the CLI caches your token at ~/.vault-token, mode 0600 but unencrypted. A stolen laptop is a stolen token until the TTL dies. Keep TTLs short, and never run vault login as root on shared boxes.

Concrete practice

  • Enable an audit device before anything else: vault audit enable file file_path=/var/log/vault/audit.log — every request logged with sensitive fields HMAC'd, and Vault halts rather than serve unaudited requests if logging fails.
  • Dynamic engines (database, aws, pki) over kv wherever an integration exists.
  • Short token TTLs; policies scoped per path; root token revoked after setup (vault token revoke) and regenerated only for emergencies.
  • In an incident, vault lease revoke -prefix database/creds/ mass-expires live credentials — drill it before you need it.

Vault's value isn't that it stores secrets. It's that it can unissue them — a safe can only protect what it holds, but a lease lets you reach into the database and delete the account itself.

Was this lesson helpful?

Sign in to rate

Keep reading

Related articles from the SudoSecurity blog.