Secrets Management

Secrets management is storing, controlling and rotating the passwords, API keys, tokens and certificates that applications and systems use, in a secure vault rather than in code, config files or chat messages.

IntermediateCategory: Cloud and software supply chain

Also called: secrets vault, credential management, hardcoded secrets, secret scanning

What is secrets management?

Applications need credentials too. A website needs a database password, a script needs an API key for the payment processor, and a deployment pipeline needs cloud access keys. These are called secrets. Secrets management is the practice of keeping them safe: storing them in one protected place, limiting who and what can read them, rotating them and logging their use.

Why it matters

Secrets are often far less protected than people's passwords:

  • Hardcoded in source code and then pushed to a public GitHub repository, where automated bots find them within minutes
  • Left in config files, scripts, container images and backups
  • Shared in chat or email and never changed
  • Long-lived, with broad permissions and no MFA

A leaked cloud access key can let an attacker spin up expensive cryptomining servers, steal data or delete everything. Many cloud breaches have started with a key found in a code repository. NIST's guide to CI/CD supply chain security, SP 800-204D, treats protecting pipeline secrets as a core requirement.

Best practices

OWASP's secrets management guidance recommends:

  1. Centralize secrets in a vault, such as AWS Secrets Manager, Azure Key Vault, Google Secret Manager, HashiCorp Vault or a business password manager's secrets feature.
  2. Never hardcode secrets in code, images or config files. Applications fetch them at runtime.
  3. Apply [least privilege](/glossary/least-privilege/) so each app reads only the secrets it needs.
  4. Rotate secrets regularly and immediately after a suspected leak, or use short-lived credentials that expire automatically.
  5. Audit access to secrets.
  6. Scan for leaked secrets in code repositories and pipelines. GitHub, GitLab and others offer secret scanning, and pre-commit hooks can block mistakes before they're pushed.

If a secret leaks

Deleting it from the code isn't enough; it lives on in history and may already have been copied. Revoke and replace it first, then check logs for misuse.

For people's passwords, the equivalent tool is a password manager.

Related terms

Sources

  1. SP 800-204D: Strategies for the Integration of Software Supply Chain Security in DevSecOps CI/CD Pipelines (NIST)
  2. Secrets Management Cheat Sheet (OWASP)

Drafted with AI assistance, then edited and fact-checked by a person. How we use AI.