用 Claude Code 自查 AI Key 存储位置
If you use Claude Code or Codex, 𝗵𝗮𝘃𝗲 𝗶𝘁 𝗰𝗵𝗲𝗰𝗸 𝘄𝗵𝗲𝗿𝗲 𝘁𝗵𝗲 𝗔𝗜 𝗸𝗲𝘆𝘀 𝗼𝗻 𝘆𝗼𝘂𝗿 𝗺𝗮𝗰𝗵𝗶𝗻𝗲…
提供了可直接复用的具体 Prompt,将 AI 工具用于自身安全防护,结构清晰且具备实操性。
If you use Claude Code or Codex, 𝗵𝗮𝘃𝗲 𝗶𝘁 𝗰𝗵𝗲𝗰𝗸 𝘄𝗵𝗲𝗿𝗲 𝘁𝗵𝗲 𝗔𝗜 𝗸𝗲𝘆𝘀 𝗼𝗻 𝘆𝗼𝘂𝗿 𝗺𝗮𝗰𝗵𝗶𝗻𝗲 𝗮𝗿𝗲 𝘀𝗶𝘁𝘁𝗶𝗻𝗴, today. OpenCode disclosed an attack two days ago: AI accounts linked to it had their credits drained, and the Codex lead at OpenAI said today those credits were refunded.
如果你使用 Claude Code 或 Codex,今天就让它们检查一下你的机器上 AI 密钥存放在哪里。 OpenCode 两天前披露了一起攻击事件:与其关联的 AI 账户积分被耗尽,OpenAI 的 Codex 负责人今天表示这些积分已退还。
The breach happened on OpenCode's servers. We took it as a reason to have Claude Code look through our own Mac without changing anything. OpenCode's login file from January was still there, holding 𝟰 𝘀𝗮𝘃𝗲𝗱 𝗹𝗼𝗴𝗶𝗻𝘀.
此次漏洞发生在 OpenCode 的服务器上。我们将其视为让 Claude Code 在不更改任何内容的情况下扫描我们自己 Mac 的理由。OpenCode 一月份的登录文件仍然存在,其中包含 𝟰 个保存的登录凭据。
1. The login files for OpenCode, Codex and Gemini CLI live at ~/.local/share/opencode/auth.json, ~/.codex/auth.json and ~/.gemini/oauth_creds.json. For tools you haven't opened in a while, revoke access in their dashboard first, then delete the file. 2. Codex can keep its login in the system keychain: add cli_auth_credentials_store = "keyring" to ~/.codex/config.toml. Claude Code already keeps its login in the Keychain on a Mac. 3. Any key you export in ~/.zshrc can be read by every Claude Code or Codex session you start from that terminal. We had 𝟮 𝗼𝗳 𝘁𝗵𝗲𝗺. 4. We found 32 .env files across our projects, and none of them are in git. Anything committed and later deleted still sits in git history, and we haven't checked that part yet. 5. Set a spending cap wherever the dashboard lets you, and give each project its own key, so if something goes wrong you only revoke that one.
1. OpenCode、Codex 和 Gemini CLI 的登录文件位于 ~/.local/share/opencode/auth.json、~/.codex/auth.json 和 ~/.gemini/oauth_creds.json。对于你有一段时间未打开的工具,请先在其仪表盘中撤销访问权限,然后删除该文件。 2. Codex 可以将登录信息保存在系统钥匙串中:在 ~/.codex/config.toml 中添加 cli_auth_credentials_store = "keyring"。Claude Code 在 Mac 上已将登录信息保存在钥匙串中。 3. 你在 ~/.zshrc 中导出的任何密钥,都可以被你从该终端启动的每个 Claude Code 或 Codex 会话读取。我们发现了 𝟮 个这样的密钥。 4. 我们在项目中找到了 32 个 .env 文件,且它们均未纳入 git 版本控制。任何已被提交但随后删除的内容仍然保留在 git 历史记录中,而我们尚未检查这部分内容。 5. 在仪表盘允许的地方设置支出上限,并为每个项目分配独立的密钥,这样如果出现问题,你只需撤销该特定密钥即可。
Have Claude Code build the same table for your machine 👇 "Check where the AI keys and tokens on this computer are stored, and don't change anything. Never show a value in command output or in your reply; to tell whether a token is hard-coded, only count matches with grep -c. Check each AI CLI's login file, whether Codex stores its login in a file or the keychain, CLI tokens like ~/.config/gh, env blocks in MCP configs, KEY/TOKEN/SECRET exports in shell startup files, .env files in my projects (whether they're in git or in git history) and .env files in build output folders. Put it in a table: location, which service, last modified, risk level and where to revoke it, highest risk first."
让 Claude Code 为你的机器构建相同的表格 👇 “检查此计算机上 AI 密钥和令牌存储的位置,不要更改任何内容。切勿在命令输出或回复中显示任何值;要判断令牌是否为硬编码,仅使用 grep -c 进行匹配计数。检查每个 AI CLI 的登录文件,确认 Codex 是将登录信息存储在文件中还是钥匙串中,检查 CLI 令牌(如 ~/.config/gh)、MCP 配置中的 env 块、shell 启动文件中的 KEY/TOKEN/SECRET 导出、我项目中的 .env 文件(无论是否在 git 中或 git 历史记录中)以及构建输出文件夹中的 .env 文件。以表格形式呈现:位置、所属服务、最后修改时间、风险等级以及撤销位置,按风险从高到低排序。”
更进一步:量化金融体系
看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力