跳到主内容
@wquguru
精选85VoxAI 产品与模型

Claude Code安全测试:用Opus 5.5自动化攻击演练

Claude Code tip: before you ship a vibe-coded site, have Opus 5.5 𝗽𝗹𝗮𝘆 𝘁𝗵𝗲 𝗯𝗮𝗱 𝗴…

原文
发到 X
推荐理由

提供了结构完整的 AI 安全测试工作流,包含具体的攻击场景、操作指令及自动化审查方案,对开发者有直接参考价值。

Claude Code tip: before you ship a vibe-coded site, have Opus 5.5 𝗽𝗹𝗮𝘆 𝘁𝗵𝗲 𝗯𝗮𝗱 𝗴𝘂𝘆. Send out 3 subagents with three test accounts (A, B and an admin) to actually run 𝘁𝗵𝗲𝘀𝗲 𝟭𝟰 𝗮𝘁𝘁𝗮𝗰𝗸𝘀, collect proof, then fix everything in one pass:

Claude Code 技巧:在你发布一个由 AI 生成的网站之前,让 Opus 5.5 扮演“红队”角色。派出 3 个子代理,使用三个测试账号(A、B 和一个管理员)实际运行这 14 种攻击,收集证据,然后一次性修复所有问题:

Impersonate other users → Without logging in, take the public key from your frontend and query every table in the database directly. See what comes back → Logged in as A, swap the id in a request for B's and try to read, edit and delete B's data → When A edits their profile, add role: admin to the request, then try editing the role in their own account data directly → Use a password reset link once, then click it again

冒充其他用户 → 无需登录,从前端获取公钥并直接查询数据库中的每个表,查看返回结果 → 以 A 的身份登录,在请求中替换为 B 的 ID,尝试读取、编辑和删除 B 的数据 → 当 A 编辑个人资料时,在请求中添加 role: admin,然后尝试直接在账户数据中编辑角色 → 使用一次密码重置链接后,再次点击该链接

Get around limits in the UI → For disabled buttons and hidden options, skip the page and send the request directly → Once the free uses run out, check whether calling the API directly still works → With only a little credit left, fire 20 requests at once and see whether more succeed than the credit allows → Fill forms with very long text, special characters, negative numbers and empty values → Change the post-login redirect (?next=) to another site, and also try values starting with // and @

绕过 UI 限制 → 对于禁用的按钮和隐藏选项,跳过页面并直接发送请求 → 免费额度用完后,检查直接调用 API 是否仍然有效 → 剩余少量积分时,同时发起 20 个请求,看是否有超过限额的请求成功 → 在表单中填入超长文本、特殊字符、负数和空值 → 将登录后重定向参数 (?next=) 改为其他站点,并尝试以 // 和 @ 开头的值

Come in from outside → Put <img src=x onerror=alert(1)> in a username, a comment or Markdown, then open the page in a browser and see if an alert pops up → If the app fetches URLs (importing links, building previews), give it http://localhost and http://169.254.169.254 and check the server logs for an actual outgoing request. Skip this if there's no such feature → For pages and API responses A has seen, request the same address from another browser as B or logged out, and see whether A's content shows up → Open your hosting platform's preview links without logging in to the platform → Hide an instruction in an uploaded document or web page that tells your AI feature to read another user's data or call a tool it shouldn't, and see if it does

来自外部的攻击 → 在用户名、评论或 Markdown 中插入 <img src=x onerror=alert(1)>,然后在浏览器中打开页面,查看是否会弹出警告框 → 如果应用会抓取 URL(如导入链接、生成预览),向其提供 http://localhost 和 http://169.254.169.254,并在服务器日志中检查是否有实际的出站请求。若无此类功能则跳过 → 对于 A 已访问过的页面和 API 响应,从另一个浏览器以 B 身份或未登录状态请求相同地址,查看 A 的内容是否出现 → 在未登录平台的情况下,打开托管平台的预览链接 → 在上传的文档或网页中隐藏一条指令,指示你的 AI 功能读取其他用户的数据或调用不应调用的工具,并观察其是否执行

Collect proof → Every item has to actually run. If it was only read in the code and never run, it counts as "not proven" → After a fix, temporarily turn the protection off in local code and run it again. The attack must succeed. Turn it back on and it must be refused → Put the results in a table: how each attack was done, the request and response, and whether it was refused when it should have been → Save the tests as scripts in the repo and run them again before your next launch → When you're done, install Anthropic's official security-guidance plugin (/plugin install security-guidance@claude-plugins-official). After every turn of edits, and after each commit or push it makes, Opus reviews the changes again. Those reviews use extra usage

收集证据 → 每个项目都必须实际运行。如果仅在代码中读取而从未运行,则计为“未证明” → 修复后,在本地代码中暂时关闭保护并再次运行。攻击必须成功。重新开启保护后,它必须被拒绝 → 将结果放入表格:说明每种攻击是如何进行的、请求和响应内容,以及本应被拒绝时是否被拒绝 → 将测试保存为仓库中的脚本,并在下次发布前再次运行它们 → 完成后,安装 Anthropic 的官方安全指导插件(/plugin install security-guidance@claude-plugins-official)。每次编辑轮次之后,以及每次提交或推送操作之后,Opus 都会再次审查更改。这些审查会使用额外的用量

The default medium effort is enough. The impersonation group is the most expensive to get wrong, so raise that one to high.

默认的中等工作量已足够。冒充组是最容易出错且成本最高的,因此将其提升至高工作量。

Send this whole post to Claude Code. If you need to, add this line at the end 👇 "First check that the preview environment isn't connected to the production database. If it is, run everything locally only. Use test accounts and test data, with a separate set of accounts for each subagent. Don't touch real users, don't attack services I don't own, don't hammer any one endpoint, and only test payments in test mode. Only switch protections off temporarily in local code, and never change the database or dashboard settings. Keep test account passwords in .env, out of git, and mask tokens in the results table. Send one subagent per group to attack, recording without fixing. Run the impersonation subagent at high effort. Then fix everything yourself from their lists, rerun every test, and give me a before-and-after table. Delete the test accounts and data at the end. For installing the plugin or changing dashboard settings, give me the steps and I'll do it."

将此整篇帖子发送给 Claude Code。如果需要,请在末尾添加这一行 👇 “首先检查预览环境是否连接到了生产数据库。如果是,则仅在本机运行所有内容。使用测试账户和测试数据,并为每个子智能体使用一组独立的账户。不要触碰真实用户,不要攻击我不拥有的服务,不要对任何单一端点进行高频请求,并且仅在测试模式下测试支付功能。仅在本机代码中临时关闭保护,且绝不更改数据库或仪表板设置。将测试账户密码保存在 .env 文件中,排除在 git 之外,并在结果表中屏蔽令牌。每组发送一个子智能体进行攻击,记录但不修复。以高工作量运行冒充子智能体。然后从他们的列表中自行修复所有问题,重新运行每项测试,并提供一份前后对比表。最后删除测试账户和数据。关于安装插件或更改仪表板设置,请提供步骤,由我来执行。”

更进一步:量化金融体系

看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力

进入量化体系 →

相似阅读

关联信息,但可能不是同一事件