barry-patil/agentic-ai-security-testing

GitHub: barry-patil/agentic-ai-security-testing

面向 LLM 应用程序的自动化安全测试平台,依据 OWASP Top 10 for LLMs 2025 对大模型应用进行漏洞探测与评分。

Stars: 0 | Forks: 0

# Agentic AI 安全测试 标准的安全扫描器不知道如何处理 LLM 应用程序。它们无法测试 prompt injection、system prompt 泄露,或者一个因为被好好请求就决定给整个用户群发送电子邮件的 AI agent。该工具正是为弥补这一空白而构建的。 它针对 LLM 驱动的应用程序运行自动化安全探测,并根据 OWASP Top 10 for LLMs 2025 对其进行评分。每个 OWASP 类别都是一个独立的模块,包含精心挑选的 payload 和检测逻辑——你可以添加自己的模块或扩展现有模块。 该平台部署在 ECS Fargate 上,后端使用 FastAPI,并带有一个简单的 React 前端用于浏览结果。我构建它是为了在我们的内部 AI 工具的 CI 期间运行安全评估——在 prompt injection 问题到达生产环境之前发现它们,比事后处理它们成本要低得多。 ## 测试内容 | OWASP ID | 类别 | 我们的探测目标 | |----------|----------|-------------------| | LLM01 | Prompt Injection | 模型是否会被对抗性输入劫持? | | LLM06 | Excessive Agency | 模型在被请求时是否会执行有害操作? | | LLM07 | System Prompt Leakage | 我们能否通过巧妙的提问提取出 system prompt? | | LLM02 | 敏感信息泄露 | 模型是否会泄露训练数据或 PII? | | LLM10 | Unbounded Consumption | 我们能否通过耗尽资源的 prompt 触发 DoS? | ## 架构 ``` GitHub Actions └── trigger scan on PR FastAPI (ECS Fargate, private subnet) ├── POST /api/scan — submit a target URL for scanning ├── GET /api/results/:id — get scan results └── WebSocket /api/live — real-time progress during a scan React frontend (ECS Fargate, public subnet via ALB) └── submits scans, shows findings with severity + explanation RDS PostgreSQL └── stores scan history and results S3 └── full scan reports as JSON ``` ## 运行扫描 ``` # 针对本地 LLM API python -m src.agents.owasp_llm_scanner \ --target http://localhost:8080/api/chat \ --api-key your-key \ --output report.json # 通过 REST API curl -X POST http://your-deployment/api/scan \ -H "Content-Type: application/json" \ -d '{"target_url": "http://your-llm-app/chat", "categories": ["LLM01", "LLM07"]}' ``` ## 添加自定义 payload 每个类别模块都有一个 `payloads` 列表。添加你自己的: ``` # 在 src/payloads/custom_injection.py 中 PAYLOADS = [ "Your custom prompt injection attempt", "Another test payload", ] ``` 然后在 `src/agents/owasp_llm_scanner.py` 中将其注册到相应的类别下。 ## CI 集成 ``` # 在你的 GitHub Actions pipeline 中 - name: LLM Security Scan run: | python -m src.agents.owasp_llm_scanner \ --target ${{ secrets.STAGING_LLM_URL }} \ --fail-on-critical ``` `--fail-on-critical` 会在发现任何严重漏洞时以非零状态退出,从而阻止 PR 合并。 ## 部署 ``` cd terraform terraform init && terraform apply # 构建并推送 scanner image docker build -t llm-security-scanner . docker tag llm-security-scanner $ECR_URI/llm-security-scanner:latest docker push $ECR_URI/llm-security-scanner:latest ```
标签:AV绕过, DLL 劫持, ECS Fargate, FastAPI, LLM安全测试, LNA, OWASP Top 10, React, Syscalls, 大语言模型, 测试用例, 自动化安全评估, 请求拦截, 逆向工具