---
title: "Claude Code: Approved Commands Leak Secrets to Public Repos"
url: https://erroneo.us/security/briefs/claude-code-settings-local-json-secrets-github/
description: "Apiiro found secrets in 1,122 public .claude/settings.local.json files saved by 'don't ask again'. Search your repos, rotate what you find, then untrack it."
type: security-brief
section: "Security Digest"
date_published: 2026-11-05
date_modified: 2026-11-09
publisher: erroneo.us
author: erroneo.us Security Desk
verdict: "Check exposure"
cves: []
severity: "high"
exploited: "none-known"
kev: false
license: All rights reserved. Quote with attribution and a link.
---

# Claude Code: Approved Commands Leak Secrets to Public Repos

**Verdict: Check exposure.** Nothing here attacks your machine, but if a .claude/settings.local.json file was ever committed to a repository others can read, assume any password or token in it is exposed and rotate it.

- **Who must act:** Teams using Claude Code whose repositories, especially public ones or forks, have ever tracked .claude/settings.local.json or put literal credentials in .claude/settings.json.
- **Who can relax:** Developers whose settings.local.json has never been committed, which is the default when Claude Code creates the file, and whose approved commands contain no literal secrets.
- **Affected:** Claude Code projects with .claude/settings.local.json committed to git (version range not disclosed as of 2026-11-09)
- **Fixed:** none listed
- **CVEs:** none
- **CISA KEV:** no · **Exploitation:** No known exploitation

## What to do

1. Search your organization for committed copies with gh search code permissions --owner YOUR_ORG --filename settings.local.json, then repeat for settings.json.
2. Rotate every password, token and key found in those files or their git history before you clean anything up.
3. Untrack the file with git rm --cached .claude/settings.local.json and add it to the repository's .gitignore.
4. Remove literal secrets from allow rules in local copies, and pass credentials through environment variables or a secrets manager.
5. Prefer prefix rules such as Bash(npm run *) over approving one-off commands that contain credentials.
6. Treat agent folders such as .claude/, .cursor/, .gemini/ and .specstory/ as secret-bearing, like .env files, in reviews and scanner configuration.

### How to check if you are affected

- List tracked agent files: git ls-files | grep -E '(^|/)\.claude/'.
- Check history on all branches: git log --all --oneline -- .claude/settings.local.json.
- Search for passwords typed into commands: grep -nE 'PGPASSWORD=|sshpass -p|mysql .*-p|Bearer |AKIA' .claude/settings.local.json. Generic scanners missed many of these.
- Confirm the ignore rule applies on each machine: git check-ignore -v .claude/settings.local.json.

## What happened

