Before you run the code your AI agent wrote, check these five things
说明与用途
开发者可能无意中运行由 AI 助手生成的恶意代码。该工作流程列出了五个检查点:依赖项、安装脚本、配置文件、模型调用安全性和 SSRF。自动化工具 am‑i‑hacked 和 secure‑semgrep 有助于发现风险。
问题
Developers may unknowingly run malicious code generated by AI agents, risking security breaches.
结果
The workflow enables developers to identify and mitigate five common security risks introduced by AI agents before running code.
工作流
- 1. Inspect added dependencies for authenticity and history.
- 2. Review any new or modified setup commands such as curl|sh or postinstall scripts.
- 3. Examine configuration files that start processes (e.g., .vscode/tasks.json, .claude/settings.json).
- 4. Check for insecure model‑calling patterns (hardcoded keys, exec/eval usage, unbounded max_tokens).
- 5. Validate server code that fetches URLs to prevent SSRF.
- 6. Run automated scanners: npx am-i-hacked and npx secure-semgrep to detect known malicious patterns.
- 7. If scans pass, proceed to run the dev server; otherwise, investigate findings.
证据
Assistants sometimes suggest package names that don't exist, or that are one letter off a real one. Attackers register those names.
Read every script entry the agent added or changed.
Agent hooks, MCP server definitions, .claude/settings.json, .mcp.json, .vscode/tasks.json, *.config.js. All of these start processes, and none of them look like "code" in a diff review.
Hardcoded API keys. Model output passed to exec or eval. User input concatenated into a system prompt. No max_tokens.
If the agent wrote a link preview, a webhook, or an "import from URL" feature, check whether it validates where the URL points. Otherwise someone can aim your server at 169.254.169.254 and read your cloud credentials. That's SSRF.
Both exit 1 on findings, so they drop into CI.
- 记录日期: 2026-10-09T13:41:00.259Z