Skip to content

Secrets management

A secret is anything that grants access: database passwords, API keys, OAuth client secrets, private keys and certificates, signing keys, tokens. Secrets management is how those are created, stored, delivered to the software that needs them, rotated and revoked, with a record of who used what.

Leaked credentials are one of the most common ways attackers get in, and the leaks are usually mundane: a key committed to a repository, a password in a config file, a token pasted in a ticket. Good secrets management makes the safe path the easy one.

Secrets delivered at runtime, never stored with the code1. Code and configuration hold only references to secrets, never the values. 2. At runtime the workload authenticates to the secrets store with its platform identity. 3. The store returns the secret, or creates short-lived database credentials just for this workload. 4. Every access is recorded, so leaks can be traced and access reviewed. Code and configreferences only Deploymentworkload identity Workloadproves its identity Secrets storeencrypted, audited Databaseshort-lived credentials Audit logevery access recorded1234
Secrets delivered at runtime, never stored with the code Workloads prove their identity to the secrets store and receive short-lived credentials; nothing secret lives in the repository or image.
  1. Code and configuration hold only references to secrets, never the values.
  2. At runtime the workload authenticates to the secrets store with its platform identity.
  3. The store returns the secret, or creates short-lived database credentials just for this workload.
  4. Every access is recorded, so leaks can be traced and access reviewed.
  • No secrets in code, images, config files or environment files committed to version control. Store references; resolve them at runtime.
  • Authenticate workloads by identity, not by another secret. Cloud workload identities (for example IAM roles, managed identities or Kubernetes service account federation) let a workload prove who it is without a bootstrap password. This removes the “secret to get the secrets” problem.
  • Prefer short-lived, automatically issued credentials over long-lived static ones. A database credential that expires in an hour is far less valuable to an attacker.
  • Least privilege: each workload can read only its own secrets.
  • Rotate, automatically where possible, and make sure rotation doesn’t need a deployment.
  • Audit every access, and alert on unusual access.
  • Plan revocation: know how to revoke and replace any secret within minutes, and practice it.
  • Cloud secret managers: AWS Secrets Manager, Azure Key Vault, Google Cloud Secret Manager.
  • Dedicated platforms: HashiCorp Vault (opens in a new tab) and OpenBao (opens in a new tab) can also issue dynamic credentials for databases and clouds, and act as a certificate authority.
  • Key management services (KMS) and hardware security modules (HSM) for encryption keys, where the key never leaves the service.
  • Kubernetes: native Secrets are only base64-encoded by default; enable encryption at rest and prefer syncing from an external store (for example with the External Secrets Operator or a secrets store CSI driver).
  • Secret scanning in repositories and CI, blocking commits that contain credentials. Many code hosts provide this; open-source scanners exist too.
  • Scrub logs and error messages, which often print connection strings.
  • Keep secrets out of tickets, chat and AI prompts. Provide a safe sharing tool for the rare cases humans need to exchange one.
  • Treat any exposed secret as compromised: revoke and replace it, even if the repository was private or the commit was deleted. Version history and forks keep it.
  • Leaks become rarer, and less damaging when they happen.
  • Rotation and revocation become routine instead of an emergency project.
  • A full record of which workload accessed which secret.
  • The secrets store becomes critical infrastructure: if it’s down, workloads can’t start. Plan caching and availability.
  • Migrating existing applications off static secrets takes effort.
  • A vault with one shared admin token used by every pipeline.
  • Static secrets copied into the vault and never rotated, which adds a tool without reducing risk.
  • Secrets passed as build arguments that end up in container image layers.
  • Long-lived personal access tokens used by automation after their owner has left.

Written and edited by Abhinav Taduka, enterprise software architect.