Claude Code Wrote Passwords Into a Settings File. Some of Them Reached GitHub

Claude Code 把密码写进了项目文件,然后被推上了 GitHub

新闻资讯C1进阶59.1
329 词 2 分钟 205 次阅读

The rule file records the command a developer approved — including any secret in it. Apiiro found 2,539 real credentials across 1,994 public repositories.

Claude Code has been writing developers' secrets into a settings file that sometimes ends up in public GitHub repositories. A security firm counted 2,539 real credentials across 1,994 repositories.

The research, by Apiiro and reported by Ars Technica, found more than 100,000 Claude Code local settings files uploaded to public repositories; about 1,100 contained database passwords, API tokens, private keys or root login details. Combining those files with git history, shared settings and agent chat logs produced the larger figure.

The 63 affected organisations include student teams, startups, software agencies and established vendors. What leaked includes Azure database passwords, Square production tokens, SSH root credentials and, in one case, the owner password for a medical records database.

The mechanism is mundane. When Claude Code asks permission to run a shell command and the developer chooses “yes, and don't ask again”, the rule is written to .claude/settings.local.json. The command text is recorded too — so if the command contained a password or a token, so does the file.

That file is supposed to be excluded by the developer's global .gitignore, but the exclusion does not reliably reach every repository: a project cloned onto another machine, or an ordinary folder later turned into a git repository, can slip past it. The researchers also report that Claude Code sometimes committed settings changes without asking.

Two details make it worse. The larger the allowlist, the likelier a secret: one file in ten over 8 KB contained a real one, against fewer than one in five hundred under 500 bytes. And deleting the file does not recall it — anyone who forked the repository keeps their copy.

It is not a new problem. Bug reports from August 2025 said the settings file might not be added to .gitignore correctly; they were closed after 60 days of inactivity. Boris Cherny of the Claude Code team said on Hacker News on 7 November that the team is studying preventive measures, that settings files should never be committed, and that built-in secret scanning is under consideration.

中文翻译(全文)

Claude Code 一直在把开发者的密钥写进一个设置文件,而这个文件有时会被推到公开的 GitHub 仓库里。一家安全公司统计出 1994 个仓库中的 2539 个真实凭据。

这项由安全公司 Apiiro 完成、经 Ars Technica 报道的研究发现,超过 10 万份 Claude Code 本地设置文件被上传至公开仓库,其中约 1100 份含有数据库密码、API Token、私钥或 root 登录信息。再结合 git 历史、共享设置与智能体聊天记录,得出了更大的总数。

学生团队、初创公司、软件代理机构,也有成熟供应商——被波及的组织共 63 家。泄漏物里既有 Azure 数据库的口令和 SSH 的 root 登录信息,也有 Square 的生产令牌;最严重的一例,是一个医疗记录数据库的拥有者密码。

机制很平常。当 Claude Code 询问是否允许运行某条 shell 命令、开发者选择「是,且不再询问」时,这条授权规则会被写入 .claude/settings.local.json。命令原文也会被记录下来——所以如果命令里带着密码或 token,文件里也就有了。

这个文件本应被开发者全局的 .gitignore 排除,但这条排除并不总能作用到每个仓库:项目被克隆到另一台电脑,或者一个普通文件夹后来才被初始化为 git 仓库,都可能绕过去。研究者还表示,Claude Code 有时会在未经询问的情况下自行提交设置文件的改动。

两个细节让情况更糟。允许列表越大,越可能藏有密钥:8KB 以上的文件里每十个就有一个含真实密钥,而小于 500 字节的文件中不到五百分之一。另外,删掉文件并不能收回它——任何 fork 过该仓库的人都留着自己那份。

这并不是新问题。2025 年 8 月就有 bug 报告指出设置文件可能未被正确加入 .gitignore,这些报告在 60 天无活动后被关闭。11 月 7 日,Claude Code 团队的 Boris Cherny 在 Hacker News 上回应称,团队正在研究预防措施,设置文件本就不该被提交,并考虑把密钥扫描内置进产品。

重点词汇

  • credential/krəˈdenʃl/n.— a password, key or token used to gain access凭据It found 2,539 credentials.
  • token/ˈtəʊkən/n.— a string used to authenticate an API call令牌Square production tokens leaked.
  • private key/ˈpraɪvət kiː/n.— a secret key used for authentication私钥Some files held private keys.
  • allowlist/ˈəlaʊlɪst/n.— a list of things permitted without further checks允许列表A larger allowlist raises the risk.
  • version control/ˈvɜːʃn kənˈtrəʊl/n.— a system that tracks changes to code版本控制Settings should not be committed.
  • commit/kəˈmɪt/v.— to record changes in a repository提交It sometimes committed settings without asking.
  • fork/fɔːk/v.— to copy someone's repository复刻(仓库)Anyone who forked it keeps a copy.
  • secret scanning/ˈsiːkrət ˈskænɪŋ/n.— automatically detecting credentials in code密钥扫描Built-in secret scanning is considered.
  • mundane/mʌnˈdeɪn/adj.— ordinary and unremarkable平常的The mechanism is mundane.
  • exclude/ɪkˈskluːd/v.— to keep something out排除The file should be excluded.

阅读测验

共 5 道题目

5 题
1.[单选]

What was found in public repositories?

2.[单选]

How do secrets end up in the file?

3.[判断]

Deleting the leaked file from the original repository does not remove it from forks.

4.[多选]

Which details are given? (Select all that apply)

5.[填空]

Claude Code's team is considering building _____ scanning into the product.

(1)

评论

0 条讨论

按时间

登录后发表评论

立即登录

暂无评论

成为第一个分享想法的人吧!