🔎 动态应用程序安全测试 (DAST) 工具

向运行中的 API 发送请求以检测漏洞的工具。

Burp Suite 商业版/免费版可用

网络应用程序和 API 安全测试的行业标准工具。基于代理的拦截和扫描功能。

  • 拦截和修改 HTTP 请求/响应
  • 自动扫描(SQL 注入、XSS 等)
  • 入侵者参数模糊
  • 中继器:手动请求重放和验证
  • 丰富的扩展生态系统(BApp Store)
应用程序接口测试技巧

导入 OpenAPI/Swagger 定义,自动抓取和测试所有端点。

OWASP ZAP 免费/开放源码软件

由 OWASP 开发的开源安全测试工具。易于集成到 CI/CD 管道中。

  • 主动扫描/被动扫描
  • 导入 API 定义(OpenAPI、GraphQL)
  • CI/CD 集成(GitHub Actions、Jenkins)
  • 支持 Docker 的无头执行
  • 通过脚本进行自定义测试
Bash使用 ZAP Docker 进行 API 扫描
docker run -t ghcr.io/zaproxy/zaproxy:stable zap-api-scan.py \
  -t https://api.example.com/openapi.json \
  -f openapi \
  -r report.html

🧪 API 测试和开发工具

邮递员免费/商业

API 开发和测试的首选工具。也可用于安全测试。

  • 使用 "集合 "功能组织测试用例
  • 使用环境变量在试运行/生产阶段之间切换
  • 使用预请求脚本自动获取令牌
  • 在 "测试 "选项卡中自动进行响应验证
  • 使用纽曼(CLI)从 CI/CD 运行
JavaScriptPostman 测试脚本示例
// 状态代码验证
pm.test("Status is 200", () => {
  pm.response.to.have.status(200);
});

// 安全头验证
pm.test("Security headers present", () => {
  pm.response.to.have.header("X-Content-Type-Options");
  pm.response.to.have.header("Strict-Transport-Security");
});

// 检查是否暴露了敏感数据
pm.test("No sensitive data exposed", () => {
  const body = pm.response.json();
  pm.expect(body).to.not.have.property("password");
  pm.expect(body).to.not.have.property("password_hash");
  pm.expect(body).to.not.have.property("secret");
});

curl + jq 免费 / CLI

从命令行快速进行 API 测试。易于编写脚本并实现自动化。

  • 适用于任何环境
  • 使用 shell 脚本实现自动化
  • 使用 jq 解析 JSON 响应
  • 详细的 HTTP 标头检查
Bash安全头检查
# 检查响应标头
curl -s -D - -o /dev/null https://api.example.com/health

# 尝试未经身份验证的访问
curl -s -w "%{http_code}" https://api.example.com/api/users

# BOLA 测试(访问其他用户的资源)
curl -s -H "Authorization: Bearer $TOKEN" \
  https://api.example.com/api/users/OTHER_USER_ID

📊 静态分析 (SAST) 和软件构成分析 (SCA)

Semgrep 免费/开放源码软件

基于模式的静态分析工具可轻松创建自定义规则。

  • 多语言支持(JS、Python、Go、Java 等)
  • 内置安全规则集
  • 轻松集成 CI/CD
  • 在 YAML 中定义自定义规则

Snyk 提供免费层级

依赖性漏洞扫描和代码分析。

  • 对 npm、pip、Maven 等进行依赖扫描。
  • 自动检测已知 CVE
  • 自动生成修复 PR
  • 集装箱图像扫描

npm audit / Trivy 免费

软件包管理器和容器的漏洞检查。

  • <代码>npm 审计:Node.js 软件包
  • <代码>pip 审计:Python 软件包
  • 特里维容器、IaC 和文件系统
  • CI/CD 门控的理想选择
Bash依赖性漏洞检查
# 检查 Node.js 依赖项
npm audit --production

# 使用 Semgrep 进行安全扫描
semgrep --config=p/security-audit ./src

# 使用 Trivy 进行容器扫描
trivy image --severity HIGH,CRITICAL myapp:latest

