Skip to content
Ad slotPut your product on this line. It runs at the top of every page on IndieHacked.Advertise
News

Claude Code's "don't ask again" left real secrets in 1,122 public GitHub files

Approving a command for good saves it, key and all, to a settings file that ends up committed. Anthropic says it is looking at secret scanning.

Security0 comments

TL;DR

Apiiro found real secrets in 1,122 public copies of Claude Code's .claude/settings.local.json, saved there when developers chose "Yes, and don't ask again".

Counting git history, shared settings files and agent chat exports, it found 2,539 distinct secrets in 1,994 public repositories, most of them belonging to individual developers.

Anthropic's Boris Cherny said Claude Code keeps the file out of git when it creates it and that the team is looking at secret scanning. Anyone affected should rotate the keys first.

What Apiiro found

The security company Apiiro published the research on 5 November. Researchers Shmulik Cohen and Matan Giladi searched public GitHub between 1 and 3 November and found 104,185 copies of .claude/settings.local.json in 103,617 repositories. 1,122 of them, 1.1%, held what Apiiro calls a real secret: a key in a known provider format, or a password or token next to a public host. Apiiro didn't test any of them, so a real secret here means one that looks usable, not one known to work.

If you build with a coding agent, our guide How to keep API keys safe when you code with AI agents has the fixes for each way a key leaks and a prompt that checks your own project.

How a key ends up in the file

Ask Claude Code to query a database or call an API and the command it proposes often carries the password or token from your config. Claude Code asks before it runs a shell command. Choose "Yes, and don't ask again" and it saves the approval as an allow rule in .claude/settings.local.json, and the rule is the exact command, secret included. Apiiro says it reproduced this with Opus 5.5 and Fable 5.1, because it is how Claude Code stores approvals, not something the model does.

Claude Code's settings docs say the file is meant to stay on your computer: the first time Claude Code writes it in a git repository, it adds it to your global git excludes. Apiiro points out that this rule never goes into the repository's own .gitignore, so it doesn't cover a folder that becomes a repository later, a clone on another computer, or a file someone has already committed. In 539 of the 1,105 repositories Apiiro traced, a commit co-authored by Claude changed the file.

What was exposed

  • 1,379 distinct secrets in the 1,122 files: 636 provider keys and 743 passwords or tokens for public hosts.
  • More than a third open a database directly: 379 database passwords and 122 Supabase service-role keys, plus 103 Supabase account tokens that control every project in an account.
  • 43 SSH logins for public servers, 42 GitHub, GitLab and npm tokens, 23 AWS keys and 6 private keys.
  • 63 organisations among the owners, from student groups and startups to software agencies and a database vendor whose own admin-level cloud key was exposed. Apiiro says it told each of them on 2 and 3 November.
  • The files are old. In the median repository with a real secret, the file was first committed 217 days before 2 November, and 734 more secrets now live only in a file's history.

Secret scanners caught most but not all of them. Apiiro ran gitleaks and TruffleHog over the 1,122 files: gitleaks flagged 564 and TruffleHog 643, and 215 were flagged by neither. Those are mostly passwords typed into commands, which have no key format for a scanner to match.

Not only one file

The same habit leaves secrets in other files that agents write and developers commit. Apiiro found real secrets in 298 of the 76,011 shared .claude/settings.json files that teams commit on purpose, in 120 exported agent chats from 87 repositories, in agent memory files in 9 repositories, in 33 handoff and deploy notes, and in VS Code's auto-approve settings for Copilot in 9 repositories.

What Anthropic says

Boris Cherny, head of Claude Code at Anthropic, replied in the Hacker News thread about the research on 7 November. He said Claude Code hasn't scrubbed secrets so far and that the team is "looking into what we can do to prevent this". He named two ideas it will prototype: making auto mode catch these commands, and building in basic secret scanning.

He also said the file is not meant for source control, and that because Claude Code gitignores it when it creates it, the exposed copies were made by hand and checked in. He recommended auto mode, which lets a classifier approve commands instead of a growing list of rules, and the secret scanning that GitHub and other hosts offer.

What to do if you use Claude Code

  1. Search your repositories for .claude/settings.local.json and .claude/settings.json, and check git history for the files even if they are gone today.
  2. Rotate every credential either file has ever held, before anything else. Deleting the file doesn't clear history, forks or clones.
  3. Untrack the file with git rm --cached and add it to the repository's own .gitignore.
  4. Open the file on your computer and delete every allow rule that holds a password, a token or a connection string.
  5. From now on, refer to secrets by variable name in commands, and approve patterns such as npm run * instead of one literal command.

Give your agent rules to follow with your keys:Open the Secrets setup

Comments

Log in to comment, reply and like. Reading stays open to everyone.

No comments yet. Add what you know about it.

More news

All news

The week's news for builders, in Weekly Unpack.

Weekly Unpack is one email a week with founder stories, the playbooks behind them and the businesses we unpack in our interviews.

Plusand the Builder Kit come with it

Subscribing makes your account Plus and opens your Builder Kit: what your product needs next, written for your coding agent to do.

By subscribing you agree to our Privacy Policy.