API endpoint security: a checklist for one route at a time

API endpoint security is the work of making one route safe to leave open: it is listed, the caller is allowed to use it on the objects in question, it accepts only the input it was designed for, it cannot be called without limit, and it returns only what the caller needs. The overview of API risks is on API security; this page is the list you run per route.

Section API security Updated Covers six checks per route

Quick facts

Unit of work
One route: method plus path, such as GET /orders/{id}
Input contract
OpenAPI Specification, whose schemas follow JSON Schema
Categories touched here
API1, API2, API3, API4, API5 and API9 (2023 edition)
What a WAF can check
Method, path, size and request rate per route; not who owns an object

The overview page covers what each OWASP category means. This page does not repeat it. It takes the six places where a single route most often fails and turns each into a question you can answer yes or no. For how to find the failures by testing, see API security testing.

1. Know the route exists

You cannot secure a route nobody listed. OWASP calls the failure Improper Inventory Management (API9:2023): old versions, debug routes and test hosts that keep answering after the documented API has moved on. They tend to lack the fixes made since and sit outside the monitoring. Routes nobody tracks are covered under shadow APIs; costly requests under resource consumption; keys under API key security. Allowing only what the schema describes is the positive security model.

  • Compare the description with traffic. Take the routes in the OpenAPI document and the routes seen in access logs. A path in the logs and not in the document is a candidate shadow endpoint.
  • Give every route an owner and a version status. A route with no owner is where nobody will ever apply the next fix.
  • Retire what is not used. A deprecated version that still answers is still attack surface; remove it rather than only mark it.

A route missing from the description is also invisible to the schema checks in step 3 and to scanners, which is why this step comes first.

2. Check access on the function and the object

Two questions, asked on every route, and both belong in the application. First, may this caller use this function at all? Failing that is Broken Function Level Authorization (API5:2023): an ordinary account that can call an administrative route because only the interface hid it. Second, may this caller touch this object? Failing that is Broken Object Level Authorization (API1:2023), covered with a worked example on BOLA; the same flaw in a web page is IDOR. Field-level checks are covered under mass assignment, and query-based APIs under GraphQL security. Where a gateway fits is covered under WAF vs API gateway.

For each route, write down which role may call it and which object field ties the record to the caller. Then test with two accounts, as the testing page describes. A route that takes an identifier in the path, the query string or the body needs the object check on all three.

Hard-to-guess identifiers make enumeration slower, but they are not an authorisation check: a leaked or shared identifier works for anyone who holds it.

3. Accept only the input you designed

An OpenAPI description can say what a route accepts: the allowed methods under each path, parameter types, required fields and, through JSON Schema keywords, limits such as maxLength, maxItems, maximum and enum. A schema in the description is only a contract until something enforces it, so validate requests against it in the application or the gateway and reject what does not fit.

  • Methods. Allow the methods the route defines and refuse the rest. The status for a known path with an unsupported method is 405, and RFC 9110 requires the response to carry an Allow header. Method handling is covered on HTTP methods in API security.
  • Size. Set a maximum body size per route. An oversized request is answered with 413, defined in the same RFC.
  • Shape. Reject unknown fields on write routes, so a caller cannot slip in a field such as a role or an owner that the route was never meant to set.
  • Types and ranges. A page size, a quantity and an identifier each get a type and a bound.

4. Limit frequency and cost

Unrestricted Resource Consumption (API4:2023) is not only about request counts. One call can be expensive because of what it asks for: a very large page size, a deep nested query, an export, an upload, a message sent to a third party. Count the cost of one call per route, then set limits that match it.

  • Cheap reads can take a generous rate.
  • Costly or side-effecting routes (search, export, password reset, anything that sends email or SMS) get their own, lower limit and an upper bound on the parameters that drive cost.
  • Refusals should use 429, defined in RFC 6585, so clients know to slow down; see 429 Too Many Requests.

How limits are counted and keyed is on rate limiting. Per-route limits are one of the checks a filter in front of the API can carry out, because the route and the rate are visible in the request.

5. Return only what is needed

Broken Object Property Level Authorization (API3:2023) covers two directions: a response that includes properties the caller should not see, and a request that can write properties the caller should not change. The usual cause is returning or binding a whole internal object instead of a chosen set of fields.

  • Name the fields each route returns per role, instead of serialising the record as stored.
  • Keep errors plain. A client needs a status and a short message, not a stack trace, a query or a library version.
  • Do not advertise internals. Version banners and verbose headers tell an attacker which known flaws to try.

6. Authenticate the caller

Unless a route is public on purpose, a request without valid credentials should get 401 before any other logic runs. Weak or missing authentication is Broken Authentication (API2:2023). Choosing a scheme and handling keys is on API authentication; token-specific mistakes are on JWT security. Mark public routes explicitly in the description, so that a route which should be protected is not public by omission.

Which layer checks what

CheckApplicationGatewayWAF
Route is in the inventoryOwns the listCan expose only listed routesShows which paths receive traffic
Function-level access (API5)YesCoarse role checksNo
Object-level access (API1)Yes, only hereNoNo
Method allow-listYesYesYes, if you define it
Schema and size limitsYesYes, if it loads the descriptionSize yes; schema only if you describe it
Rate and cost (API4)Cost boundsRate limitsRate limits per route
Response fields (API3)YesSometimesNo
Authentication (API2)YesOftenNot as a substitute

The pattern is plain in the table: what depends on who the caller is and who owns what stays in the application. What depends only on the shape and rate of the request can be moved earlier.

Where a WAF helps and where it does not

A WAF sees each request as it arrives: method, path, headers, body size and how often that source and route are called. That is enough to apply a limit to one route, refuse a method you do not use, or flag a known attack shape in a parameter. A schema allow-list is possible only if you have written the schema down and given it to the filter; the filter does not infer your contract. Checking every route this way is the application-level side of a zero trust approach.

It does not see who owns an object. A request for another user's record looks identical to a request for your own, so object and function authorisation are not something a filter checks, and a response that returns too many fields passes through as any other would. Treat the WAF as a layer that narrows what reaches the application, and keep the checks above in the application.

Introduce it by watching first. In monitor mode, matches are recorded and every request is still served; read the activity log for a while, see which routes would have been affected, then move one route at a time to block. The reasoning is on monitor mode, and the mapping from OWASP categories to rules is on OWASP API Top 10.

Questions

What is API endpoint security?

API endpoint security is the set of checks applied to one route of an API: whether it is in the inventory, who may call it and on which objects, what input it accepts, how often and how expensively it can be called, what its responses reveal, and how callers authenticate.

How do you secure a REST API endpoint?

Work through one route at a time. Confirm it is documented, check authorisation on the function and on each object it touches, validate input against the schema, set size and rate limits, trim response fields, and require authentication unless the route is public on purpose.

Can a WAF secure an API endpoint on its own?

No. A WAF sees the method, path and request rate and can apply limits per route, but it does not know who owns an object, so it cannot check authorisation. It complements the checks made in the application and the gateway.

What is a shadow or zombie endpoint?

An endpoint that still answers but is missing from the API description or from anyone's ownership, often an old version or a forgotten test route. OWASP lists the inventory problem as Improper Inventory Management, API9:2023.

Should rate limits be set per endpoint?

Yes for routes where one call is costly, such as search, export, password reset or anything that sends a message. A single global limit is too loose for those and too tight for cheap reads. Start in monitor mode and read the activity log before blocking.