Secrets in Environment Files and Configuration
Overview
Secrets in .env, config.yaml, docker-compose.yml, and similar files are frequently committed to Git repositories (including public ones), exposing credentials, API keys, and tokens. This is one of the most common causes of cloud breaches.
Detection Strategy
.envfiles with actual values (not placeholders)docker-compose.ymlwith hardcoded credentials- CI/CD configuration files with secrets
Remediation
- Use
.gitignoreto exclude.envfiles from version control - Use secret management services (AWS Secrets Manager, HashiCorp Vault, GCP Secret Manager)
- Use
${VARIABLE}placeholders in config files, with actual values injected at runtime - Rotate any secrets that have been committed — assume they are compromised