Files such as config.yaml, application.yml, .env and settings.json can contain database passwords, API keys and OAuth secrets. Committing the real configuration alongside a sample can expose these values to anyone with repository access.
If a secret was exposed
- Revoke or disable the exposed credential immediately and issue a replacement.
- Remove live values from configuration and stop tracking production files in Git. Adding a file to
.gitignoreleaves past commits intact, so assess whether history needs cleaning. - Choose a guide below to deliver the replacement in your environment.
Choose a detailed guide
- If environment variables can replace the values: Secrets overview
- If the application must keep a file format such as
config.yaml: Runtime configuration file guide - If configuration files must be mounted in Kubernetes: Kubernetes guide
- For Spring Boot using
application.ymlorapplication-prod.yml: Spring application.yml example - For Go services maintaining both
config.yamlandconfig.yaml.example: Go config.yaml example
Developer responsibilities
- Keep only keys and structure in samples such as
config.yaml.example. Have the application read live values from environment variables or a runtime configuration file. - Keep full configuration objects out of logs. Check debug output and error responses as well.
Infrastructure and platform responsibilities
- Supply values using Kubernetes Secrets, a secret manager or protected file delivery. A ConfigMap or Docker image can expose a production configuration file.
- Check that the deployment pipeline keeps production files out of Git. Document how to redeploy or reload configuration after rotation.
Verification
- Check Git history for production files such as
.envand inspect sample files for real values. - After deployment, verify that the application reads the replacement and that logs and error responses do not disclose it.
Example instructions for the owner
Please rotate the exposed credential and keep only the structure in
config.yaml.example. If the application requires a realconfig.yaml, mount it at deployment.