# API Access Control Audit

> Use when auditing an API for broken authz/binding — per-sibling-verb gaps, tenant-shared stores.

- Skill: `yufeifeio/api-access-control-audit` (Agent Skill, multi-file: 5 files)
- Install (CLI): `npx get-skill add yufeifeio/api-access-control-audit`
- Raw SKILL.md: https://api.skillmd.com/api/skills/yufeifeio/api-access-control-audit/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Security
- Author: Yufeifeio (https://skillmd.com/u/yufeifeio)
- Updated: 2026-11-22
- Page: https://skillmd.com/skills/yufeifeio/api-access-control-audit

---


# API Access-Control Audit

Auditing an HTTP API (FastAPI/DRF/Express/Spring) for broken authorization: endpoints that write, bind, mint, or read someone else's record with no credential. Complements — do not replace — the engagement's broad attack surface; on any target with an `openapi.json` this is usually the cheapest path to a real finding.

## Always-on rules

1. **Spec first.** `GET /openapi.json`, `/openapi.yaml`, `/v3/api-docs`, `/swagger.json`, `/swagger-ui/index.html`, `/docs`. The spec hands you every path *and* the request schemas, so field names stop being guesses. Blind field guessing is how rounds get burned: a wrong name returns `422` or a generic "not found" that looks like an empty collection.
2. **Classify every endpoint by observed enforcement, not by its name.** Hit each one with no credential and an empty/minimal body and record: `401/403` = enforced, `200`/`422`/`4xx-with-detail` = unenforced and worth crafting a real body for. An endpoint named `admin` or `addslave` is not authenticated until you have proven it is.
3. **The four flaw classes, in this order, on every unenforced endpoint:**
   - **write without auth** — create/register/bind/import/claim/assign paths that mutate state for an arbitrary identity;
   - **signature not verified** — put garbage in the signature field (`signedMessage`, `signature`, `userSignature`, `checkMessage`) and in the token field. A success message means the check is absent or trivially bypassable;
   - **identity swap (IDOR)** — re-send the same request with the identity field replaced by a real third party (`userAddress`, `userId`, `owner`, `email`, `accountId`, `master`). Copy the field names from the spec. **A list endpoint that re-applies token scope does NOT imply its detail endpoint does — test each independently.** The one that takes a bare numeric object ID (`id`/`batchId`/`orderId`/`phoneId`) and returns another owner's row is the biggest finding on most platforms, and the record it returns usually embeds the *entire* dataset behind that object: recipient/target lists, message bodies, device/SIM identifiers, and the owner plus upstream-reseller IDs. **Dump the full key tree of the returned row before judging its value** — ORM relations are routinely serialized unpruned, so a row that *looks* like `uid/number/balance` can carry a nested `user`/`member` object with the owner's plaintext phone, real name, national ID, password hashes, registration/last IPs, invite code and upline. That turns a per-ID ledger/dividend endpoint into a **full-population PII oracle at one request per ID**, which is a far better walk than any admin list. Expand recursively on your own row first (`walk(row)` over `list[0]`), then find the twin endpoint of the same table as a fallback channel. Fetch your own objects first to learn the ID base and confirm the object shape, then **probe the boundaries of the ID space before committing to a walk** — sample low/mid/high values to bracket the smallest and largest valid ID. A valid range that begins *above* your first hit means the table was reset or rolls, and a hard upper bound plus your hit count hands you the retention window (e.g. ~50k rows spanning the last 8 days) — that number belongs in the report, because it defines how much of the platform's history is actually recoverable. Then walk it as **resumable ranges**: append each record as one JSON line to an ndjson, print a running `done/ok/miss/rate/eta` line, and chain the next range to start when the current process exits, so a multi-hour dump survives a dropped connection or an expired session;
   - **minted-token consumption** — whatever token an endpoint returns, replay it as `Authorization: Bearer <t>`, `X-Token`, `token`, `X-Auth-Token`, and as a cookie against every *other* collection endpoint before calling it inert;
   - **input checks ordered before the auth filter (method / parameter validation)** — an endpoint that answers `unsupported request method: POST` or `missing parameter: <name>` to an *unauthenticated or role-failing* caller has already entered its handler: the framework ran argument binding before the authorization interceptor, so the request never reached the auth gate. Both responses are **bypass signals, not dead ends**. Convert to the verb it names, then supply the parameters it names (each round names the next one) and re-read the response. The **export/download family is the highest-payoff instance** — `.../export`, `/bill/exportProxy`-style handlers routinely also skip the account-existence lookup their `list` sibling performs, so a token whose account row is gone still returns files. Prove a real workbook, not a stub shell: `Content-Type: application/vnd.ms-excel` **and** body magic `PK\x03\x04`, and say what the exported rows actually contain (operator/billing statistics = data exfiltration, not "an export endpoint exists"). **The handler's `Content-Type` may lie — score the hit on the body magic, not the header:** a misconfigured export answered `Content-Type: application/json` while the body was a real workbook, and that header/body mismatch is itself the tell that the request skipped the export filter chain — which is usually where the auth interceptor lives. Decode the sheet and state the reach in numbers (one worksheet returned the whole platform's per-operator card counts and send totals — ~84k cards / 60M+ sends — to a single client-role token). On Chinese Spring-Boot admin panels `400`/`402` is the signature of this class and `401 未授权` is the only response that means the gate held. **Classify the bypass by comparing with and without a token** — same endpoint, same empty body: `401` both ways = real gate, drop it; `402 缺少参数` **with** a low-privilege token but a realm/session denial (`scode:2`) **without** one = the endpoint checks that a session exists and **never checks the role**, so every authenticated low-privilege account can write that admin resource (persistent poison, not "unauthorized access" — name it correctly in the report); `400 不支持的请求方式` in reply to a GET leaks only "route exists + correct verb" and is never itself a finding.
