Every application needs secrets: database passwords, API keys, signing keys and tokens for third-party services. When they live in source code or a shared spreadsheet, they spread to every laptop, backup and fork of the repository, and they rarely change. Leaked credentials are one of the most common ways attackers get in.
Find what you already have
Run a secret scanner across your repositories, including their full history, because a key deleted from the latest commit is still in the history. Add the same scanner to your CI pipeline and as a pre-commit hook, so new secrets are blocked before they are pushed.
Move secrets to a manager
- Store secrets in a managed service such as AWS Secrets Manager, Azure Key Vault, Google Secret Manager or HashiCorp Vault
- Give each application its own identity and only the secrets it needs
- Load secrets at runtime, and keep them out of container images and build logs
- Use separate secrets for development, staging and production
Rotate, and make rotation boring
Treat any secret that has been in source code as exposed, and rotate it. Then automate rotation where the service supports it, and test that applications pick up new values without an outage. If rotating a key is a nervous, manual event, it will not happen often enough.
Our engineers and consultants write about what they see in real projects. Have a question about your own systems?






