Practical technical guides / Recent development: Apiiro report on Claude Code allow rules (2026-11-05; HN 2026-11-07)

A Remembered Agent Approval Can Store the Password: Audit Claude Code Allow Rules Before They Reach Git

Apiiro reported 1,122 public Claude Code settings files with secrets (5 November 2026). Why approvals store passwords, why token scanners miss them, and a tested audit.

By Sandeep Belgavi · Published 2026-11-08

Apiiro reported 1,122 public Claude Code settings files with secrets (5 November 2026). Why approvals store passwords, why token scanners miss them, and a tested audit.

What happened this week

On 5 November 2026 the security company Apiiro published a count of public GitHub files created by Claude Code's "Yes, and don't ask again" option. The report reached Hacker News on 7 November, where a member of the Claude Code team replied within half an hour. I could not load Apiiro's page in a readable form, so the figures below are Apiiro's as summarised by iTWire on 7 November, and they are Apiiro's findings, not independent measurements: 104,185 public copies of .claude/settings.local.json, of which 1,122 (about 1.1 percent) held what Apiiro classed as secrets, 1,379 distinct values. Including Git history, shared settings and agent transcripts, Apiiro counted 2,539 distinct secrets in 1,994 repositories. It did not try any of the credentials, used an LLM reviewer in its classification, and sells security products.

The mechanism is not new or disputed. An issue filed in the Claude Code repository in August 2025, number 5544, reported that approved Bash commands containing credentials were stored as plain text in that file; it was closed automatically in January 2026 as not planned. This guide explains why a remembered approval can store a password, why the usual scanners miss it, and how to audit and clean up, with a tested audit script.

Why an approval becomes a copy of the secret

Claude Code's settings documentation says that when you choose "Yes, and don't ask again" for a Bash command, it saves that approval as an allow rule in .claude/settings.local.json at the repository root. The rule records the command. If the command was

PGPASSWORD=Tq7-not-a-real-pass psql -h db.example.internal -U shop_app -c 'select count(*) from orders'

then the rule is that whole string, password included. Nothing malicious has happened: the developer approved a command they were about to run, and the tool remembered it so it would not ask again.

The file is meant to stay on the developer's machine. The same documentation says that the first time Claude Code writes it in a Git repository that does not already ignore it, it adds **/.claude/settings.local.json to the developer's global Git excludes file. On Hacker News, Boris Cherny of the Claude Code team wrote that the file "is meant to stay local", that "We automatically gitignore it when Claude creates the file, so in this case the files were manually created and checked in", and that the team was "looking into what we can do to prevent this". iTWire's summary adds Apiiro's counterpoint: in 539 of 1,105 repositories it traced, a commit co-authored by Claude changed the file. Neither side's claim settles every case, and the cleanup is the same either way.

How the file still ends up in Git

A global excludes entry lives on one machine. It is not part of the repository, so it does not protect:

  • a clone on a second machine, or a colleague's machine, where Claude Code has not yet written the file;
  • a CI job or container that runs Claude Code with a fresh home directory;
  • a file created by hand, or copied from another project;
  • a file that was already tracked. Git's documentation is explicit that ignore rules do not affect files Git already tracks.

The companion example ran into this from the other side: its test needs to commit the file into a throwaway repository, and git add -A silently skipped it because this machine's global excludes already listed it. Forcing the add with -f is exactly what a developer does when they decide the file "should" be shared.

Why format-based scanners miss these

Token scanners such as gitleaks and TruffleHog look for credentials by shape: a known prefix and length, high entropy, or a provider-specific format, often confirmed by calling the provider. A database password typed after PGPASSWORD= or sshpass -p has no shape. It is recognisable only from the command around it, which is why a file can pass a token scan and still hold a working database password.

The companion audit looks at context instead. It reads the allow, ask and deny lists, takes the command inside each Bash(...) or PowerShell(...) rule, and checks for secret-named environment assignments, sshpass -p, mysql -p, --password=, curl -u user:pass, user information in URLs, and Authorization headers. It ignores references such as $PGPASSWORD, and it never prints a value, only a short fingerprint so a person can tell which credential to rotate.

DETECTORS = [
    ('env assignment', re.compile(r'\b(' + SECRET_NAME + r''')=(['"]?)''' + NOT_A_REF + r'''([^\s'"]{3,})\2''')),
    ('sshpass -p', re.compile(r'''\bsshpass\s+-p\s*(['"]?)''' + NOT_A_REF + r'''([^\s'"]{3,})\1''')),
    ('URL userinfo', re.compile(r'\b[a-z][a-z0-9+.-]*://[^\s/:@]+:' + NOT_A_REF + r'([^\s/@]{3,})@')),
]

On the fixture, a settings file with six synthetic credentials in six forms, the context detectors find all six and a format-only baseline finds none. That is a property of the fixture, chosen to show the gap, not a measurement of any product. Run both kinds of scanner; they catch different things.

Cleaning up, in order

  1. Rotate first. A credential that reached a public repository, or any repository more people can read than should, must be treated as exposed. Deleting the file does not remove it from history, forks or clones. Revoke and replace it before anything else.
  2. Search history, not only the current tree. The audit's scan_git_history reads every committed version of .claude/settings*.json. In the example, a file committed and then deleted still yields all six findings from history, and none from the current tree.
  3. Ignore the file in the repository itself. Add .claude/settings.local.json to the project's own .gitignore, so the protection applies in every clone, and run git rm --cached if it is tracked.
  4. Approve patterns, not literal commands. A rule such as Bash(psql -h db.example.internal *) with the password supplied by ~/.pgpass, a PGPASSFILE, or an environment variable the shell provides never contains the value. If a prompt offers to remember a command that contains a secret, approve it once instead.
  5. Check transcripts. Apiiro's wider count included agent transcripts; anything that records what an agent ran can record its arguments.

Make it a pre-commit and CI check

The same detectors run in a pre-commit hook on staged settings files and in CI on every pull request. Fail the check on any finding in an allow rule; a deny rule containing a secret is rarer but should be reviewed too. Keep the history scan as a periodic job, because a hook does not see what was committed before it existed.

What this does not tell us

The 1,122 figure is Apiiro's classification of public files, untested against live systems. Private repositories, other agent products and other storage locations are outside the count. Whether Claude Code will add secret scrubbing to remembered approvals was, as of 8 November, something the team said it was prototyping, not a shipped change. The audit script has false negatives (a password passed through an unusual flag) and false positives; treat a finding as a reason to rotate and a clean result as one signal among several.

Verifying the audit

The companion tests check that each detector finds its form, that references such as $PGPASSWORD, ${PGPASSWORD} and %API_TOKEN% are not flagged, that values are fingerprinted and never printed, that a format-only scanner misses every fixture secret, that only Bash and PowerShell rules are read, and that history keeps what the current tree dropped. Point the script at your own repositories' history before you decide the problem does not apply to you.

Primary references and authorship

Sources dated on or before 8 November 2026. Original explanation and synthetic examples by Sandeep Belgavi. Companion code: Sandeep-BA/agent-decision-lab/examples/python/approval_rule_secret_audit. Views are my own and do not represent any employer, past or present.