Security company Apiiro published research on [November 5, 2026](https://runtimewire.com/article/claude-code-dont-ask-again-secrets-public-github-settings-files) showing that Claude Code's permission file is leaking credentials into public GitHub repositories. Apiiro's page was not readable by our tools, so the figures below come from [The Hacker News](https://thehackernews.com/2026/11/claude-codes-dont-ask-again-file.html) and [Security Online](https://securityonline.info/claude-code-leaking-secrets-github/), which agree on the core numbers.

When you choose "Yes, and don't ask again" on a Bash prompt, Claude Code [saves an allow rule](https://code.claude.com/docs/en/settings) in `.claude/settings.local.json`. If the approved command had a password or token on the command line, the secret can land in that file in plain text. This behavior was [reported in August 2025](https://github.com/anthropics/claude-code/issues/5544) and that issue was closed as "not planned" by an inactivity bot in January 2026, with no maintainer reply in the thread.

Scanning between November 1 and 3, the researchers found 104,185 public copies of the file in 103,617 repositories. Of those, 1,122 copies, about 1.1%, held at least one secret, for 1,379 distinct secrets. They include 379 database passwords, 43 SSH logins for public servers and 23 AWS keys. Counting git history, the shared `settings.json` and saved agent chat logs, the total is 2,539 secrets across 1,994 repositories.

## Who is affected

You are affected only if a file like this reached a place others can read. The [documentation](https://code.claude.com/docs/en/settings) says Claude Code adds `**/.claude/settings.local.json` to your global git excludes the first time it writes the file. That protects a normal setup on that machine. It does not help a file that was already tracked, one that was committed from a machine with different git configuration, a forced `git add`, or the 74 repositories whose forks carry the same secrets. It also does not cover the shared `.claude/settings.json`, which teams are told to commit and where 298 of 76,011 copies held secrets.

How the files got into git is disputed. Per Security Online, Claude Code lead Boris Cherny said on Hacker News on November 7 that the tool ignores the file when it creates it, so he believes exposed copies were created by hand and checked in. The researchers report that in 539 of 1,105 traced repositories, a commit crediting Claude as co-author changed the file. Both can be true, and neither changes what you should do if you find one.

## Do you really need to act?

**Do a one-time search, and act only on what you find.** This is not a remotely exploitable bug and no attacks using these secrets have been reported. Most users have nothing committed. The risk is concentrated in public repositories and in habits like typing `PGPASSWORD=...` or `sshpass -p` into an agent session. The researchers did not test whether the secrets still work, though Security Online reports that one notified organization confirmed its key was live. Every secret-bearing file was still on its default branch when scanned, and in half of those repositories it had been there at least 217 days.

No shipped fix is named in the reports we reviewed as of November 9. Cherny said the team is looking at prevention, including secret scanning. Do not rely on generic scanners in the meantime: Gitleaks flagged 564 of the 1,122 files, TruffleHog flagged 643, and neither flagged 215, mostly passwords typed inside commands.

## What to do now

1. Search your organization: `gh search code permissions --owner YOUR_ORG --filename settings.local.json`, then again for `settings.json`.
2. Rotate first. Removing a file from the tree leaves the secret in history and in forks.
3. Run `git rm --cached .claude/settings.local.json` and add the path to the repository's `.gitignore`, so the protection does not depend on each developer's global git config.
4. Delete literal secrets from allow rules in local copies. Pass credentials through variables such as `$DATABASE_URL` or a secrets manager.
5. Prefer [prefix rules](https://code.claude.com/docs/en/permissions) such as `Bash(npm run *)`. Decline "don't ask again" on any one-off command that contains a credential.
6. Treat `.claude/`, `.cursor/`, `.gemini/` and `.specstory/` like `.env` files in review and scanner rules.

## How to tell if you were hit

Run `git ls-files | grep -E '(^|/)\.claude/'` and `git log --all --oneline -- .claude/settings.local.json`. Then read the file's `permissions.allow` entries, because pattern scanners miss passwords embedded in commands. If you find a secret in a public repository, assume it was harvested and review that credential's access logs for use you do not recognize.

## Timeline

- Aug 11, 2025 — Issue #5544 reports credentials saved in plain text in `settings.local.json`.
- Jan 3, 2026 — Issue closed as "not planned" by an inactivity bot.
- Nov 1–3, 2026 — Apiiro scans public GitHub and notifies affected organizations on November 2 and 3.
- Nov 5, 2026 — Apiiro publishes its research.
- Nov 7, 2026 — Press coverage follows, and Boris Cherny responds on Hacker News.

## Sources

1. [Anthropic — Claude Code settings documentation](https://code.claude.com/docs/en/settings)
2. [Anthropic — Claude Code permissions documentation](https://code.claude.com/docs/en/permissions)
3. [anthropics/claude-code — Issue #5544: approved bash commands stored with plain text credentials](https://github.com/anthropics/claude-code/issues/5544)
4. [Security Online — Claude Code Leaking Secrets Across Nearly Two Thousand Public GitHub Repositories](https://securityonline.info/claude-code-leaking-secrets-github/)
5. [Runtime Wire — Apiiro finds secrets in 1,122 public Claude Code settings files](https://runtimewire.com/article/claude-code-dont-ask-again-secrets-public-github-settings-files)
6. [The Hacker News — Claude Code's 'Don't Ask Again' File Exposes Passwords and Keys in 1,122 Public Copies on GitHub](https://thehackernews.com/2026/11/claude-codes-dont-ask-again-file.html)

---
Source page: https://erroneo.us/security/briefs/claude-code-settings-local-json-secrets-github/ · Security Digest: https://erroneo.us/security/ · More: https://erroneo.us/llms.txt
