Originally published on the Postman blog.
Did you commit your agent's allow rules? One git log tells you. If you use Claude Code, Cursor or Gemini against real APIs and databases, your agent has probably been writing down the exact commands you approved, credentials included. This post covers how that happens, the commands to check and clean up your repo, and how to give your agent a secret reference instead of a key worth stealing.
We've all done it. Your coding agent asks, for the fourteenth time today, whether it can run a command you've already approved thirteen times. You click the button that makes the question go away.
That button has a very good memory. Security firm Apiiro searched public GitHub repositories for one of the files where an agent keeps the commands you've approved: Claude Code's .claude/settings.local.json. Out of 104,185 public copies, 1,122 held a real secret. Once you add git history, shared settings files and saved agent chat transcripts, the count reached 2,539 secrets across 1,994 repositories.
How a password ends up in a settings file
Nobody sets out to commit their database password. What happens is much more ordinary. You ask the agent to check something in the database or call an API. It reads the credential it needs from your project's config and proposes a perfectly reasonable command with that credential filled in. You approve it for good, and the agent dutifully saves the exact command as an allow rule (illustrative values):
{
"permissions": {
"allow": [
"Bash(PGPASSWORD=EXAMPLE-ONLY psql -h db.example.com -U app)",
"Bash(curl -H \"Authorization: Bearer sk-live-EXAMPLE-ONLY\" https://api.example.com/v1/orders)"
]
}
}
The file is meant to stay on your laptop, but nothing in the repository says so, and a broad git add doesn't ask. Secret scanners also struggle here. A password sitting after PGPASSWORD= looks like any other word to a tool that searches for known key formats. When the researchers ran two popular open-source scanners over the leaked files, 215 of them got past both.
This study happened to look at one agent's settings file, but the pattern isn't about one tool. Every agent harness writes things down: approved commands, chat transcripts, memory files, generated scripts. That's why Apiiro's advice covers .claude/, .cursor/, .gemini/ and .specstory/ directories alike, and suggests treating all of them the way you'd treat a .env file.
An agent is very good at taking what you give it and putting it to work. If you give it a working key, that key ends up in whatever it builds, and you can't count on every one of those places staying private.
Give the agent something not worth stealing
The standard advice is sound: rotate first, ignore the local file, keep secrets out of commands, approve patterns instead of exact strings, and scan agent folders. Taken together, though, it asks developers to handle credentials perfectly, many times a day. A sturdier fix is to change what the agent holds in the first place. That's the idea behind Passport from Postman.
With Passport, your project's config holds a secret reference, something like {{vault:<secret-reference-id>}}, instead of the real key. The real secret stays in the store you already run.
So when the agent builds a command from that config, the command carries the reference, and so does the allow rule it saves (illustrative values, using passport request):
{
"permissions": {
"allow": [
"Bash(passport request \"https://api.example.com/v1/orders\" -H \"Authorization: Bearer {{vault:<secret-reference-id>}}\")"
]
}
}
If that file ends up on GitHub, whoever finds it gets a reference that's bound to your identity and doesn't work from their machine. You'd still tidy it up, but it's no longer an incident.
Passport has limits. It brokers HTTP API calls, so database passwords and SSH logins need their own fixes, such as short-lived database credentials and SSH certificates. And a key that has already leaked needs rotating no matter what you move to next.
If your agent has been keeping notes
Rotate any exposed key first, then clean up the repo, because git history and forks keep copies. These commands check whether agent files were ever committed in a repo and stop tracking the local settings file:
git log --all --oneline -- .claude/ .cursor/ .gemini/
git rm --cached .claude/settings.local.json
echo ".claude/settings.local.json" >> .gitignore
While you're in there, delete any allow rules that contain a real secret. Prefer patterns like Bash(npm run:*) over single commands.
To see what your agent is sending before you change anything, try Lens, which comes with the free Passport CLI Community Edition. Run it around your agent for a day and see which keys show up.
None of this is a reason to stop using coding agents. It's a reason to assume that anything an agent can see can eventually leak, whoever built the agent, and to plan around that. Then you can keep clicking "don't ask again" with a clear conscience, because the thing it remembers won't be a password.
Read the full post on the Postman blog for the cleanup commands and to see how Passport secret references keep real keys out of your agent's files.
Top comments (0)