Notebookcheck Logo

Claude Code: How to check your GitHub repos for leaked passwords

Laptop screen showing program code in blue light
ⓘ Nemuel Sereti / Pexels
Laptop showing program code in a dark room (symbolic image).
Claude Code saved passwords and API keys in a settings file that many developers later pushed to GitHub. An update released on November 12 stops new entries, but existing ones stay put. Here is how to check your repositories, which credentials to rotate first, and where Codex, Cursor and Copilot store their command approvals.

Clicking "Yes, and don't ask again" in Claude Code saves time. For many developers it also published database passwords, cloud keys and SSH logins. Our news story on Apiiro's findings explains how that happened. Since then, Anthropic has shipped an update and a second, much larger study has come out. This guide covers the practical side: how to find out whether you are affected and what to do, in what order.

Why the password ends up in the file

Claude Code asks for permission before it runs a shell command. If you approve a command permanently, Claude Code saves it as a rule in .claude/settings.local.json, and it saves the full command. If that command contained a password or token, for example in a psql or curl call, the secret now sits in the file in plain text. According to Anthropic's documentation, the file is meant to stay out of your repository. To do that, Claude Code adds it to your global git excludes on your own machine rather than to the project's .gitignore. That protection does not travel with the repository, so it does not apply on a new machine, in CI or for colleagues.

A GitGuardian analysis published on November 9 shows the scale. Since January 2025, the company found 31,088 distinct secrets in these files on GitHub, spread across 23,276 repositories. Of those, 5,343 were still valid when they were detected. Leaks peaked in April 2026 at 12,535 in a single month and fell to 959 in October. The files also turned up inside images on Docker Hub.

Anthropic responded on November 12 with version 2.1.323. The release notes say a "don't ask again" rule that looks like it holds a secret, or that would be saved to a settings.local.json tracked by git, "lasts for the session only and isn't saved." The update also fixes the file not being ignored globally when a folder becomes a git repository later or is used on a new machine. It does not remove anything already in the file or already pushed, and Anthropic has not said how Claude Code decides that a rule looks like a secret. Run claude --version to see your version and claude update to install the latest one.

How a permanent approval in Claude Code travelled from a command with a password to a public repository, up to version 2.1.322.

How to find the file in your repositories

GitHub code search is the fastest way in. A query such as path:.claude/settings.local.json user:YOURNAME or org:YOURORG lists every repository that contains the file. Run the same search for .claude/settings.json, because Apiiro found secrets in 298 of those shared files as well, The Hacker News reports. Code search only shows the current state of a repository, though. Of the secrets Apiiro found, 734 existed only in the commit history, after the file itself had been deleted.

To check the history, open each repository locally and run git log --all --full-history -- .claude/settings.local.json. It lists every commit that ever touched the file. If anything shows up, open the old versions and read the allow list yourself. Gitleaks and TruffleHog can help, and gitleaks git . scans a repository's full history. Do not rely on them alone, though. According to Apiiro, both tools missed 215 of the 1,122 files that held real secrets, mostly passwords embedded in an ordinary command line. TruffleHog's option to show only verified results filters out those passwords.

GitHub scans public repositories for known key formats for free, including the history of every branch. Push protection, which blocks such keys before they are uploaded, is on by default for personal accounts. Generic passwords, however, are only detected by AI, and push protection for them is still in public preview, according to GitHub's documentation. No alert does not mean nothing slipped through.

Where Claude Code, OpenAI Codex, Cursor, VS Code Copilot and Gemini CLI store permanently allowed commands, according to vendor documentation.

Rotate credentials first, then clean up

GitHub's guide puts the most important step first. A secret that has been public should be treated as compromised. Replace it before anything else, which means a new database password, a new API key or a new SSH key, and revoke the old one. GitGuardian's advice is to "rotate everything the file ever held first." Only then is it worth cleaning up the repository, because deleting the file is not enough. It remains in the history, in forks and in any copies other people have already pulled. According to The Hacker News, the same secrets appeared in 211 forks of 74 repositories.

To remove the file from the history, GitHub recommends git-filter-repo with --sensitive-data-removal --invert-paths --path .claude/settings.local.json, followed by a force push. That does not reach forks, and old commits can stay reachable by their hash for a while. GitHub Support can help with cached views. After that, remove the file from version control with git rm --cached, add it to the project's .gitignore and confirm it with git check-ignore -v. If you publish packages to npm or images to Docker Hub, add it to .npmignore and .dockerignore as well.

In the long run, one habit matters most. Passwords belong in environment variables or a command-line password manager, not in a command that an agent runs. When you approve commands, use a pattern such as Bash(npm run test:*) rather than the full line. This goes beyond Claude Code. According to its documentation, "Codex writes to the user layer at ~/.codex/rules/default.rules." Cursor supports a per-project permissions file, and its docs tell teams to commit it so everyone shares the same rules. Whatever is in that file is published with the next push. Our report on Postman plugins that installed themselves showed how easily agents create files in a project folder that nobody asked for.

Google LogoAdd as a preferred source on Google
Mail Logo
static version load dynamic
Loading Comments
> Expert reviews and news on laptops, smartphones and tech innovations > Reviews > Claude Code: How to check your GitHub repos for leaked passwords
Steffen Zahn, 2026-11-16 (Update: 2026-11-14)