calbebop/batesian
GitHub: calbebop/batesian
针对 MCP 和 A2A 等 AI Agent 协议栈进行对抗性安全测试的命令行工具,帮助发现协议实现中的漏洞与安全缺陷。
Stars: 0 | Forks: 0
# Batesian
[](LICENSE)
[](https://golang.org)
[](https://github.com/calbebop/batesian/actions)
用于对 [A2A](https://google.github.io/A2A/) 和 [MCP](https://modelcontextprotocol.io) 协议栈进行对抗性测试的 CLI 工具。它会驱动实际的协议流量(OAuth、回调、JWS、会话边界、工具及元数据处理),并将结果记录为 `confirmed` 或 `indicator`,可选生成用于 CI 的 SARIF 报告。

## 内置内容
捆绑规则:18 条 A2A,17 条 MCP(共 35 条)。每条规则均映射到 CWE 风格的引用和目录中的修复建议:
- [A2A 规则](docs/rules-a2a.md)
- [MCP 规则](docs/rules-mcp.md)
## 快速开始
```
go install github.com/calbebop/batesian/cmd/batesian@latest
batesian probe --target https://agent.example.com --protocol a2a
batesian scan --target https://agent.example.com --output sarif > results.sarif
batesian scan --target https://agent.example.com --rule-ids a2a-push-ssrf-001,mcp-tool-poison-001
batesian scan --target https://mcp.example.com --token "$TOKEN"
batesian scan --target https://mcp.example.com \
--token-url https://auth.example.com/oauth/token \
--client-id my-client \
--client-secret "$CLIENT_SECRET" \
--oauth-scopes mcp:read,mcp:write
batesian scan --target https://mcp.example.com \
--auth-url https://auth.example.com/authorize \
--token-url https://auth.example.com/oauth/token \
--client-id my-client \
--oauth-scopes mcp:read
batesian init
```
`probe` 用于侦察(表格或 JSON 格式输出)。它不会生成 SARIF。有关标志、过滤器、配置文件、OAuth 和额外规则路径的信息,请运行:`batesian scan --help`。
## 规则包
规则采用 YAML 格式。新的检查可以在不重新编译二进制文件的情况下发布。有关规则的编写、Schema 结构和审查要求,请参阅 [CONTRIBUTING.md](CONTRIBUTING.md)。
## Python SDK
版本 **0.3.0**(详见 `sdk/python/pyproject.toml`)。该 SDK 通过调用相同的 `batesian` 二进制文件(由 `BATESIAN_BIN` 指定或在 PATH 中)来执行。
```
from batesian import Scanner
scanner = Scanner(target="https://agent.example.com")
results = scanner.run(rules=["a2a-push-ssrf-001", "mcp-tool-poison-001"])
for finding in results.findings:
print(f"[{finding.severity}] {finding.rule_id}: {finding.title}")
assert results.critical_count == 0
```
安装与 CI 使用模式详见:[`sdk/python/`](sdk/python/)。
## 构建与测试
```
make build
make test
```
或者运行:`go build -o bin/batesian ./cmd/batesian` 和 `go test -race ./...`。
## 参与贡献
欢迎在 [Apache 2.0](LICENSE) 协议下提交规则和代码。详情请参阅 [CONTRIBUTING.md](CONTRIBUTING.md)。有关测试的漏洞固件和端口配置,请参见 [`testdata/README.md`](testdata/README.md)。
## 参考文献
- [A2A 协议规范](https://google.github.io/A2A/)
- [MCP 授权规范](https://modelcontextprotocol.io/specification/2025-11-25/basic/authorization)
- [MCP 安全最佳实践](https://modelcontextprotocol.io/docs/tutorials/security/authorization)
- [Unit 42:A2A 系统中的 Agent 会话走私](https://unit42.paloaltonetworks.com/agent-session-smuggling-in-agent2agent-systems/)
- [OWASP GenAI 安全项目](https://genai.owasp.org)
## 许可证
Apache 2.0。详见 [LICENSE](LICENSE)。
标签:A2A协议, API安全, CISA项目, EVTX分析, Go语言, IP 地址批量处理, JSON输出, MCP协议, OAuth, SARIF, SSRF, Web安全, Web报告查看器, 协议安全, 反取证, 安全评估, 对抗性测试, 工具投毒, 日志审计, 智能体协议, 程序破解, 蓝队分析, 逆向工具