gnim81/awi-scan
GitHub: gnim81/awi-scan
awi-scan 是一款本地离线扫描工具,用于在 AI agent 运行前检测 GitHub Actions 工作流中不可信输入流向特权 agent 的注入风险。
Stars: 0 | Forks: 0
# awi-scan
[](https://github.com/gnim81/awi-scan/actions/workflows/ci.yml)
[](https://www.npmjs.com/package/awi-scan)
[](https://github.com/gnim81/awi-scan/releases)
[](LICENSE)
检测 GitHub Actions 工作流中的 Agentic Workflow Injection 风险。
当不受信任的 GitHub 文本(例如 pull request 内容或 issue 评论)被发送给以仓库权限运行的 AI coding agent 时,就会发生 Agentic Workflow Injection。`awi-scan` 会在 agent 运行之前寻找这条从源到 agent 再到权限的路径。
`awi-scan` 在本地离线运行。它不会将工作流内容发送到外部服务。

```
npx awi-scan . --format human
```
```
awi-scan: 5 finding(s) in 9 workflow file(s)
critical awi.untrusted-prompt-to-agent examples/vulnerable/pull-request-target-agent.yml:1:1
Untrusted GitHub event content can reach an AI agent running with workflow privileges.
critical awi.untrusted-checkout-to-agent examples/vulnerable/pull-request-target-checkout-agent.yml:1:1
An AI agent can run after untrusted pull request code is checked out in a privileged workflow.
high awi.untrusted-prompt-to-agent examples/vulnerable/gemini-issue-agent.yml:1:1
Untrusted GitHub event content can reach an AI agent running with workflow privileges.
```
## 示例发现
```
name: vulnerable pull request agent
on:
pull_request_target:
permissions:
contents: write
jobs:
agent:
runs-on: ubuntu-latest
steps:
- uses: anthropics/claude-code-action@v1
with:
prompt: ${{ github.event.pull_request.body }}
```
`awi-scan` 报告此问题,是因为不受信任的 pull request 文本在 工作流具有写入权限 时到达了 agent。
```
critical awi.untrusted-prompt-to-agent .github/workflows/danger.yml:10:1
Untrusted GitHub event content can reach an AI agent running with workflow privileges.
```
## 更安全的模式
在受信任的触发器上运行 agent,默认保持只读权限,并在使用不受信任的文本之前,要求设置由 maintainer 控制的批准边界。
```
on:
workflow_dispatch:
permissions:
contents: read
```
## GitHub Action
```
name: awi-scan
on: [pull_request]
permissions:
contents: read
security-events: write
jobs:
scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: gnim81/awi-scan@v0.2.0
with:
fail-on: high
```
## CLI
```
npx awi-scan --format human
npx awi-scan --format json --output awi-scan.json
npx awi-scan --format sarif --output awi-scan.sarif
npx awi-scan --fail-on critical
npx awi-scan rules
npx awi-scan explain awi.untrusted-prompt-to-agent
```
## 检测内容
- 不受信任的 issue、PR、评论、审查或讨论文本。
- 通过 `GITHUB_EVENT_PATH`、`gh`、`curl` 或 GitHub API 调用读取 Event payload。
- Agent actions 和 agent CLI 调用。
- 在 agent 执行前,不受信任的 pull request head checkouts。
- 危险的上下文,例如 `pull_request_target`、写入权限、secrets、OIDC 和 self-hosted runners。
详情请参阅 [威胁模型](docs/threat-model.md) 和 [规则](docs/rules.md)。
## 项目
- 支持的 agent 模式:[docs/agent-actions.md](docs/agent-actions.md)
- 安全的 `pull_request_target` 模式:[docs/pull-request-target.md](docs/pull-request-target.md)
- SARIF 上传:[docs/sarif-upload.md](docs/sarif-upload.md)
- 误报:[docs/false-positives.md](docs/false-positives.md)
- 安全报告:[SECURITY.md](SECURITY.md)
- 贡献指南:[CONTRIBUTING.md](CONTRIBUTING.md)
- 示例:[docs/examples.md](docs/examples.md)
## 许可证
MIT
标签:AI代理安全, CI/CD安全, DevSecOps, GitHub Actions, GNU通用公共许可证, Llama, MITM代理, Node.js, 上游代理, 暗色界面, 自动化攻击, 自动笔记, 软件开发工具包, 错误基检测, 静态代码分析