API Security

API security covers the flaws that appear when business logic and data are exposed as machine-callable endpoints: the client is not a security boundary, so every authentication, authorization, validation and throttling decision has to be made server-side, per request, per object, per property and per function.

What it is

  • Root cause: the server trusts what the client chose to send. Field filtering, rate limits, role gating and “this button isn’t shown to normal users” all live in the SPA or mobile app, and calling the endpoint directly skips them. A hidden admin button is not a blocked admin endpoint (Bir Hacker Gibi Düşünmek #21).
  • The trust boundary that breaks is the subject-to-resource decision. Most teams authorize the route (valid token, right role) and then hand the handler an object ID nobody checks. Order.find(params[:id]) returns any row; scoping to the caller is opt-in, and every new endpoint is a new chance to skip it (agentoffense).
  • OWASP splits access control by granularity (OWASP API Security Top 10): object (BOLA in APIs, API1), property (Mass Assignment + Excessive Data Exposure = BOPLA, API3) and function (Function Level Authorization, API5). A role check (“is this user an editor?”) is constantly mistaken for an object check (“may this editor edit document 4411?”) (agentoffense).
  • The bug is a valid request answered with 200 OK. No payload, no error, nothing for a WAF or signature scanner to match (The 200 OK…).

Why it matters

Scale and exploitability.

  • Wallarm 2026 ThreatStats: 11,053 of 67,058 published bulletins in 2025 (17%) were API-related, as were 106 of 245 new CISA KEVs (43%). 97% of API vulns are exploitable with a single request, 98% are rated easy or trivial, and 59% need no authentication (Wallarm).
  • 42crunch’s “State of API Security 2026” (200 incidents, 2024–25) found Missing Authentication the most frequent API vulnerability of 2025 (arXiv 3015).

Agents widen the blind spot.

  • Salt 1H 2026: 48.9% of organizations can’t see machine-to-machine traffic; 48.3% can’t tell legitimate AI agents from malicious bots (Salt).
  • Postman survey (~9,000 respondents): a quarter run agents against their APIs in production, but only 13.2% say their APIs are agent-ready. ~3 in 10 let agents reuse ordinary API-client credentials, so there is no separate identity to revoke; fewer than a quarter inventory or monitor agents, and 9% have a retirement process. API-first shops share credentials more (43.2% vs 23.0%) (Help Net Security). See AI Agent Authorization, MCP Security.

Impact ladder (what a single class typically yields):

RungTypical API path
Enumeration / existence oracleMixed 403/404 across sibling routes; pre-auth lookups resolving email → user ID
Bulk PII readBOLA in APIs on sequential IDs; Excessive Data Exposure in list endpoints
Session/OTP/token leakTokens, OTPs or session values serialized into responses → Account Takeover
Write / state changeBOLA on PUT/PATCH/DELETE; Mass Assignment of role, price, status
Privilege escalationFunction Level Authorization on admin routes; isAdmin:true
Cross-tenant / platformMulti-Tenant Isolation failures, API Gateway Security flaws, Backend-as-a-Service Data Exposure
Internal networkServer-Side Parameter Pollution and Server-Side Request Forgery (API7)

Severity drivers. Authenticated-but-legitimate-looking requests, object counts reachable, whether writes or deletes work, and data class. A cross-tenant read+write BOLA scores CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N = 8.1; map to CWE-639, plus CWE-862 (no check) or CWE-863 (wrong check) (agentoffense). In finance/KYC flows, a missing ownership check on a draft that the spec says holds identity scans is High even when proven on an empty test object (SiteGuarding).

How it works

The 2023 Top 10 is the working taxonomy (OWASP API Security Top 10). The mechanisms that matter in practice:

Object level — BOLA in APIs (API1). The endpoint takes a client-supplied ID and never checks ownership. Variants:

  • Foreign IDs in the body. The URL object is checked, but a second ID in the JSON body is only checked for existence. PATCH /documents/d-123 {"project_id":"p-999"} attaches account B’s project to A’s document, and the response embeds B’s project with owner_email. Laravel exists:projects,id, plain foreign keys and even Postgres RLS (integrity checks bypass RLS) all let the link through (jrobineau).
  • Path ID authorized, body ID acted on; nested routes that check orgId then load fileId globally; batch endpoints that authorize the envelope or first element only (agentoffense). See Second-Order and Multi-Step IDOR.
  • Microservice trust gaps. The gateway authenticates, the downstream service trusts a caller-supplied X-Tenant-Id (agentoffense). See Multi-Tenant Isolation.

Property level — BOPLA (API3). One root cause, two directions (Palo Alto):

  • Write: Mass Assignment. user.update(request.json) binds role, isAdmin, credit, pid. Yii/Craft setAttributes($params, false) disables the safe-attribute filter.
  • Read: Excessive Data Exposure. res.json(user) ships email_verification_token, is_admin, OTPs; the UI just doesn’t render them.

Function level — Function Level Authorization (API5). Admin and internal functions reachable by low-privilege or anonymous callers, often because one handler sits outside the decorator/AOP that protects its siblings, or because the HTTP method differs.

Authentication (API2). Token validation, expiry and revocation; JWT none/weak keys (JSON Web Tokens); unthrottled login/OTP/reset. Framework defaults can ship unauthenticated controllers: Rails’ ActiveStorage::DirectUploadsController has only protect_from_forgery, and Rails itself warns all Active Storage controllers are public by default (InfoSec Write-ups). Cloud identity can also hand out anonymous access: a Cognito identity pool with guest identities maps every visitor to the unauthenticated IAM role, and IAM-mode AppSync only asks “may this principal call appsync:GraphQL”, never “whose data is this” (Exaforce).

Resource consumption (API4) and business flows (API6). Limiters keyed to client-controlled values, counting HTTP requests instead of operations, plus single expensive requests (page_size=20000 against a learned 250). See API Rate Limiting, GraphQL Batching Attacks (Salt API4).

Server-built requests (API7, API10). User input concatenated into internal API calls (Server-Side Parameter Pollution) or URLs the server fetches (Server-Side Request Forgery, Webhook SSRF).

Inventory (API9). Shadow, orphaned and zombie versions without the fixes /v2 received (API Discovery).

Plumbing. Gateways with exposed admin planes, coarse authorizer caches and CL/TE disagreements with the backend (API Gateway Security); BaaS backends where the publishable key is the API and RLS/rules are the only authz (Backend-as-a-Service Data Exposure); GraphQL resolvers that authorize one path to an object but not the others (GraphQL Authorization Flaws, GraphQL Security).

Leaked keys. API keys and tokens hardcoded in source, public repos, Docker images, logs and config files (.env, config.json, .aws/credentials) (PayloadsAllTheThings). See Hardcoded Secrets, Leaked Cloud Credentials.

Management endpoints. Spring Boot Actuator exposes only /health over HTTP by default, secures the rest when Spring Security is present, and masks /env and /configprops values as ******; one property or bean disables each default (e.g. show-values), and none of the switches looks dangerous alone. A secret injected as an environment variable is also inherited by child processes and readable from /proc/<pid>/environ (Actuator; Hardcoded Secrets).

Where to find it

  • ID-bearing locations, all of them: path segment, query, JSON body, form/multipart fields, X-User-Id/X-Tenant-Id headers, cookies, GraphQL variables and inline args, batch array elements (agentoffense).
  • Read-shaped POSTs and writes: CSV/XLSX export, PDF/invoice rendering, report generation, share-link creation, thumbnails, search; PUT/PATCH/DELETE matter more than GET (agentoffense).
  • Writes with foreign keys: “move to project”, “assign to”, “attach to” fields in PUT/PATCH bodies (jrobineau).
  • Profile update, registration, admin edit-user, bulk update, GraphQL mutations for mass assignment (Mass Assignment).
  • Auth, OTP, reset, signup, SMS-send, search and export endpoints for throttling: POST /api/v1/login, /register, /auth/forgot-password, /send-sms, GET /search (Sütlü Kader).
  • Backend-for-frontend proxies that place a user value into an internal path (Server-Side Parameter Pollution).
  • Legacy versions, staging/UAT hosts, internal tools indexed on the internet (API Discovery; T-Mobile).
  • Framework-convention routes absent from specs and JS: Rails /rails/active_storage/direct_uploads, ActionCable /cable (InfoSec Write-ups).
  • Guest/anonymous cloud identities (Cognito identity pools) reaching data APIs (Exaforce).
  • WebSocket and subscription transports that authenticate separately from HTTP (GraphQL Subscription Security).
  • Agent tools / MCP servers that take object IDs from model context (agentoffense; IDOR in AI Applications).
  • MCP servers over Streamable HTTP: JSON-RPC (initialize → tools/list → tools/call with an Mcp-Session-Id), no authorization by default, and often treated as non-public because humans aren’t meant to call them; ~100k Shodan hits for “MCP” (Fenrisk; MCP Security).

How to test

1. Map the surface (API Discovery).

  • Proxy every client (web, mobile, partner). Hunt specs: /openapi.json, /swagger.json, /v2/api-docs, /v3/api-docs, /swagger-ui.html, /redoc (Swagger Jacker).
  • Archives and brute force: gau --subs target.com | grep -E "\.json|/api/|/v[0-9]/|/graphql|/swagger", ffuf -u https://api.target.com/FUZZ -w common-api-endpoints.txt (API recon guide).
  • No spec? Capture traffic and generate one with mitmproxy2swagger (mitmproxy2swagger). Decompile APKs; vAPI api3’s endpoint only existed in the APK (vAPI).
  • Try every older version of every route, and framework-convention routes.
  • Collect object IDs for the whole engagement: exports, notification emails, PDFs, JS bundles, logs, referrers (agentoffense).

2. Build a four-persona harness (agentoffense): A (victim, tenant 1), B (same role, tenant 1), C (tenant 2), D (lower-privileged or anonymous). Each must own real objects. This covers horizontal, cross-tenant and vertical; the intra-tenant peer case is the one most often missed.

3. Run the swap loop on every object-touching request.

  1. Baseline 2xx as owner.
  2. Replay with a non-owner token and the owner’s ID, one ID location at a time.
  3. Diff status, body, length, headers, timing.
  4. Re-fetch as owner to detect writes. A 403 that still mutated the row, fired a webhook or queued an email is a finding.
  5. Automate token refresh: an expired token’s 401 looks like a pass.
  6. Rule out false negatives: cached responses, soft-deleted objects that skip the ownership filter, empty 200 bodies hiding a successful write.
  7. Flag inconsistent 403/404 across sibling routes (e.g. /invoices/{id} vs /invoices/{id}/pdf) as an existence oracle.

4. Property-level checks. Diff GET vs POST/PATCH bodies; add every field the response returns to the request; confirm binding with a wrong type first ("chosen_discount":{"percentage":"x"} → type error) (PortSwigger lab). Diff response fields across roles for over-exposure.

5. Function-level checks. Call admin/internal routes as D; switch HTTP methods. vAPI api5: /api5/users returned 403 unauthenticated but 200 with the user table for a low-privilege token (vAPI).

6. “Are all the 401s the same 401?” Compare error text across a gated surface. Devise’s “You need to sign in” is an authentication failure; Rails’ “Can’t verify CSRF token authenticity” means the request passed every auth filter (InfoSec Write-ups).

7. Throttling. For every auth/OTP/reset/signup/export flow, test the limiter key and its bypasses (API Rate Limiting); for GraphQL, resend as aliases and arrays (GraphQL Batching Attacks).

8. Server-built requests. Inject %23, %26, %2f..%2f (Server-Side Parameter Pollution) and URLs (Server-Side Request Forgery).

8a. Search and filter scoping. Send *, %, an empty string or any “match everything” value to every search/filter parameter and check results stay scoped to the caller; a search that returns your own record proves nothing (USPS). Compare 200 vs 404 for valid vs non-existent IDs as an enumeration oracle (profile IDOR).

9. Replay against the other environment. Staging findings re-run against production doubled impact in the exam-platform case (InfoSec Write-ups).

10. Fuzz from the spec for crashes, schema violations and authz oracles (API Fuzzing).

Checklist

  • Specs, JS bundles, APKs, archives, older versions, convention routes enumerated
  • Four personas, each owning objects; token refresh automated
  • Every ID location swapped independently, including body foreign keys and batch elements
  • Writes verified by owner re-read; 403-but-mutated checked
  • Nested routes: parent kept, child swapped (other tenant, then own tenant / inaccessible parent)
  • GraphQL node/nodes, typed queries and viewer traversals all tested (GraphQL Authorization Flaws)
  • Response fields diffed across roles; returned fields replayed in writes
  • Admin routes and alternate methods as low-priv and anonymous
  • 403 vs 404 consistency across sibling routes
  • Limiter keys, path variants, aliases, HTTP/2 streams on auth/OTP flows
  • %23/%26/../ in values that feed internal requests
  • Wildcard / empty values in search and filter parameters
  • Batch/bulk endpoints: malformed sub-request paths and nested batches
  • MCP endpoints: tools/list enumerated, tool arguments fuzzed, auth required
  • WebSocket/subscription transports tested without and with foreign tokens
  • Guest/anonymous cloud identities checked against data APIs
  • Findings replayed against production-equivalent environment (in scope)

Exploitation and escalation

  • BOLA → bulk scrape. Seed a few real IDs (from a lookup, your own objects, leaks), then step sequential neighbors. UUIDs slow guessing but leak through responses, links and logs; one foreign ID in a response opened a second route in the jrobineau audit (jrobineau). See Predictable Identifiers.
  • Data exposure → ATO. Tokens, OTPs or session values in responses: vAPI api2 returned every user’s token (vAPI); Tata nexarc returned otpGeneratedForMobile (Eaton Works). See IDOR to Account Takeover, Account Takeover.
  • Mass assignment → privilege, money, workflow. Replaying a user-create with "Profiles":[{"id":1}] produced an admin (Vaadata); "credit":"1000" stuck in vAPI api6 (vAPI); crAPI "status":"returned" on a delivered order got cashback (Cobalt). Mass assignment into template fields reached Server-Side Template Injection in Formie (Formie).
  • BFLA → admin functions → RCE. Unprotected handlers chain into deserialization or config writes (Function Level Authorization, Privilege Escalation).
  • SSPP → internal APIs. Path traversal through a BFF reached an internal search API (Starbucks).
  • Unauthenticated write primitive → trusted-domain hosting. Rails direct upload → presigned S3 PUT → anonymous serve via /rails/active_storage/blobs/proxy/<signed_id>/, cached public, immutable for a year (InfoSec Write-ups).
  • Agent confused deputy. An indirect prompt injection names another tenant’s object ID; an MCP server trusting the agent’s service account fetches it (agentoffense). See MCP Security, Indirect Prompt Injection.
  • Leaked key → service access. Identify the issuing service with secrets-patterns-db regexes (AKIA[0-9A-Z]{16}), validate with keyhacks-style calls, e.g. curl https://api.telegram.org/bot<TOKEN>/getMe, or spray with nuclei -t token-spray/ -var token=token_list.txt (PayloadsAllTheThings).
  • Chain planning: Vulnerability Chaining.

Bypassing defenses

  • UUIDs are locators, not secrets. A random-UUID financing draft was still readable, updatable and file-deletable across identities via a free guest login (SiteGuarding).
  • Gateways and WAFs can’t evaluate ownership. A BOLA request is authenticated and well-formed; gateway-only enforcement leaves service-to-service calls, jobs and queue consumers open (agentoffense). Authorizer caches keyed on JWT alone reuse an ALLOW across objects (Authress); gateway/backend CL.TE disagreement smuggles past every gateway control (apisec.ai). See API Gateway Security.
  • Existence checks posing as authz. exists: validation rules, foreign keys and RLS on integrity checks accept other tenants’ IDs (jrobineau).
  • CSRF as pseudo-auth. A CSRF token handed out on the public sign-in page makes an unauthenticated controller look protected (InfoSec Write-ups).
  • Rate limits: spoofed X-Forwarded-For, path variants (/SignUp, /v1/), /. normalization, %00/%20 username suffixes, HTTP/2 multiplexing, GraphQL aliases, single-packet amplification (~10,000 requests in ~166 ms) (HackTricks; Flatt Security). Details in API Rate Limiting.
  • Version downgrade. vAPI api9: /v2 PIN login was limited (X-RateLimit-Limit: 5), /v1 was not; PIN fell after 795 requests (vAPI).
  • Parser disagreement. Duplicate user_id in query or JSON where the authz layer and handler pick different occurrences; encoded #/& truncating or injecting internal parameters; backslash traversal past a WAF (Server-Side Parameter Pollution; Aon).
  • Batch dispatch desync. WordPress /wp-json/batch/v1: a sub-request whose path fails parse_url() isn’t pushed into $matches but the index still increments, so sub-request N runs with N+1’s handler; a nested batch then delivered a string author_exclude into WP_Query, whose author__not_in check (! empty, no array type guard) skipped absint() and concatenated into NOT IN (...) (Essity H1).
  • Unscoped queries. A wildcard search parameter is not an IDOR bypass: there was no ownership filter to bypass (USPS).
  • Introspection off ≠ schema hidden. Validation errors and Clairvoyance rebuild it (agentoffense; GraphQL Introspection).
  • Relay global IDs are base64 TypeName:pk: decode, change, re-encode (agentoffense).
  • BaaS “fixes” that don’t restrict: to authenticated using (true) silences the RLS-disabled alert; tables revoked for anon remain readable for authenticated accounts; registration via /auth/v1/signup even with no signup UI (Oneleet).

Real-world cases

  • Lovable (2026) — /projects/{id}/* checked Firebase auth, not ownership; source, hardcoded Supabase creds and AI chats exposed 48+ days (CyberKendra).
  • Moltbook — Supabase anon key + missing RLS: 1.5M API tokens, 35,000 emails, plaintext OpenAI keys (Wiz).
  • Cognito guest → AppSync scrape — 8 guest identities, 604 requests, 401 sequential IDs, 172 profiles, 60 with legacy session values; updateUserProfile could change any password (Exaforce).
  • Starbucks (2020, $4,000) — BFF path traversal to an internal API over ~100M customer records (Starbucks).
  • Uber ATO ($6,500) — UUID leaked in an error fed an API returning any user’s mobile token (Uber).
  • T-Mobile promotool — internet-reachable internal care API returned account data incl. PIN by phone number (T-Mobile).
  • Volvo/Eicher fleet — unauthenticated internal APIs: ATO over all users and vehicles, Aadhaar and licences exposed (Eaton Works).
  • Laravel white-box audit — four PUT/PATCH routes accepted foreign project_id-style body IDs; three leaked the other account’s data, one moved the object (jrobineau).
  • Auto-financing drafts — guest login read/updated/attached/deleted files on other identities’ KYC drafts (SiteGuarding).
  • University exam SaaS (Rails) — unauthenticated Active Storage direct upload on staging and production, CWE-306, Medium (InfoSec Write-ups).
  • GHSA-364q-4p2h-gcf3 — @graphql-tools/executor-graphql-ws 3.2.0 merged connectionParams across callers; in GraphQL Mesh, later (incl. anonymous) subscribers ran upstream as the first subscriber; sibling fix CVE-2026-118665 (GitHub advisory).
  • B2B contact platform — "unmaskContactData": true unmasked 600M+ contacts on a free tier (Wiz Red Agent).
  • NodeBB — "pid":1 in POST /api/v3/topics re-created the admin’s post under the attacker (Aikido).
  • Training platform — loadStreams.do leaked 14,000+ enrolled users’ emails (Medium); AI freelance marketplace — unauthenticated sequential-ID endpoint, ~19,990 profiles (InfoSec Write-ups).
  • Directus — anonymous aliased GraphQL resolvers: account lockout, reset-mail flood, argon2id CPU burn (GHSA).
  • Kong — admin API on 8001/8444 exposed via Docker example config (Trend Micro); CVE-2026-92442 cache key omits caller identity (GHSA).
  • USPS Informed Visibility — a wildcard search parameter let any logged-in usps.com user query ~60M accounts (emails, usernames, account numbers, addresses, phones) and request changes to others’ details; ignored for over a year until Krebs’s involvement, then fixed in 48 h (Medium).
  • Essity / WordPress 7.0 — unauthenticated blind SQLi via REST batch route confusion; SLEEP(0) 0.5 s vs SLEEP(0.01) 9.1 s (~860 rows); fixed 7.0.2+ / 6.9.5+ / 6.8.6+ (H1 #3873072; SQL Injection).
  • /app-api/enduserapp/profile/{userId} — authenticated-but-unauthorized profile read (CWE-639), confirmed both directions with unrelated accounts; 200/404 split enables enumeration (writeup).
  • Saleor GHSA-24jw-f244-qfpp / SurrealDB GHSA-p3c2-wh5f-jwqm — unbounded GraphQL array batching and a GraphQL WebSocket upgrade missing size limits: API4 resource exhaustion (Saleor, SurrealDB; GraphQL Denial of Service).
  • Azure API Management Classic (Nov 2026) — unauthorized management-plane access on Developer/Basic/Standard/Premium tiers (not Consumption or v2) exposed Named Values secrets, IdP/OIDC client secrets, subscription keys and direct-management tokens; linked by Norway’s NSM to attacks on Equinor and Skagerak Energi. Microsoft closed the path on 19 Nov, but the fix does not invalidate already-stolen credentials, so rotate. An admin alleged a deprecated legacy API that produced no customer-visible logs (BleepingComputer; API Gateway Security).
  • Microsoft Entra Connect Health API (Jul–Nov 2026) — unauthorized read-only access to tenant metadata: technical-contact emails, tenant ID/name, initial domain, license tier, sync status. Microsoft’s main concern is targeted phishing; mitigations are phishing-resistant MFA and PIM for contacts who hold privileged roles (Help Net Security).
  • DreameHome cloud API (CVE-2026-49964 and GHSA-7mmp-qpv4-2q5v) — POST /dreame-user-iot/token/rtc2 issued Agora RTC tokens for any device DID + owner UID without an ownership check, so a caller could join and publish to a device’s live-video channel. POST /smart-app/meari-cloud/redirectAndLogin picked the Meari account from a caller-supplied uid rather than the Dreame-Auth token, which leaked camera session credentials (live video, mic, speaker, recordings). Target uids came from public profiles and an email-to-uid lookup (GHSA-3pfg-cg22-v3rr, GHSA-7mmp-qpv4-2q5v; BOLA in APIs).
  • Bolt CMS (CVE-2026-77379) — the public Relation API had no access-control filter, so unauthenticated callers could read metadata on unpublished, draft and viewless content over REST and GraphQL. Fixed in 6.1.4 (GHSA-6358-jg5p-hmjj; Excessive Data Exposure).
  • erxes insurance_api (CVE-2026-134826) — unauthenticated GraphQL mutations could create, overwrite or delete contract templates. The templates were rendered by headless Chromium in generateContractPDF, so injected HTML pulled internal content into the PDFs. Fixed in 3.4.14 (GHSA-m22g-6wm2-c3qq; GraphQL Authorization Flaws, SSRF in PDF and HTML Renderers).
  • Coinbase Advanced Trading API (2022, $250,000) — an order carried a product, a source account and a target account. Validation checked that the source held enough balance but never that it held the asset the product trades, so users could sell assets they did not own. Fixes: validate relationships between IDs and place an atomic reserve on the exact asset (Coinbase case study).
  • IBM API Connect 12.1.0.0–12.1.1.2 (CVE-2026-17323) — XXE disclosed sensitive information; no verified patch at publication (tsecurity.de; API Gateway Security).
  • graphql-core (CVE-2026-134795) — Lexer.lookahead tokenized runs of comments before the max_tokens check, causing unauthenticated CPU/memory DoS. Fixed in 3.2.14 / 3.3.2 (GHSA-5pww-59wv-hj9w; GraphQL Denial of Service).
  • GraphQL web cache deception — a POST-only user-data query also worked as GET, and /api/graphql;test.css?query= turned Cloudflare DYNAMIC into HIT (0x_karim; Web Cache Deception).
  • GraphQL alias brute force / voucher limit bypass — request-counting limiters defeated by aliases (logicbreaker, voucher); hidden schemas rebuilt from suggestions (arok.win). Limits must count operations inside a batch as well as HTTP requests, and authorization for user(id:) belongs in the resolver, for example graphql-shield (securityelites).

Prevention

  • Centralize object authorization. A Policy Enforcement Point in shared middleware or the data layer asks a PDP “may subject S do action A on resource R?”, default deny (NIST SP 800-162 ABAC). Subject comes from the verified token (sub), never from user_id, tenant headers or unverified subdomains (agentoffense). Engines: OPA, Cedar, OpenFGA/SpiceDB, Cerbos/Casbin — see Authorization Policy Engines.
  • Make the unscoped query hard to write. current_user.orders.find(id) not Order.find(id); repository methods that require a subject/tenant argument; framework hooks: Spring AuthorizationManager, ASP.NET Core IAuthorizationHandler, Pundit/CanCanCan, DRF get_queryset + django-guardian, NestJS guards + CASL (agentoffense).
  • Check every received ID for existence and ownership in the same statement as the write, and drop fields the product doesn’t need. Back it with a composite FK so the DB rejects cross-owner links, and find already-written ones first (jrobineau):
    ALTER TABLE projects ADD CONSTRAINT projects_id_owner UNIQUE (id, owner_id);
    ALTER TABLE documents ADD CONSTRAINT documents_project_same_owner
      FOREIGN KEY (project_id, owner_id) REFERENCES projects (id, owner_id);
    -- before adding: SELECT d.id FROM documents d JOIN projects p ON p.id=d.project_id WHERE d.owner_id <> p.owner_id;
    Laravel: Rule::exists('projects','id')->where('owner_id', $userId).
  • Per-field allowlists both ways. Request DTOs with explicit writable fields; reject unknown properties; JSON Schema readOnly/writeOnly; response DTOs, never serialized entities; no session material in profile responses (Mass Assignment, Excessive Data Exposure; Exaforce).
  • Consistent not-found semantics. Pick 403 or 404 (often 404 for reads) everywhere; same error text and timing (agentoffense).
  • Authenticate the controllers you didn’t write. Audit framework default routes (Active Storage, ActionCable) and override them (InfoSec Write-ups).
  • Scope anonymous cloud roles. Restrict the Cognito unauthenticated role to the exact AppSync fields guests need (types/Query/fields/getTrxProfile, not types/*/fields/*); add an SCP denying appsync:GraphQL/execute-api:Invoke to principals tagged exposure=public outside an allowlist; enable AWS Config cognito-identity-pool-unauth-access-check (Security Hub Cognito.2) (Exaforce).
  • Throttle the operation, not the request. Key limits to account/operation, count resolver invocations and batch items, overwrite forwarded-IP headers at the edge, apply the same limiter to every version and spelling (API Rate Limiting).
  • Inventory and decommission. Continuous inventory from specs + traffic + code; no Swagger UI or debug routes in production; old versions behind the same middleware (API Discovery).
  • Gateway hygiene. Admin plane on localhost and firewalled; caller and object in every cache key; HTTP/2 end-to-end; re-authorize in each backend (API Gateway Security).
  • BaaS. RLS on every table with real policies, every exposed schema reviewed, registration locked down server-side (Backend-as-a-Service Data Exposure).
  • Agents. Give each agent its own identity (Help Net Security); authorize MCP tool calls against the end user the agent acts for, treating arguments as untrusted (agentoffense). API design itself may steer AI-generated client code toward insecure patterns, a question raised in the talk “The API Made Me Do It” (YouTube).
  • MCP tool metadata is input. Tool descriptions and inputSchema land in the model’s context with no privilege boundary and can change via notifications/tools/list_changed (rug pull, cross-server shadowing). Read full descriptions before approval; hash name + description + schema at approval and block any new or changed tool until re-reviewed (tool descriptions; MCP Tool Poisoning).
  • Actuator. Keep /env and /configprops masking on, expose only needed endpoints, keep them behind Spring Security (Actuator).
  • Keys. Pre-commit detect-aws-credentials and detect-private-key hooks; scan repos and images with TruffleHog (PayloadsAllTheThings); see Secret Scanning, Secrets Management.
  • Regression tests and detection. Per endpoint, a positive owner test and a negative cross-persona test asserting status, no body/header/timing leak and unchanged state; generate skeletons from OpenAPI and fail builds that add routes without one. Log every authz decision; alert on denial spikes and one subject touching many distinct IDs (agentoffense). Sequential-ID sweeps on guest credentials are a scraping signature; correlating them needs CloudTrail + AppSync request logs + resolver logs (Exaforce).

Tools

PurposeTools
Spec discoverySwagger Jacker (sj), Autoswagger (-risk, -b), APIDetector, Dana Epp’s Burp extension (API Discovery)
Route/param brute forceKiterunner, ffuf, api_wordlist (actions.txt × objects.txt), arjun, paramspider ([[raw/github.com/api-wordlist-6028
Spec reconstructionmitmproxy2swagger, Postman capture
Multi-session authzAutorize, AuthMatrix, Auth Analyzer (Burp); Caido match-and-replace ([[raw/agentoffense.com/bola-idor-testing-the-multi-account-object-swap-harness-15619
GraphQLgraphw00f, Clairvoyance, InQL (GraphQL Security)
MCP serversMCPwned (Burp: flags MCP traffic, enumerates capabilities, pre-fills tools/call Repeater templates, parses SSE responses; no WebSocket transport yet) ([[raw/fenrisk.com/mcpwned-a-burp-suite-extension-for-auditing-mcp-servers-15859
gRPC-WebgRPC-Web Coder (BApp): decodes framed protobuf, including grpc-web-text base64 bodies, gzip frames and streaming trailers, into editable JSON without the .proto. It also extracts service routes and field definitions from gRPC-Web JS bundles, which reveals methods the UI never calls, and exports a reconstructed .proto for grpcurl ([[raw/portswigger.net/grpc-web-coder-bapp-16050
Rate limitsTurbo Intruder, h2load -n 100 -c 1 -m 100 (API Rate Limiting)
Spec-driven fuzzingRESTler, CATS, WuppieFuzz, Schemathesis, openapi-fuzzer (API Fuzzing)
Key leaksTruffleHog (trufflehog github --org=…, trufflehog docker --image …), trivy, badsecrets, secrets-patterns-db, keyhacks, nuclei -t token-spray/ ([[raw/github.com/payloadsallthethings-api-key-leaks-3993
Practice targetsvAPI, VAmPI, crAPI ([[raw/github.com/vampi-vulnerable-rest-api-with-owasp-top-10-vulnerabilities-4912

Sub-pages

apisec pages

Shared with other topics

Related elsewhere: Insecure Direct Object Reference, IDOR Testing Methodology, Broken Access Control, Authorization Security, GraphQL Security, GraphQL Subscription Security, JSON Web Tokens, OAuth 2.0 Vulnerabilities, Account Takeover, Server-Side Request Forgery, Webhook SSRF, SQL Injection, NoSQL Injection, MCP Security.

See also: Race Conditions · HTTP Request Smuggling · CORS Misconfiguration

Sources