Search your repos and git history for .claude/settings.local.json, rotate anything in it, then gitignore it
Claude Code's 'don't ask again' saved passwords and keys into a project file: secrets found in 1,122 public copies on GitHub · Security incident · Web · The Hacker News (Apiiro research) · Nov 6, 2026
What happened
Apiiro found that when a Claude Code user picks 'Yes, and don't ask again', the exact approved command can be saved word for word in .claude/settings.local.json, including any password or token typed into it. Searching public GitHub (1 to 3 Nov), it found 104,185 copies of the file, 1,122 of them holding at least one secret (1,379 distinct secrets), more than a third of them database access, including 379 database passwords. Claude Code adds the file to the user's global git excludes, but not to the project's own .gitignore, so the protection doesn't travel with the repo. Apiiro did not test the secrets; one notified company confirmed its key had been live. The Hacker News reported the research on 7 Nov.
How to prevent it
Never type secrets directly into commands an agent runs; reference them as environment variables. Approve command patterns rather than one-off commands that contain values. Add .claude/settings.local.json (and other agent folders like .cursor/) to every project's .gitignore and to your secret scanning, including git history.
Fix prompt for your own AI tool
Copy this into your own AI tool (Cursor, Lovable, Claude Code, Bolt…). It's general guidance written by us. Review what the AI suggests before applying it.
I use Claude Code. Help me check whether it has saved secrets into my project. 1) Tell me how to look for .claude/settings.local.json and .claude/settings.json in this repo and in its git history, including deleted versions. 2) Show me how to spot allow rules that contain a password, token, API key or connection string, without printing the values back to me. 3) Give me the steps to stop tracking the local file (git rm --cached .claude/settings.local.json) and add it to this project's own .gitignore. 4) Show me how to reference secrets as environment variables, such as $DATABASE_URL, so approved commands never contain the real value, and how to approve patterns instead of single commands. Remind me to rotate any secret the file ever held before I clean up history. Don't change anything until I've approved your plan. Never ask me to paste API keys, passwords or .env contents; tell me where to check them myself.
Why this keeps happening: leaked secrets & api keys
Secret keys placed in front-end code, mobile bundles or public repositories can be found by automated scanners and abused, often running up large bills on AI or cloud accounts before anyone notices.
A quick checklist before you ship
- Keep secret keys only in server-side environment variables, never in browser or app code.
- Set spend limits and usage alerts with every AI and cloud provider.
- Turn on secret scanning and push protection for your repositories.
- If a key leaks, revoke and replace it first; deleting the file is not enough.
More on this: every leaked secrets & api keys story and our related guide.
Tools involved
Related stories
- Turn on Privacy Mode in Cursor, never paste live keys into agent chats, and rotate any key you shared with an AI tool or its support team
Cursor: a key Fireworks exposed opened coding-agent traces holding unredacted customer credentials - Keep secrets out of what your AI agent can read
GitGuardian: real leaked API keys recovered from three LLMs; Claude Code commits leak more - Protect the AI tool tokens saved on your laptop
Aoki infostealer now steals Claude, Codex, Cursor and Copilot credentials
Source: original post on Web ↗. Summarised in our own words; numbers are as stated by the source. Browse all stories.