The pull request looked clean. The tests were green, the diff was small, and the commit message was tidy. Three lines deep in a config helper there was a real AWS access key that the coding agent had pasted in to make an example run. Nobody read those three lines, because nobody reads every line an agent writes anymore.

When a person writes a secret into a file, it usually passes under someone's eyes before it reaches a commit. When an agent writes one, it often does not. The reviewer is either the same agent that wrote the code or a human skimming a 600 line diff. A regex scanner can match the shape of a key, but it cannot tell you whether that key is live, and it cannot fix it for you. So the leak ships, someone force pushes over it, it sits in the history, and you find out when the provider sends you an email.

leakferret is a secret scanner written for that situation. It is a single Rust binary that runs as a CLI in CI and as an MCP server that an agent can call on its own work before it commits. It checks findings against the real provider, it keeps the raw secret on your machine, and it can apply the fix by replacing the hardcoded value with an environment variable lookup. This post explains how each of those parts works and how to wire it into both a CI pipeline and an agent loop. It is open source under MIT and free to use.