AAK-SECRET-010: Credential inside a Claude Code permission rule
- Severity
- HIGH
- Category
- Secret Exposure (
secret-exposure) - Scanner
agent_audit_kit/scanners/secret_exposure.py- Auto-fixable
- No.
- SARIF name
CredentialInAgentPermissionRule
What it detects
A rule in permissions.allow, .ask or .deny of a Claude Code settings file (.claude/settings.json or .claude/settings.local.json) holds a literal credential: a password, secret or token assignment before the command (PGPASSWORD=, MYSQL_PWD=), a password attached to a MySQL or MariaDB client's -p, a --password value, sshpass -p, curl -u user:password, the password in a database, broker or HTTP URL, or an Authorization header value. When a user answers "Yes, and don't ask again", Claude Code saves the exact command, secret included, as an allow rule in .claude/settings.local.json. Apiiro, reported by The Hacker News on 7 Nov 2026, found 1,122 of 104,185 public copies of that file holding at least one secret, 215 of which neither gitleaks nor TruffleHog flagged. A typed password is short and plain, so no length or entropy gate applies: the place is the evidence. A value that reads as a stand-in (a placeholder word, or one character repeated, such as x or 0000) is skipped; the limitations list each. The finding shows at most the value's first two characters.
How to fix
Rotate the credential: it sits in the file in clear text, and in every copy of the repository that ever committed it. Then remove the rule, or rewrite it to read the secret from the environment (Bash(PGPASSWORD=$PGPASSWORD psql:*)) or a client config file such as ~/.pgpass, and keep .claude/settings.local.json out of git (AAK-SECRET-011).
To confirm the finding is gone, report only this rule:
agent-audit-kit scan . --rules AAK-SECRET-010
Limitations
Reads only .claude/settings.json and .claude/settings.local.json, at any depth outside AAK's skip directories; another agent's permission or allow-list file is not read, and neither is a command in a hook, a shell history or a script. In a rule it reads Bash(<command>)'s command, or the rule as written, cut into shell words without expanding anything, and reports these shapes only: an assignment whose name holds PASSWORD, PASSWD, PWD, SECRET or TOKEN (not PWD, OLDPWD or a name ending in _FILE, _PATH, _DIR or _URL); -p<value> after mysql, mariadb, mysqldump or mysqladmin; --password=<value> on any command, and --password <value> except after those four, which read no value after a space; sshpass's own -p; curl -u or --user with a colon; the password in a postgres, postgresql, mysql, redis, rediss, mongodb, mongodb+srv, amqp, amqps, http or https URL; and an Authorization: Bearer, Basic or token value. A password in any other option (psql has none, docker login -p, redis-cli -a) or a key in a positional argument is not read. A value that starts with $, is or ends in * is read as a shell reference or a wildcard and not reported, so a literal password that starts with $ is missed. A value that reads as a placeholder is not reported either: one holding REPLACE, YOUR, EXAMPLE, PLACEHOLDER or CHANGEME, or a run of four x, in any case (<your-password>, changeme, xxxx1234), one of the two example keys in AWS's documentation, or one character repeated, - and _ aside (x, 0000, a-a-a), so PGPASSWORD=x and MYSQL_PWD=1111 are missed while PGPASSWORD=1234 and PGPASSWORD=ab are reported. A value a prefix rule (AAK-SECRET-001, -002, -003, -008) reports, or AAK-SECRET-004 reports on the same line, is left to that rule. A settings file that does not parse as JSON or JSONC is not read, and a file over 1,000,000 bytes is not read.
References
- OWASP MCP Top 10: MCP01:2025 (Token Mismanagement & Secret Exposure)
- OWASP Agentic Top 10: ASI03 (Identity and Privilege Abuse)
- Adversa AI MCP Top 25 (AAK-defined ids): ADV-TOKEN-06 (Generic Secret Exposure)
- Incidents and advisories: APIIRO-CLAUDE-CODE-SETTINGS-2026-11-07
- CSA AI Controls Matrix (AICM): DSP-17
All rules. This page is generated from the rule registry when the documentation is built; to change it, change the rule in agent_audit_kit/rules/builtin.py. To give the rule a hand-written write-up, add docs/rules/AAK-SECRET-010.md: the page then shows that text, with the registry reference appended under it.