4. **Bind/assign endpoints get tested with the biggest real holder's identity.** `{master: <whale address>, slave: <ours>}` (or the equivalent owner/child field pair) returning `{"message":"ok"}` is a first-class auth-bypass finding even when the follow-on capability is unknown.
5. **Never inflate a binding into fund access.** Endpoints taking a *client-signed* payload (`signedSerializedTx`, raw signed tx/serialized blob) are relays, not key oracles. Being bound, registered, or authorized server-side does not move funds that live on-chain — the holder's private key is still the missing leg. Report "unauthorized binding/authorization bypass, execution capability unproven".
6. **"Item not found" is not an auth wall.** Address/user-keyed lookups usually answer `404 {"detail":"Item not found"}` for identities with no record — that is an empty collection. Do not read it as "requires privilege" and do not stop testing the write-side endpoints because of it.
7. **Credential spraying is the last resort, not the main line.** This user's engagements expect logic, authorization, and binding flaws first; a default-password sweep is a small side probe (a handful of pairs), never the headline.
8. **Verdict first when reporting.** Lead with 打穿/没打穿 (compromised or not) and the single best finding, then evidence. No process narration, no mid-task summary dump; keep attacking until the user says stop.
9. **Bulk-enumerate at the rate the target tolerates — the throttle caps total yield, so hammering only spends the account.** Measured on a rate-limited platform: ~8 req/s gave a 73% hit rate, ~78 req/s gave ~8% — the same ~6 valid rows/s either way, but the fast run risks a ban and returns a mostly-empty dataset. When failures appear mid-run, compare against an endpoint that answered minutes earlier: an error code that *looks* like an authz/session denial, reappearing on endpoints that just succeeded, is throttling, not a ban — pause, re-call one of them, and confirm a lightweight status endpoint still answers success to rule out a token block. Back off and retry on that code instead of restarting the session, and print a running `ok/miss/rate` line so the shift is visible. **The same trap produces fake *authorization walls*:** a denial string (`access restricted`, `forbidden`) that a counted-out source IP receives is indistinguishable from a permission decision until you control for it — re-send the identical request from a clean source IP, and again later; a verdict that flips (denial → `invalid credentials`, or → a normal page) is a counter bucket, not an authz gate. Rate keys live on the **TCP peer IP**, so `X-Forwarded-For` / `X-Real-IP` never bypass it; only source-IP rotation (with quota shared across devices) or waiting does.
    - **Calibrate the limit; never inherit one — the bucket is keyed on (TCP peer IP, hostname).** A throttle measured on one hostname says nothing about a sibling hostname serving the same backend: brand/canonical/second-level domains of one platform usually hold *separate* buckets, and the App/API host is often far more tolerant than the H5 or admin host. Ramp the worker count by **doubling** and read the hit rate at every step. On an unthrottled API this ladder held 99%+ up to 160 workers / **242 req/s** with no backoff, while a stale belief in a ~1-2 req/s per-IP limit had been pacing the same harvest at 33 req/s — a tenfold waste that only exists on paper. Symmetric rule: keep doubling while the hit rate holds, back off the instant it collapses (that is the 73%→8% case above). Print the ladder in the report; sustained throughput is a capability statement about the target.
    - Recipe and run-hygiene rules (ramp ladder, resumable queue, completion-watcher trap, self-kill-safe process cleanup): `references/harvest-throughput-and-run-hygiene.md`.

## 全文导航（已拆分）

主卡保留 Always-on rules 第 1–9 条；Procedure、Pitfalls 在 `references/full.md`：

- Procedure
- Pitfalls

- Always-on rules（续：第 10–15 条）— `references/always-on-rules-2.md`

加载：`skill_view(name='api-access-control-audit', file_path='references/full.md')`

