# Coding Agents Copy Your Secrets to a Hidden File. Thousands Are on GitHub
<!--
ref: @content/web/apiiro/2026-11-05-coding-agents-leaking-secrets
tags: [claude-code, secrets-security, supply-chain, agent-permissions]
version: 2
updated_at: 2026-11-22T14:06:45.405Z
-->

**[Read the original](https://apiiro.com/blog/coding-agents-leaking-secrets-github-dont-ask-again)**


*Synthesized from the Apiiro research blog post by Shmulik Cohen and Matan Giladi, 2026-11-05, including its November 8 update.*

Apiiro researchers scanned public GitHub for a file Claude Code writes when a user permanently approves a shell command, and found it frequently contains live credentials. The count came to 2,539 real secrets across 1,994 public repositories, with 63 organizations affected, from student groups to established vendors.

## Core Thesis

The leak is a product behavior, not a model quirk. When a proposed command embeds a password or token and the user picks the "always allow" option, Claude Code stores the literal command in .claude/settings.local.json. The file is meant to stay local, but nothing in the repository itself marks it private, so it gets committed along with everything else. The authors argue that developers, security teams and scanners all need to treat agent folders as secret-bearing.

## Key Insights

- **Mechanism.** Commands that query a database or call an API carry the secret inline. Approving one with "Yes, and don't ask again" saves the exact command string, secret included, as a permission rule. The authors reproduced it with several current models.
- **Why the safeguard fails.** Claude Code adds the file to the developer's global git ignore when it creates it in a repo. That does not help a folder that becomes a repo later, a clone elsewhere, or a file already tracked. The repo's own .gitignore is never updated.
- **Claude often commits it.** In 539 of the 1,105 traced repos with a real secret, a commit co-authored by Claude changed the file. The commit guidance warns against committing .env and credentials files but does not name this one.
- **Scale.** Of 104,185 public copies of the file, 1,122 (about 1.1%) hold a real secret. More than a third open a database directly. Larger allowlists leak far more often: roughly one in ten files over 8 KB versus under one in 500 for tiny ones.
- **Persistence.** The median affected repo had the file committed 217 days before the check. Deleting it does not help, since history holds 734 more secrets in 509 repos, and 211 forks of 74 repos carry copies.
- **Scanner gap.** gitleaks flagged 564 and TruffleHog 643 of the 1,122 files, and 215 were caught by neither. Scanners key on provider formats and miss plain passwords after PGPASSWORD=, sshpass -p or mysql -p.
- **Beyond one file.** Secrets also showed up in 298 shared settings.json files, 120 chat transcript files in 87 repos, agent memory files, handoff notes and VS Code Copilot auto-approve settings, plus a few Hugging Face Spaces and GitLab repos.
- **Local risk.** The file is plain JSON at a predictable path, a ready-made map of reachable systems for malware. The post cites the Shai-Hulud npm worm and the malicious Nx packages as precedent for credential harvesting on developer machines.
- **Vendor response.** Users reported the mechanism in GitHub issues from August 2025 without a reply. After publication, Anthropic's head of Claude Code said on Hacker News that the product historically did no secret scrubbing and that the team is prototyping fixes such as auto mode catching it and built-in basic secret scanning. He also noted the file is gitignored on creation, so exposed copies were likely created manually and checked in.
- **Method caveat.** No credentials were tested. "Real secret" means a provider-format match or a password next to a public host, confirmed by rules plus an LLM reviewer, not proof of validity.

## Actionable Takeaways

- Search your org for .claude/settings.local.json and .claude/settings.json, and check git history even if the file is gone today.
- If found, rotate first and clean up second: rotate every credential the file ever held, since forks and clones keep history.
- Untrack with `git rm --cached .claude/settings.local.json` and add the path to the repo's own .gitignore.
- Stop typing secrets into commands. Reference them as environment variables so the saved rule records the variable name.
- Approve command patterns, such as a prefix rule for npm run, instead of literal command lines.
- Treat .claude/, .cursor/, .gemini/, .specstory/ and agent memory files like .env in pre-commit and CI scanning, including history, and tune scanners to catch passwords inside commands.
- Add the settings file to org-wide .gitignore templates and triage credentials paired with public hosts first.

## Notable Quotes

- "Yes, and don't ask again" — the permission prompt option that writes the full command, secret included, to the settings file.
- "looking into what we can do to prevent this" — Anthropic's head of Claude Code, responding on Hacker News on November 7.

---

*Related: `@content/web/xinyadu/2026-11-29-claude-code-task-framing-study` · `@content/web/github/2026-11-29-convex-backend-skill-issue-64` · `@content/web/github/2026-11-27-resume-command-osc-7577-issue-112408` · `@content/web/github/2026-11-26-opus-context-fills-faster-issue-112194` · `@content/web/github/2026-11-26-interactive-session-misclassified-background-issue-112133`*

---

*You're reading a protocol on [protocol.supply](https://protocol.supply) — hosted, searchable knowledge for AI agents. Think Agent Skills, as an API: bootstrap once (`curl -sL https://api.protocol.supply/bootstrap`), search (`/search?q=…`), fetch (`/@repo/slug`).*

*Any skill can become a protocol, and any protocol installs as a local skill — tell your agent "install this as a skill" or see [`@protocol/protocol-to-skill`](https://api.protocol.supply/@protocol/protocol-to-skill).*