Agents read files and print output into transcripts, so a secret in a repository, shell history, or .env file can land in a model context or a log. Keep secrets in a manager, inject them at runtime by reference, and scan for leaks before and after commit. Agent transcripts and MCP config files are new places that need scanning.
Read in this order
- OfficialOWASP Secrets Management Cheat SheetStart here: the baseline practices for storing, rotating, and auditing secrets.
- OfficialGitHub: Push protectionHow push protection blocks a leaked token before it reaches the repository.
- Open sourceGitleaksA scanner you can run locally and in CI against repos and agent output.