Secrets in plaintext in config files
Quick summary
Your config file contains secrets in plaintext — anyone with access to the file can read the credentials.
Why this happens
Secrets are hardcoded in docker-compose, Kubernetes manifests, or application config files
Secrets are committed to version control in plaintext config files
Environment variable files with secrets are not in .gitignore and are committed
Minimal example
# docker-compose.yml
services:
db:
image: postgres:15
environment:
POSTGRES_PASSWORD: mysecretpassword # plaintext secret in config!# docker-compose.yml
services:
db:
image: postgres:15
environment:
POSTGRES_PASSWORD_FILE: /run/secrets/db_password # reference to Docker Secret
secrets:
- db_password
secrets:
db_password:
file: ./secrets/db_password.txtUsing Docker Secrets to mount the password as a file keeps the secret out of the config file and environment variables.
How to diagnose
Scan config files and the repository for plaintext passwords, API keys, and tokens
Check if .env files and secret configs are in .gitignore
Review the repository history for committed secrets using a secret scanning tool
How to fix
Move secrets to a secrets manager or encrypted secret store
Use Kubernetes Secrets or Docker Secrets instead of plaintext environment variables
Remove secrets from the repository history and rotate any exposed credentials
How to prevent
Never commit secrets to version control — use .gitignore and a secrets manager
Use secret scanning tools in CI to detect and prevent committed secrets
Related Resources
Related Glossary
Related Lessons
- Security
Learn about secrets.