Overview
Curated: · Written: · Reviewed:
Secrets Management in the Cloud
In one line
Cloud secret stores hold the credentials a workload still needs. The strongest design removes the credential first, using workload identity or short-lived tokens, and only then stores, delivers and rotates what remains. Reach for it whenever a static password, key or token would otherwise sit in code, images, CI settings or environment variables.
Key definitions
- Workload identity: the platform vouches for a workload (a federated Kubernetes service account, instance or task role, or the GKE and Azure equivalents), so no stored credential is needed.
- Static vs dynamic secret: a long-lived value changed only by rotation, vs a short-lived credential minted per consumer with a TTL.
- Envelope encryption: a data key encrypts the secret, and a KMS key encrypts the data key. Each decrypt is a KMS call.
- Dual credentials: two valid credentials at once, so consumers can move from old to new without an outage.
- Authority of revocation: the system that honors the credential (database, SaaS API). Deleting the vault entry does not revoke the password.
- Blast radius: what a leaked value can do, for how long, and what revoking it breaks.
Formulas and complexity
With process ages uniform from 0 to P, and the old credential disabled G days after each rotation, the share of running processes holding a dead credential at the instant the grace window closes is:
Hypothetical example: P = 6 days, G = 2 days, so f = 4/6, about 67% of the fleet. Processes that started before the rotation hold the old credential.
How it works
- The workload proves its identity to the cloud or store through its platform identity, and receives a bounded token.
- The store checks that identity against a policy scoped to that workload's own secrets.
- The consumer reads the value at start or per use, and re-reads on a schedule that matches the rotation interval.
- Rotation sets the new credential at the target, verifies a real login with it, then revokes the old one at the authority.
When to use and when not to
| Option | Use when | Trade-off to state |
|---|---|---|
| Platform identity, no secret (IAM database auth, OIDC federation) | Workload runs on the cloud identity plane | Identity-plane outage blocks new authentication |
| Dynamic broker credentials (Vault leases) | Many consumers, need per-consumer revocation | You run, unseal and DR-test the broker |
| Managed store read at start | Few secrets, rare rotation | A cached value keeps working until the process restarts or re-reads |
| Environment variable | Almost never for production secrets | Readable via /proc/pid/environ, inherited by children, captured in dumps |
| Private endpoint alone | Reducing network exposure | Any identity inside the network still reaches the secret |
Traps interviewers probe
- Injected at start, rotated later. Values from env vars do not change in a running process. Fix: mount the secret as a file or re-fetch per connection, and roll pods when a value must change.
- Revoking in the vault. Writing a new vault version leaves the old password valid at the database. Fix: change the credential at the target, verify a new login, then revoke at the database.
- Trusting network position. A private endpoint serves every identity inside the VPC, so an over-broad instance role is the real exposure. Fix: scope each identity to its own secrets.
- Group grants. A group granted project-wide read reaches every secret, whatever per-service grants exist. Fix: grant per secret and audit group membership.
- Secrets in images and arguments. Values baked into image layers survive a config override, and command-line arguments appear in process listings. Fix: inspect built images, and keep values out of argv.
Interview tips
Opening: "I'd try to remove the secret first: workload identity for the service, so nothing is stored. Whatever remains goes into one store with per-service read policy, is delivered as a file or fetched at use, and is rotated with overlap."
Follow-ups to expect:
- How does the workload authenticate without a bootstrap secret? Workload identity, and name the bootstrap problem honestly if it remains.
- What happens when the store is down? Decide per credential: serve stale with an alert, or fail.
- How do untrusted pull requests stay away from production credentials? Federation conditions on repository, branch and environment (the OIDC subject claim differs for pull_request runs), plus approval gates.
- What does audit cover? Data-plane reads and decrypts, not only policy changes.
First hour of a public leak: revoke at the authority, not the vault. Find every copy and access path, mint replacement material, confirm the old value is rejected, and audit reads during the exposure window.
30-second outline: Eliminate the credential with workload identity. Keep what remains in one store with per-service policy, delivered as a file. Rotate by setting the new value at the target, verifying a login, letting consumers adopt, then revoking the old value at the authority. Alert on bulk reads and deletions. Name the cost: short-lived identity depends on the identity plane being available.
Feedback on this overview
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.