Secrets Management: Beyond Environment Variables
Treat secrets like cattle, not pets: they should be temporary and replaceable. Use a central vault to dynamically inject credentials into apps at runtime, especially in CI/CD and containerized environments.
WHY IT EXISTS: Applications need to authenticate with databases, APIs, and other services. Hardcoding these credentials (secrets) in source code or configuration files is a massive security risk. A single leak exposes the entire system. Secrets management exists to solve this by externalizing and securing access to credentials.
THE MENTAL MODEL: Think of a secrets manager as a digital locksmith for your applications. Instead of giving every app a permanent key (a static secret), the app authenticates itself to the locksmith (the secrets manager) and receives a temporary, special-purpose key just for the task it needs to perform. When the task is done, the key expires. This approach minimizes the window of opportunity for an attacker if a key is compromised.
HOW IT WORKS: A central secrets management system (like AWS Secrets Manager or HashiCorp Vault) acts as a secure vault. Applications authenticate to the vault using a trusted identity, such as an IAM role or a Kubernetes service account. Upon successful authentication, the vault generates or retrieves a short-lived, scoped-down secret and injects it into the application's environment, often as a file in a temporary volume or directly into memory. The system also handles the entire secret lifecycle: creation, rotation, and revocation, often automatically.
WHEN TO USE IT: Use a secrets management system whenever an application, service, or pipeline needs credentials. This is especially critical in modern infrastructure: CI/CD pipelines deploying to production, microservices authenticating with each other, and serverless functions accessing a database. The goal is to eliminate static, long-lived secrets from your entire development and deployment lifecycle.
WHEN NOT TO USE IT: For a simple, local-only development script that uses a non-production test database on your own machine, a full secrets management system might be overkill. The primary footgun here is misjudging the boundary: a 'temporary' script often becomes a permanent part of a workflow, and its hardcoded secrets become a liability. Non-sensitive configuration, like a public API endpoint URL, does not need to be treated as a secret.
ONE CANONICAL EXAMPLE: A common pattern in Kubernetes is the 'sidecar injector.' Your application pod runs alongside a small, dedicated sidecar container. This sidecar authenticates with the secrets manager (e.g., AWS Secrets Manager), fetches the required database password, and writes it to a shared in-memory volume that only the main application container can read. The application reads the password from this file. The secret never touches the container image or the developer's machine, and the sidecar can automatically rotate it periodically.
Read the original → cheatsheetseries.owasp.org
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.