SuperAPI AI 工具集

api-security-schemathesis

安全与审计

查看项目

更新于 10-16 05:32

技能介绍

用途

该技能面向安全工程师,用于运行基于属性的 API 安全测试。它使用 Schemathesis 从 API 模式(OpenAPI/Swagger 或 GraphQL)自动生成测试用例,以发现崩溃、500 错误和规范违规等问题。

何时使用

当被要求使用 OpenAPI/Swagger 或 GraphQL 模式测试 REST API 或 GraphQL 端点的安全问题时,使用此技能。

前置条件

  • 已安装 Schemathesis(pip install schemathesis)
  • API 必须正在运行,并具有可访问的 OpenAPI 规范或 GraphQL 端点
  • 验证:schemathesis --version

使用方式

  1. 确定目标 — 确认 API 模式 URL 和基础 URL。

  2. 运行扫描:

OpenAPI:

schemathesis run <openapi-url> --report > schemathesis-report.txt

GraphQL:

schemathesis run <graphql-url> --report

带认证:schemathesis run <url> --auth user:pass

Bearer 令牌:schemathesis run <url> --header "Authorization: Bearer <token>"

指定端点:schemathesis run <url> --endpoint "/api/users"

有状态测试:schemathesis run <url> --stateful=links

  1. 解析结果 — 以表格形式呈现发现:
# Endpoint Method Issue Type Status Code Finding Reproduction
  1. 汇总 — 提供:
  • 测试的端点总数和生成的测试用例数
  • 发现的服务端错误(5xx)及复现步骤
  • 模式违规和不一致
  • 安全相关发现(认证绕过、注入成功等)

检测的问题类型

类型 描述
Server Error (5xx) 未处理的异常 / 崩溃
Schema Violation 响应与模式不匹配
Status Code Mismatch 未记录的响应代码
Content Type Mismatch 返回了错误的内容类型
Missing Auth 无需凭据即可访问的端点
Injection Patterns 通过模糊输入进行 SQL/NoSQL 注入

适用场景

适用于对 REST API 或 GraphQL 端点进行安全测试,尤其是需要基于模式自动生成测试用例、发现服务端错误、模式违规及安全相关问题的场景。

限制

资料中未提供关于收费、价格、平台支持范围、测试效果保证等方面的信息,暂未提供。