Lakshya

Identity & Access · Chapter 6 of 16

Secrets management

The problem every engineering organisation has, and most solve badly.

4 min read0 diagramsAll 16 chapters

Applications need credentials: database passwords, API keys, signing keys, certificates. Where those live is one of the most consequential and least examined decisions in a codebase.

The maturity ladder

LevelWhere the secret livesThe problem
0Hard-coded in sourceIn every clone, every fork, and git history forever
1In a .env file on the serverUnrotatable in practice; nobody knows who has read it
2In CI/CD variablesBetter, but broad blast radius and often visible in logs
3In a secrets manager, fetched at bootGood. Still long-lived, still one leak from exposure
4Dynamic, short-lived, fetched per useThe target. A leaked credential expires before it is useful
5No secret at all — workload identityThe endpoint. The platform attests the workload; nothing to leak

Levels 4 and 5 are what modern secrets tooling is for. Cloud workload identity — IAM roles for service accounts, managed identities, OIDC federation from CI — removes the secret entirely: the platform proves what the workload is, and the workload receives a short-lived token. The best secret is the one that does not exist.

What to check

  • Has the repository ever contained a secret? History matters — rotating without purging history leaves it retrievable. Secret scanning on every push, and on history, is now table stakes.
  • Can you rotate without downtime? If not, rotation will not happen after an incident when it matters most. Practise it.
  • Who can read each secret, and is that logged? A vault with permissive read policies is a well-organised secret sprawl.
  • What is the lease duration? This single number tells you most of what you need to know about the maturity of the setup.

Why secrets management fails in practice

Nearly every organisation has a secrets manager. Most still have secrets in source control, in environment files on developer laptops, and in a shared password vault someone set up in 2019. Deploying the tool is the easy part and it is not the programme.

FailureWhy it happensThe fix that actually works
Secrets in git historyRotating is work; deleting the file feels like enoughAssume any committed secret is compromised and rotate it. Removing it from history does not un-disclose it. Then add pre-commit and server-side scanning so the next one never lands
The vault holds them, and they never changeNobody knows what breaks on rotationRotate on a schedule from day one, while the blast radius is small. A credential that has never been rotated cannot be rotated in an emergency
One credential shared by five servicesIt was convenient onceYou cannot rotate or revoke it without an outage, so you never do. One identity per workload, always
Long-lived cloud keys in CIIt is the default in every tutorialShort-lived federated credentials. This removes the class rather than protecting it, and is usually a day of work
The vault credential itself is a static secretSomething has to bootstrapThis is the actual hard problem — see below. It is solvable and it is where the thinking belongs

The bootstrapping problem, and the answer

To read a secret from the vault, a workload needs a credential. Where does that come from? If it is a static secret in a config file, you have moved the problem rather than solved it — and moved it somewhere with more access than before.

The answer is an identity the platform can attest to, rather than a secret the workload holds. A cloud instance role, a Kubernetes service account token bound to a specific workload, or a hardware-rooted attestation. The platform vouches for what is running, and the vault trusts the platform.

That is the whole idea behind workload identity, and it is why it matters more than the vault choice. It converts ‘prove you know a secret’ into ‘prove you are the thing you claim to be’, and the second is not stealable by copying a file.

The diagnostic question: “if I copied this container image and ran it on my own laptop, could it read production secrets?” If yes, the secret is in the image or its configuration and the vault is decoration.

And the honest limit: something at the bottom is always trusted — the cloud provider's metadata service, the cluster's signing key, the hardware root. You are not eliminating trust; you are reducing it to one well-defended thing that is hard to copy.

Check yourself

A secret was committed to git and then deleted. Is it safe?No. Assume it is compromised and rotate it. Removing it from history does not un-disclose it.
Why can't a never-rotated credential be rotated in an emergency?Because nobody knows what depends on it. Rotate on a schedule from day one while the blast radius is small.
What is the secrets bootstrapping problem?The workload needs a credential to read the vault. A static one just moves the problem. The answer is a platform-attested identity rather than a held secret.
What question tests whether a vault is real?'If I copied this container image and ran it on my laptop, could it read production secrets?' If yes, the secret is in the image.
← Privileged access — why admin is differentMachine and agent identity →