API gateway security means using a single entry point in front of your services to terminate TLS, validate tokens, enforce rate limits and quotas, validate requests against your API schema, and log every call. A gateway stops many edge attacks, but it cannot enforce object-level authorization, because only the service knows who owns the data — so services must still check ownership on every request.
Key takeaways
- A gateway is the right place for TLS, token validation, rate limiting, schema checks and logging.
- Object-level authorization lives in the service, not the gateway — a valid token for tenant B must never open tenant A's data.
- Treat the gateway as a high-value target: its configuration is code, and changes to it need review and alerting.
Every API you expose is a door into your systems, and without a single checkpoint, each service ends up guarding its own door differently. An API gateway puts one well-guarded entrance in front of them all — but only if you know which threats it can actually stop.
What is an API gateway?
An API gateway is a single entry point that sits in front of your backend services. All external traffic passes through it, and it routes each request to the right service.
Instead of every service handling TLS, token checks, rate limits and logging on its own, the gateway does those jobs once, consistently, for all of them. Services behind it can focus on business logic.
Common gateways include cloud-managed options such as AWS API Gateway, Azure API Management and Google Cloud API Gateway, and self-hosted ones such as Kong, NGINX and Traefik. The product matters less than the controls you turn on.
A gateway is not a firewall, and it is not an authorization server. It is the checkpoint at the edge — powerful there, and blind to what happens inside a service.
What does an API gateway secure?
A gateway secures the edge: it terminates TLS, validates tokens, applies coarse authorization, rate-limits clients, filters malformed requests and logs every call.
TLS termination means the gateway holds the public certificate and ends HTTPS there, so you set the minimum TLS version and cipher list in one place and rotate certificates in one place. You can also turn on HSTS for browser clients.
For authentication, most gateways validate OAuth 2.0 access tokens and OpenID Connect ID tokens. For a JWT, the gateway checks the signature against the issuer's published keys, then checks expiry, issuer and audience claims. Palo Alto Networks' review of the OWASP list covers the same token weaknesses. Paste a token into our free JWT decoder to see what those claims actually say.
It also enforces request size limits and timeouts, which stop one client tying up workers with huge uploads or slow connections, and it strips headers clients must never set — such as internal identity headers your services trust.
What are the OWASP API Security Top 10 risks?
The OWASP API Security Top 10 (2023) is the ranked list of the most critical API risks, and authorization failures dominate it. The current edition is still the 2023 release, as OWASP's own API Security Top 10 page confirms.
| Risk | What goes wrong | Gateway helps? |
|---|---|---|
| API1 BOLA | Endpoint trusts a client-supplied ID without checking ownership | Hardly — service must check |
| API2 Broken authentication | Weak, forgeable or non-expiring tokens | Yes — token validation |
| API3 BOPLA | Caller reads or writes properties they should not touch | Partly — schema checks |
| API4 Unrestricted resource consumption | No rate limits, quotas or size caps | Yes — limits and quotas |
| API5 BFLA | Normal user reaches admin functions | Partly — role checks per route |
| API6 Sensitive business flows | Checkout, signup or booking abused at scale | Partly — per-flow limits |
| API7 SSRF | Server tricked into calling internal systems | Partly — egress rules |
| API8 Security misconfiguration | Defaults, verbose errors, open debug endpoints | Yes — one place to harden |
| API9 Improper inventory | Unknown, shadow or zombie endpoints | Yes — routes vs real traffic |
| API10 Unsafe consumption | Third-party API data trusted blindly | Hardly — service must validate |
Of the ten risks, a gateway helps a lot with authentication, resource consumption and inventory, and helps little with object-level authorization. That split is the key to using one well.
Why is broken object level authorization the top risk?
Broken object level authorization (BOLA) happens when an endpoint exposes an object by its identifier but never checks that the caller owns it. It has ranked first since 2019.
The classic example: a user changes an order ID in a request URL from their own order to someone else's, and the API returns the other person's full order details. The route is authenticated — the object is not authorized.
A valid token for tenant B asking for tenant A's order passes every gateway check, because only the service knows who owns that order. The fix is in the service: scope the query by the verified tenant from the token, never from the request body, and return a not-found response when no row matches.
Test it the same way an attacker would: authenticate as two different users and try to access each other's resources by changing IDs in requests. Scanners cannot reliably find BOLA, so this test has to be done by hand or with role-aware testing.
How should authentication work at the gateway?
Use a standard, not a home-grown scheme: OAuth 2.0 and OpenID Connect for user-facing APIs, signed short-lived tokens for service-to-service calls, and scoped API keys only where a full token flow is impractical.
Validate the token signature, issuer, audience and expiry on every request. Do not trust a token that was never validated, and do not accept tokens that never expire. Rate-limit the login and token endpoints to blunt credential stuffing.
API keys identify a project or partner; they are not strong authentication for sensitive data, because they are long-lived, often shared, and rarely tied to a person. If you use them, scope them narrowly, rotate them, and be able to revoke one without breaking every client.
For service-to-service traffic, prefer mutual TLS or workload identity over shared secrets passed in headers. Secrets belong in a vault, never in code or in client apps.
How do rate limiting and quotas work?
Rate limiting caps how many requests a client can make in a window, and quotas cap total use over a longer period, such as a day. Both map to OWASP API4, unrestricted resource consumption.
Apply limits per authenticated identity and per IP, with tighter limits on expensive endpoints such as search, export or login. Return a 429 status with a Retry-After header when a client exceeds the limit, so well-behaved clients back off instead of retrying in a storm.
Key limits on token or tenant, not only on IP: shared egress penalizes honest users behind one address, and rotating addresses defeat a per-IP limit. For agent traffic, OWASP guidance makes the same point — rate limiting should rest on cryptographic identity rather than an IP address that can be shared or spoofed.
Without limits, one client can exhaust your capacity, run up your cloud bill, or brute-force credentials unchecked. With them, abuse becomes slow, expensive and visible.
What input validation should the gateway enforce?
Validate every input against a strict schema at the boundary: types, ranges, lengths and allowed values. If you publish an OpenAPI description, many gateways can validate requests against it directly.
Reject unknown fields, wrong types and missing required parameters before they reach a service. That stops malformed requests early and gives you a clean log of what attackers are probing.
Validate again in any service that can be reached without passing the gateway. Defense in depth matters here because a direct-to-service path bypasses every edge check — test for that path explicitly.
Also whitelist writable fields. Mass assignment — where a caller writes a property such as a price, a role or an owner ID that the UI never shows — is part of BOPLA, and a schema that only allows the fields a caller may touch stops it.
Why do inventory and logging matter?
You cannot secure an endpoint you do not know exists. Shadow APIs, old versions and forgotten test routes are a steady source of breaches, which is why improper inventory management is API9.
Compare the routes your gateway serves against real traffic in its logs. Endpoints with traffic but no entry in your inventory are shadow APIs; entries with no traffic are candidates for removal. Retire old versions instead of leaving them running.
Log every call with the caller identity, the route, the result and the timing — but never log tokens, passwords or full request bodies containing personal data. Logs are also your incident evidence, so keep them long enough to investigate and protect them from tampering.
Check your public site's TLS and headers the same way you check your gateway: our free SSL checker shows whether your certificate and TLS setup are sound.
What can an API gateway not do?
A gateway cannot enforce object-level or property-level authorization, cannot judge whether a business flow is being abused, and cannot validate data from a third-party API you consume.
Business-flow abuse — such as bulk account creation, checkout fraud or scraping through a legitimate flow — needs service-side logic that understands what the flow is worth abusing. Edge limits slow it down; they do not understand it.
Server-side request forgery (SSRF) also needs service and egress controls: the gateway can block some destinations, but the service that fetches a user-supplied URL must validate it against an allowlist.
Finally, a gateway is itself a high-value target. Treat its configuration as code, review changes, alert on them, and keep its own admin access behind strong authentication. A misconfigured gateway can expose every service behind it at once.
The bottom line
An API gateway is the right place for the checks that are the same for every request: TLS, token validation, rate limits, size limits, schema checks and audit logging. It makes those controls consistent instead of leaving each service to improvise.
But a gateway is not authorization. Put ownership and role checks in the service, test them with two real users, and keep your inventory honest. Check your own site's security posture with the free security headers checker as a starting point.
Frequently asked questions
What is an API gateway?
An API gateway is a single entry point that sits in front of your backend services and handles traffic for all of them. It routes requests, terminates TLS, checks tokens, applies rate limits and logs calls, so each service does not have to do those jobs itself.
Is an API gateway a firewall?
No. A gateway shares some jobs with a firewall, such as filtering bad traffic, but its main work is API-specific: token validation, routing, rate limiting and schema checks. It does not replace a web application firewall or the authorization checks inside your services.
What is the biggest API security risk?
Broken object level authorization, or BOLA, is ranked first in the OWASP API Security Top 10 for 2023. It happens when an endpoint trusts an ID from the client without checking that the caller owns that object, letting one user read or change another user's data.
Can an API gateway stop BOLA attacks?
No, not by itself. A gateway sees the token and the path, not the database, so it cannot tell whether an order belongs to the caller. The service must check ownership against the verified identity from the token on every request.
Should API keys be used for authentication?
API keys are fine for identifying a partner or a project, but they are weak as the only authentication for sensitive data. Use OAuth 2.0 and OpenID Connect for user-facing APIs, and short-lived signed tokens for service-to-service calls.
What is rate limiting in an API gateway?
Rate limiting caps how many requests a client can make in a time window, per identity or per IP. It slows credential stuffing and scraping, stops one client from exhausting your capacity, and limits the damage from retry storms.
Do internal APIs need a gateway too?
Internal, east-west traffic needs its own controls, usually mutual TLS from a service mesh or workload identity. A gateway at the edge does not protect services that can be reached directly, bypassing it.
How do I test API gateway security?
Test with two different authenticated users: try to access each other's objects, call admin routes as a normal user, send malformed and oversized requests, and try reaching services directly without the gateway. Also check that tokens expire and can be revoked.
Sources
The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.
Checked against the OWASP API Security Top 10 (2023) and gateway security guidance from OWASP-aligned engineering sources.
How we write and fact-check →