You ask your coding assistant to connect to a database. It suggests a command, with the password written inside it. You click "Yes, and don't ask again", to save time next time. You may have just published that password on the internet.
That is what Apiiro, a company specialising in software security, found in a study published on 6 November and reported by The Hacker News. It concerns Claude Code, Anthropic's programming assistant. But its lessons apply to all tools of the same kind.
What happened
When you approve a command with the "don't ask again" option, Claude Code saves a rule to run it automatically in future. This rule is stored in a small project file named .claude/settings.local.json. If the rule reproduces the exact command, everything it contains is copied into it word for word, passwords included, in plain text.
The problem is that this file often ends up published along with the rest of the code. Claude Code does exclude it from uploads on the user's machine, but it does not add it to the project's own ignore list. And according to Apiiro, in 539 of the 1,105 projects examined in detail, the change to this file had been recorded in a contribution co-signed by Claude. In other words, the assistant often published it itself.
The scale of the leak
The researchers found more than 104,000 copies of this file on GitHub, the main code-sharing platform. Just over 1% contained at least one secret. Adding other configuration files and conversation histories with the agent, they reach a total of 2,539 secrets exposed across 1,994 projects.
| Type of secret found | Number |
|---|---|
| Database passwords | 379 |
| Login credentials for public servers | 43 |
| GitHub, GitLab or npm access tokens | 42 |
| Amazon cloud access keys | 23 |
Among the owners are 63 organisations. Apiiro cites in particular the master password of a medical records database. At the time of the study, all the files concerned were still online, and in half the cases for at least 217 days.
Of sixteen coding assistants compared by Apiiro, Claude Code is the only one whose documentation confirms that it saves the full command in a project file by default. A report describing this problem had been filed as early as August 2025. It was closed automatically in January 2026, with no response from Anthropic according to the researchers. The Hacker News article reports no fix or statement from the company.
Six rules for coding without exposing your secrets
1. Never type a password into a command. Keep your secrets in environment variables or a secrets manager, and refer to them by name, for example $DB_URL. The AI then handles the variable name, never its value.
2. Approve command families, not exact commands. For example, authorise "all commands that start with npm run" rather than a specific command containing a token. You save just as much time, without recording anything sensitive.
3. Exclude the assistant's files from your project. Add .claude/settings.local.json to each project's .gitignore file. If the file has already been published, untrack it with the command git rm --cached .claude/settings.local.json. Other assistants have their own folders, such as .cursor/ or .gemini/: treat them with the same care.
4. Review what the AI publishes. Before every push, check the list of modified files. An assistant that can save and publish code can also slip in a file you would never have shared.
5. If a secret has leaked, change it first. Deleting the file is not enough: it remains in the project's history and in its copies. Apiiro found 734 additional secrets in older versions and in copies of projects. The only protection is to replace the password or key immediately.
6. Search for these files yourself. Automated secret-detection tools performed poorly here: gitleaks spotted only 564 of the 1,122 affected files, and TruffleHog 643. They mainly look for keys in known formats, not passwords typed in the middle of a command. A manual search for these files in your projects remains essential.
Since 2024, GitHub has blocked by default, in public projects, the push of many recognisable key types, such as those from Amazon or GitHub itself. But this protection relies on known formats. A password chosen by a human and slipped into a command has no particular format: it therefore passes without an alert. And bots constantly scan public projects looking for this kind of find.
What this tells us
Code assistants have become real colleagues: they run commands, modify files, publish code. But every shortcut that saves us time can also move a risk somewhere we no longer see it. We saw this with agents capable of raising their own spending limit. The same logic applies here.
The golden rule does not change, whether or not you work with an AI: a secret must never be written in plain text where others can read it. And as with what you should never paste into an AI at work, the best reflex remains to assume that anything you entrust to an assistant may one day leave your computer.
>>