📝 应用程序接口规范和文档管理

Swagger / OpenAPI 标准规范

以机器可读格式定义 API 规范。也可用作安全测试的输入。

  • 全面定义端点、参数和响应
  • 明确的安全方案(OAuth、API Key 等)
  • 导入 ZAP/Burp 以自动测试
  • 利用 Swagger UI 生成交互式文档

Spectral 免费/开放源码软件

OpenAPI 规范的筛选器工具。检查是否符合安全最佳实践。

  • 检查是否存在安全方案定义
  • 检测未经身份验证的端点
  • 利用自定义规则执行内部政策
  • 在 CI/CD 中对 API 规范进行质量把关

📡 监控和日志工具

应用程序接口网关

Kong、AWS API Gateway、Apigee 等。

  • 集中认证和授权
  • 限速执行
  • 请求日志汇总
  • 异常检测警报

WAF

AWS WAF、Cloudflare、ModSecurity 等。

  • 阻止 SQLi/XSS 等攻击模式
  • 基于 GeoIP 的访问控制
  • 僵尸缓解
  • 自定义规则定义

SIEM / 日志分析

ELK Stack、Splunk、Datadog 等。

  • 应用程序接口日志汇总和可视化
  • 异常模式检测
  • 事件响应支持
  • 合规审计

🤖 AI Security Testing Tools

Specialized tools for testing and securing LLMs, AI agents, and ML pipelines.

Garak Free / OSS

LLM vulnerability scanner that probes for prompt injection, data leakage, hallucination, and other LLM-specific weaknesses.

  • Automated prompt injection and jailbreak testing
  • Data leakage and memorization detection
  • Plugin-based architecture for custom probes
  • Supports OpenAI, Hugging Face, and local models
BashLLM Vulnerability Scan with Garak
# Install garak
pip install garak

# Run prompt injection probes against an OpenAI model
garak --model_type openai --model_name gpt-4 \
  --probes promptinject

# Run all probes and generate report
garak --model_type openai --model_name gpt-4 \
  --probes all --report_prefix my_audit
OWASP Reference

Addresses: LLM01: Prompt Injection, LLM06: Excessive Agency

Rebuff Free / OSS

Prompt injection detection framework with multi-layer defense: heuristics, LLM-based analysis, and vector similarity.

  • Multi-layered detection (heuristic + AI + vector DB)
  • Canary token injection for leak detection
  • Easy integration as middleware
  • Configurable sensitivity thresholds
OWASP Reference

Addresses: LLM01: Prompt Injection

NeMo Guardrails Free / OSS (NVIDIA)

Runtime guardrails framework for LLM applications. Define conversation boundaries using Colang rules.

  • Topic boundary enforcement (prevent off-topic responses)
  • Fact-checking and hallucination reduction rails
  • Sensitive data detection and PII redaction
  • Moderation and toxicity filtering

PyRIT Free / OSS (Microsoft)

Python Risk Identification Tool for generative AI. Automates red-teaming with multi-turn attack strategies.

  • Automated multi-turn red-teaming conversations
  • Attack strategy orchestration (crescendo, PAIR, etc.)
  • Scoring engine for response evaluation
  • Supports Azure OpenAI, Hugging Face, and local models

🗺 工具选择指南

目的推荐工具时间安排
API 规范安全检查Spectral设计/规格阶段
代码安全分析Semgrep开发/公关
依赖性漏洞检查Snyk / npm audit构建时间/周期性
人工安全测试Burp Suite / Postman测试/质量保证阶段
自动扫描(CI/CD)OWASP ZAP部署前
保护生产环境WAF + API Gateway运行中
日志监控和异常检测SIEM (ELK / Datadog)运行中 / 持续
LLM vulnerability scanningGarak / PyRITPre-deployment / Periodic
Prompt injection detectionRebuffRuntime / Integration
LLM runtime guardrailsNeMo GuardrailsRuntime / Continuous
AI red-teaming automationPyRITTesting / QA phase
AI model supply chain verificationSemgrep / ModelScanBuild time / Pre-deployment