--- name: hunt-api description: API security — BOLA/IDOR, mass assignment, rate limit bypass, auth bypass, method confusion. Must pass 7 gates. --- # API HUNTING — 3 BULLETS MAX **Core:** APIs are the #1 attack surface. Test systematically. ## DIFFERENTIAL ```bash # BOLA: User A → User B's resource curl -s -H "Authorization: Bearer $TOKEN_A" "https://target.com/api/users/$VICTIM_ID" # Mass assignment curl -s -X POST -H "Authorization: Bearer $TOKEN" -d '{"name":"test","role":"admin","balance":999999}' "https://target.com/api/users" # Rate limit bypass curl -s -H "X-Forwarded-For: 1.1.1.1" "https://target.com/api/login" # Method confusion for m in GET POST PUT DELETE PATCH OPTIONS HEAD TRACE; do curl -s -o /dev/null -w "$m: %{http_code}\n" -X $m "https://target.com/api/users/$ID" done ``` ## ATTACKS ``` BOLA: sequential IDs, UUIDs from other endpoints, GraphQL aliases Mass assignment: role, is_admin, balance, tenant_id, verified Rate limit: X-Forwarded-For, method change, content-type change, parameter position Auth bypass: empty token, invalid token, JWT none, expired token Version: /v1 vs /v2 vs /internal vs /debug GraphQL: batching (rate limit bypass), alias IDOR, nested query DoS, mutation auth bypass ``` ## CHAINS ``` BOLA + mass assignment → admin takeover → Critical Auth bypass + BOLA → mass data exfil → Critical Rate limit bypass + OTP brute → ATO → High GraphQL batching + IDOR → mass PII → Critical Race condition + wallet → double-spend → Critical ``` ## DISCOVERY — THE API YOU CANNOT SEE IN THE UI Documented endpoints are the tested endpoints. Value hides in the rest: ``` JS bundles → grep bundles for /api/, fetch(, baseURL, route tables; sourcemaps (.js.map) hand you the source-level route list OpenAPI/Swagger → /openapi.json /swagger.json /v3/api-docs — diff spec vs reality: spec-only endpoints are untested endpoints GraphQL → introspection on AND off per environment; field suggestions leak schema with introspection disabled History → wayback/gau corpora: dead routes, old versions, debug params the UI never sends Mobile/desktop → app binaries call APIs the web UI does not; pinned clients keep OLD endpoints alive Error oracles → 404 vs 405 vs 401: nonexistent / exists / needs auth — map with all three ``` ## VERSIONING DIFFERENTIALS Every fix lands on the current version first — sometimes only there. ``` For each sensitive operation, replay it across: /v1 /v2 /v3, unversioned, /internal, /beta, /legacy, and the mobile-pinned version. Diff: auth checks, field filtering, rate limits, response fields. Classic: v2 enforces ownership, v1 only authentication → same id, one 403, one 200 = the finding. ``` Also diff *within* a version: trailing slash, `.json` suffix, case changes, double slashes — these route through different middleware stacks, and an auth filter bound to a path pattern may simply not match. ## MASS ASSIGNMENT — GO DEEPER THAN role=admin ``` 1. Harvest field names: registration responses, profile GETs, admin-shaped objects in JS, field-echoing error messages, OpenAPI schemas 2. Probe per-object, not globally: role, is_admin, verified, tenant_id, org_id, plan, credits, price, discount, status, approved, owner_id, created_at, deleted_at, internal flags (is_test, is_staff) 3. Encodings: nested objects {"profile":{"role":"admin"}}, dot keys, duplicate keys (first-wins vs last-wins parsers), type juggling ("true" vs true vs 1), arrays for scalars 4. Confirm by RE-READING the object from a clean GET — a 200 on the write that silently dropped the field is the #1 false positive here ``` Blind spot: update endpoints (PATCH) often accept fields the create endpoint rejects — they bind the full model. Test both, plus nested objects. ## BOPLA / BFLA — PROPERTY AND FUNCTION LEVEL BOLA asks "may I see THEIR object." Two siblings get skipped: ``` BOPLA (property): the object is mine, the RESPONSE is the bug — GET returns password_hash, reset tokens, internal notes, other tenants' metadata. Diff response fields per role: the admin shape of the SAME endpoint is the spec of what should be filtered. BFLA (function): the endpoint itself is above my role — replay admin FUNCTIONS with a low-role token, method by method: export, bulk-delete, impersonate, approve, refund, invite-admin. A hidden button is not a check; GET may be allowed for support while DELETE on the same route was forgotten. ``` ## CONTENT-TYPE PARSER DIFFERENTIALS One endpoint, several parsers — each with its own validation path: ``` application/json → the path everyone tests application/xml → XXE + parser-specific field handling application/x-www-form-urlencoded → type coercion differs (all strings) multipart/form-data → file fields + text fields bound differently text/plain / no header → CSRF-able writes if auth is cookie-based and the body still parses Charset/encoding tricks → duplicate JSON keys, lenient parser in front of a strict one (comments, trailing commas) ``` Signal: same payload, different content type, different outcome (field accepted, auth skipped, error class changes). That delta is a parser seam — work it. ## BATCHING AND AGGREGATION ABUSE ``` GraphQL aliases / REST batch endpoints: N operations, one HTTP request — rate limits, OTP attempts, and authz often count the REQUEST, not the operations. Array parameters: ids[]=1..500 turns a single-object BOLA check into a bulk export if the handler loops without re-checking ownership per item. Confirm per-item authz on your two test accounts first. ``` ## RATE LIMIT AND PAGINATION ABUSE Rate limits: identify the KEY first — per IP, account, endpoint, token? Rotate exactly one input (XFF, path case, trailing slash, method). A limit reset by any cosmetic change is keyed wrong; prove it on a login/OTP endpoint, not a search box. Pagination: `limit=-1`, `limit=999999`, missing limit, `page=0`, cursor tampering. Consequences that matter: full-table export through a "list" endpoint (pairs with BOPLA), and cursors leaking other tenants' ids. ## DEPRECATED ENDPOINT RESURRECTION Old endpoints rarely die; they lose their middleware. Sources: wayback captures, old mobile builds, previous deploys' JS, old spec paths. Replay the deprecated route with CURRENT tokens: missing auth, missing rate limit, and pre-fix behaviour of patched bugs all resurface here. A route 404ing on GET but answering POST is alive. ## FALSE-POSITIVE TRAPS - Mass assignment "accepted" but never persisted: always re-read. - BOLA where the "victim" object is intentionally public/shared: check the object's sharing state before claiming cross-user access. - Introspection enabled on a public-schema API: finding is what the schema exposes beyond the public surface, not introspection itself. - Version differential where v1 is documented/supported with the same controls: the diff must show a missing CONTROL, not just a version. ## ESCALATION LADDER ``` Single-object BOLA (own two accounts) (finding) → enumeration + bulk/batch extraction (High) → BOPLA/BFLA reaches admin function (High) → mass assignment or authz chain → ATO (Critical) ``` ## REPORTING CHECKLIST - [ ] Both test accounts' requests shown; victim object owned by account B - [ ] Mass assignment proven by clean re-read, not the write response - [ ] Version/method/content-type diff table for the claimed differential - [ ] Rate-limit key identified; bypass shown on a consequential endpoint - [ ] Deprecated route evidence: where it was found, why it is still live - [ ] Impact counted in records/users reachable, not requests sent