RSS
News

"Don't ask again" can leak secrets into settings.local.json

Approving a command with "Yes, and don't ask again" saves the exact command, secrets included, to .claude/settings.local.json. Apiiro found 1,122 public copies holding a secret. How to check and fix yours.

brown padlock on brown wooden fence
Photo by Georg Bommeli on Unsplash

Updated November 20, 2026: Expanded with Apiiro's full findings, check commands, fixes and Anthropic's response.

Worth checking today. When you approve a shell command in Claude Code with "Yes, and don't ask again", Claude Code saves an allow rule to .claude/settings.local.json, and that rule is the command string itself. If the command contained a password or token, the secret now lives in the file too. Security firm Apiiro counted how often that file reaches public GitHub with a secret inside.

How a secret gets into the file

The flow is ordinary. You ask Claude Code to debug a staging login or run a migration, and the command it proposes carries a connection string, a PGPASSWORD= value or a bearer token. You pick the standing approval to stop the interruptions, and the exact command is written into the allow list. Apiiro says this is Claude Code's behaviour, not the model's, and reproduced it with Opus 5.5 and Fable 5.1.

Claude Code's settings docs describe the guard meant to keep the file private. The first time Claude Code writes it in a git repository that does not already ignore it, it adds **/.claude/settings.local.json to your global git excludes file. If you created the file by hand first, you have to add it to .gitignore yourself.

Apiiro points out where that guard falls short: it lives in one developer's global config, so it does not cover a clone on another machine, a folder that becomes a repository later, or a file that was already committed, since git ignore rules never apply to tracked files. Apiiro also found commits co-authored by Claude that changed the file in 539 of the 1,105 repositories it followed, though that does not show Claude introduced every credential.

What Apiiro found

Apiiro researchers Shmulik Cohen and Matan Giladi published the study on November 5, using read-only GitHub search between November 1 and 3. The figures are Apiiro's own:

  • 104,185 public copies of .claude/settings.local.json, of which 1,122 (about 1.1%) held at least one secret, with 1,379 distinct values.
  • Over a third of those opened a database directly: 379 database passwords and 122 Supabase service-role keys.
  • The rate rises sharply with file size: about one in ten files over 8 KB held a secret, against fewer than one in 500 under 500 bytes.
  • Earlier versions of the file in git history held 734 secrets that no current copy contains, usually because the file had been deleted but not purged.
  • The files tend to stay put: in the median affected repo the file was first committed 217 days before the scan, and 211 forks of 74 repos carry the same secrets.
  • Counting history, the shared .claude/settings.json and agent transcripts, the total was 2,539 distinct secrets across 1,994 repositories.

Two caveats matter. Apiiro did not use or test any credential, so these are exposures, not demonstrated breaches; "real secret" in its report means a value that matches a provider key format or sits next to a public host, after filtering and an LLM review against a rubric. And Apiiro sells security products. It says it notified affected organisations, 63 in all, and that one confirmed its exposed key had been live.

Ordinary secret scanners missed a share of these. Of the 1,122 files with a secret, gitleaks flagged 564, TruffleHog 643, and 215 were caught by neither. Apiiro describes the gap as passwords inside commands, such as values after PGPASSWORD=, sshpass -p or mysql -p.

Check your own repos

First, see whether the file is or ever was tracked. These are standard git commands, not from Apiiro's report: git ls-files lists the paths git currently tracks, and git log --all shows any commit on any branch that touched the file.

git ls-files .claude/
git log --all --oneline -- .claude/settings.local.json

Then open the file and read the allow list; every entry is a command you approved, with whatever you typed into it. A file that never leaves your laptop still matters: it is plain JSON at the same path in every project, and malware such as the Shai-Hulud npm worm has scanned developer machines for credentials. Also search your GitHub organisation for the shared .claude/settings.json; Apiiro found 298 copies holding a secret.

Fix it

  • Rotate first. Deleting the file does not remove it from history, forks or other people's clones, so treat any credential it ever held as exposed.
  • Stop tracking the file and add it to the repository's own .gitignore, so the protection travels with the project: git rm --cached .claude/settings.local.json
  • Delete any allow rule that contains a literal secret, even in files never committed.
  • Reference secrets as environment variables from your secrets manager, so the saved rule records $DB_URL rather than the value. An inline assignment still puts the password in the command text.
  • Approve patterns such as Bash(npm run:*) instead of literal one-off commands. In the VS Code extension, check which file the approval card writes to: it can target the shared project file.

What Anthropic has said

According to an update on Apiiro's post, Boris Cherny, head of Claude Code, said on Hacker News on November 7 that the team is looking at prevention, including having auto mode catch this and building in basic secret scanning. When a reader noted auto mode can hit the same problem, he called it a good catch. He also said that, in his view, the exposed copies were created by hand and checked in, and recommended the secret scanning GitHub and other hosts offer.

Our take

The approval prompt asks whether a command is safe to run; nobody asks whether it is safe to save. Until Claude Code scrubs secrets itself, the fixes are the boring ones: secrets in variables, pattern rules instead of literal commands, the local settings file in every repo's .gitignore, and secret scanning that treats .claude/ like .env.

Source: Coding agents copy your secrets to a hidden file (Apiiro), Settings files and precedence (Claude Code Docs), Claude Code approval files found exposing company secrets on GitHub (iTWire)

This story first appeared in the claudefox daily briefing for November 8, 2026.