What an agent in bypassPermissions mode can read on your Mac, and a hook that stops it
With approvals off, a coding agent runs any shell command it decides it needs. On a Mac that includes this: security find-generic-password -s "Chrome Safe Storage" -w That one line prints the key that decrypts e
With approvals off, a coding agent runs any shell command it decides it needs. On a Mac that includes this:
security find-generic-password -s "Chrome Safe Storage" -w
That one line prints the key that decrypts every saved Chrome password and cookie. No prompt appears, because you turned prompts off. The same goes for security dump-keychain, for copying ~/Library/Application Support/Google/Chrome/Default/Login Data, and for Python's browser_cookie3.
This is not hypothetical. On one Mac running unattended agents, a company endpoint security tool raised 2,256 alerts in two months, every one from an AI agent. Agents read "Chrome Safe Storage" from the keychain, copied Chrome's Login Data and Cookies files into /tmp, and stripped quarantine flags from a screen recorder they reinstalled.
Agents rarely do this on purpose. They do it when they are stuck: a test needs a token, a login fails, and the shortest path to "done" runs through your keychain. A prompt injection in a README or an issue can steer them there too.
Claude Code's auto mode now screens many risky calls, and Anthropic says plainly that it "does not eliminate risk". Plain bypassPermissions has no screen at all, and Cursor and Codex have their own modes. I wanted one rule set that works the same in all three, in every mode.
The hook
Claude Code, Codex and Cursor can all run a script before each tool call. Mine reads the command, decides, and denies it before it runs. Each rule maps to a MITRE ATT&CK technique, so a security team can read the log without learning a new vocabulary:
| Rule | Blocks | ATT&CK |
|---|---|---|
| keychain |
security find-generic-password, dump-keychain, export, Python keyring
|
T1555.001 |
| browser-store | Chrome, Brave, Edge, Arc, Safari and Firefox cookie and login files | T1555.003 |
| cookie-library |
browser_cookie3, pycookiecheat, rookiepy
|
T1539 |
| quarantine | xattr -d com.apple.quarantine |
T1553.001 |
| pipe-to-shell | `curl ... \ | bash` and its disguises |
| launch-agent | writing a LaunchAgent (asks you first) | T1543.001 |
Each rule can be set to block, warn, log or ask. In ask mode the call is denied until you approve that exact call, matched by a SHA-256 digest of its arguments. The agent cannot approve itself.
The audit log
Every hit becomes one JSON line with the rule, the technique, the agent and whether the call ran. It holds no command text, so it is safe to ship to a SIEM.
What it cannot do
The hook sees the command an agent asks to run, not what a program does after it starts. A compiled binary that reads the keychain on its own gets past it. Use it with a sandbox such as Docker Sandboxes or Agent Safehouse, not instead of one.
False positives
A grep or a commit message that mentions security find-generic-password is allowed: the rules look at the program each part of a command runs, not at the words.
Try it
It is MIT licensed, with no dependencies beyond Node.js:
git clone https://github.com/IgorGanapolsky/agent-credential-guard
cd agent-credential-guard
bin/mac-yolo-credential-guard install --agent all
bin/mac-yolo-credential-guard doctor
doctor shows what may already be on your Mac. Source: https://github.com/IgorGanapolsky/agent-credential-guard
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.