This sheet is past its review date. Deadlines or advice may have changed since 4 Nov 2026.
API security: is every request authorized for the exact object it touches?
Check in code, on every request, that the caller may act on the exact object and fields it names, and add tests this month that replay each endpoint with a second tenant's token. Use the gateway for token checks, rate limits, schema checks and the version inventory, and switch off any API that isn't in that inventory.
If you only do five things
Accept and return only allowlisted fields.
Bind each request to an input schema per endpoint, and build responses from an explicit output type, not a generic
to_json()of the database object2.Inventory every API and switch off the rest.
List each host, version and owner, including beta and partner hosts, and block retired versions. The NCSC traces the Optus breach to a forgotten API that stayed online for years10.
Test with a second tenant before each release.
Replay every call with another tenant's token, a lower role and no token, and block the release on any success1.
Test an API for authorization flaws
Set up two tenants.
Give each an admin, a basic user and one object of every type. CISA advises testing with users of different privilege levels13.
Collect every call.
Take them from the spec, the gateway and recorded web and mobile traffic, including old versions and GraphQL operations.
Swap the caller.
Send each request with the other tenant's token, the basic user's token and no token. Expect 401, 403 or 404.
Swap the IDs and fields.
Change IDs in paths, bodies and batches. Add
role,tenantIdorisAdminto writes and check they are ignored.Keep each case as a CI test.
Run them for every route. NIST suggests deploying an endpoint only once it carries a permission annotation9.
How API attacks work now
- Logged-in users reach other users' data. In OWASP's 2025 Top 10 data, 100% of applications tested had some form of broken access control, a category that also covers SSRF and CSRF4. Three of the API Top 10's first five risks are about authorization9.
- Old and side-door endpoints let attackers in. OWASP says unmanaged APIs are usually breached via old versions or unpatched endpoints3. The NCSC says weak authentication and no rate limiting in Dell's partner portal API exposed details of 49 million customers10.
Tokens and sign-in
- Use the code flow with PKCE. RFC 9700 forbids the password grant, advises against the implicit grant and requires PKCE for public clients6.
- Bind each token to one API. Restrict access tokens to one audience and the least privilege; an API must refuse tokens meant for another6. Identify users by
issplussub5. - Sender-constrain tokens, high-value ones first. RFC 9700 recommends mutual TLS or DPoP for all access tokens, and requires sender-constrained or rotated refresh tokens for public clients6.
- Keep lifetimes short. Authorization codes last at most 10 minutes and refresh tokens need an absolute expiry5. Keep access tokens to minutes. Give outside callers opaque tokens, not JWTs that reveal internal claims9.
- Don't rely on API keys alone. The NCSC calls them shared bearer tokens, often broad and without expiry11. Authenticate partner and service clients with
private_key_jwtor mutual TLS6.
Gateway or code: what goes where
- The gateway checks who and how much. Validate tokens, reject requests outside the schema, cap payload size and time, and log every call912.
- The code checks which object. Ownership, tenant, record state and field rules need the data, so the service decides, or a policy service it asks.
- Make the gateway impossible to skip. Accept traffic only from the gateway, by network policy or a credential it attaches9. In January 2026 CISA listed a Versa Concerto proxy flaw that exposed admin endpoints14.
- Strip identity headers at the edge. Clients must not be able to set headers such as
X-User-IDthat the gateway sets5. - Rate-limit per caller. Key limits to the user or credential over 1 to 5 minutes and cap concurrent requests; a total limit lets one caller crowd out the rest9.
Webhooks, GraphQL and gRPC
- Verify every webhook you receive. Check the HMAC over the raw body in constant time1718, reject old timestamps (Stripe's libraries allow 5 minutes by default) and skip event IDs already processed18.
- Treat webhook URLs you call as hostile. CISA listed a GitLab webhook SSRF as exploited in February 202614. Allowlist hosts, check the address you connect to and refuse redirects, as the TypeScript sheet explains.
- Cap GraphQL query cost. Use depth and amount limits or cost analysis5, limit batching and check authorization on both edges and nodes15.
- Hide the schema on public endpoints. Turn off introspection unless outside parties use the API5, and GraphiQL in production15. gRPC's docs flag the reflection service as a possible security issue on public APIs16.
Mistakes that cost the most
- Checking the role but not the record. NIST counts a missing resource-level check, or one against the wrong user or resource, as an authorization risk9.
- Letting the app hide fields. Attackers read the raw API, and decompile mobile apps to find endpoints and keys12.
- Leaving a beta host behind. In OWASP's example, a rate limit in front of the production reset API didn't cover a beta host running the same code, where a researcher brute-forced the 6-digit token3.
- Calling other services with the backend's own token. Pass the caller on by token exchange and base each decision on their permissions5, or one bug in the first service reaches every service behind it.
What changed in 2026
- Browser apps should keep tokens on a backend. RFC 10017, a Best Current Practice since August 2026, strongly recommends a backend for frontend, which keeps tokens out of the browser, for business apps and apps that handle personal data7.
- Agent-facing APIs need the same checks. MCP's July 2026 specification deprecates Dynamic Client Registration19, and in September CISA listed a LiteLLM MCP endpoint that accepted any bearer token14. Inventory and test MCP servers like any other API.
- NIST's API guidance gained checklists. The March 2026 update of SP 800-228 adds tables of API risks and of controls by lifecycle stage9.
What you can skip
- Waiting for OAuth 2.1. It is still a draft, at version 17 in October 20268. RFC 9700 already sets the rules6.
- Random IDs instead of checks. CISA says UUIDs and GUIDs should not be used for security capabilities13. Use them, and check access anyway.
- An API security platform before an inventory and tests. No traffic product knows that order 1042 belongs to tenant B.
- Signing every message. ASVS asks for per-message signatures only at its highest level, for highly sensitive requests5.
What this looks like at your size
Small team, no security staff
- Write one
canAccess(user, object, action)check and call it in every handler that takes an ID. - Use a hosted identity provider with the code flow and PKCE.
- Put the API behind your cloud's managed gateway with per-key rate limits.
Growing, with IT or security staff
- Generate the inventory from specs and gateway routes, with owners and retirement dates.
- Run the two-tenant tests in CI, and turn off introspection and reflection by default.
- Alert on bursts of 403 and 404 from one caller, a sign of enumeration13.