# API Gateway Security > The gateway is the single enforcement point for authentication, authorization and rate limiting in front of many backends, which makes it a high-value target: one flaw in the gateway, its admin plane, its caching, or the way it parses requests versus the backend defeats controls for every service behind it. ## How it works A gateway deployment has three pieces — the gateway, its datastore, and the admin API — and is only as secure as the weakest one. The recurring failure modes: - **Exposed admin API.** Reading/writing gateway config in plaintext: routes, auth config, secrets. - **Authorizer caching keyed too coarsely.** The cache omits the resource, so an ALLOW for one object is reused for another. - **Cache-key confusion in response/plugin caches.** The caller identity isn't in the key, so one caller's response is served to another. - **Parsing disagreement with the backend.** The gateway and backend split requests differently, so a smuggled request bypasses every gateway control. See [[HTTP Request Smuggling]]. - **Plugin and protocol flaws:** missing assertion checks, injection, missing timeouts. ## Techniques / payloads **Admin-API exposure (Kong case study, Trend Micro).** Kong's admin API listens on localhost by default, but the Docker Hub example binds all interfaces on 8001/8444 with weak passwords; absent cloud firewall rules leave it public (visible in Shodan since late 2021). Access lets an attacker add routes, tamper with auth, or read secrets. Kong stores secrets in the DB as plaintext in the community edition; encryption needs the enterprise keyring. Mitigations: bind admin to localhost, firewall to specific subnets/VPN, enterprise RBAC with token auth on an admin route. **Authorizer / cache-key confusion (Authress).** An AWS API Gateway authorizer that caches by JWT only breaks two ways: - Return the specific `event.methodArn` as the policy resource and the cache denies the same user's valid request to a *different* endpoint (annoying but safe). - "Fix" it to `arn:aws:execute-api:*:*:*` and now any endpoint is allowed for a valid JWT — and if you *also* cache a per-resource authorization result (`authorizeUser(userId, 'orders_123', ...)`), the cache stores `JWT => ALLOW` without the object ID, so a follow-up to `orders_456` returns the cached ALLOW and is never re-checked. Fix: include the resource in the cache key, or don't cache per-object decisions. **Request smuggling at the gateway (apisec.ai).** HTTP/1.1 ambiguity between `Content-Length` and `Transfer-Encoding` is amplified because gateways multiplex many clients over shared backend connections — one smuggled request poisons the connection for other users and bypasses auth/rate limits in one step. ```http POST /api/v1/data HTTP/1.1 Content-Length: 6 Transfer-Encoding: chunked 0 X ``` - CL.TE, TE.CL, and obfuscated TE (`Transfer-Encoding: xchunked`, tabs, line folding). Real CVEs: **CVE-2024-53008** and **CVE-2023-40225** (HAProxy ACL bypass / empty `Content-Length`), **CVE-2024-33452** (HEAD with body). Detection: send conflicting CL/TE and watch for a timeout (backend waiting for bytes that never arrive). Fix: HTTP/2 end-to-end (frame length fields remove the ambiguity), disable HTTP/1.1 downgrade, disable backend connection reuse, re-audit config after every deploy. ## Notable cases (recent CVEs) - **Kong graphql-proxy-cache-advanced (CVE-2026-92442).** Omits the caller identity from the cache key, so a response cached for one caller is served to another. - **Kong Enterprise SAML plugin (CVE-2026-92439).** Does not enforce `AudienceRestriction`, so a SAML assertion issued for another Service Provider can be replayed to authenticate to Kong. See [[SAML Attacks]]. - **Kong Gateway Enterprise / Kong AI Gateway (CVE-2026-92544).** SQL injection in the LLM usage counters via a crafted model name. See [[SQL Injection]]. - **GraphQL Hive Gateway batch-execute (sonatype-2026-010434, CVSS 8.6).** Authorization bypass via context confusion in GraphQL Tools Batch Execute. See [[GraphQL Batching Attacks]]. - **Traefik ≤ 3.7.11.** The default 60-second request read timeout was silently not applied to HTTP/3 (introduced in 2.8.2, Aug 2022), letting an unauthenticated client hold requests open indefinitely, one upstream connection each — a low-volume DoS against bounded backend pools. Fixed in 2.11.56 / 3.7.12. ## Defenses - Bind the admin plane to localhost; firewall and authenticate it. Never copy example configs that expose it. - Put the caller (and object, where relevant) in every cache key; don't cache per-object authorization at the gateway. - Validate JWTs at the gateway *and* re-authorize in each backend (defense in depth); pass trusted claims as headers the client can't set. - Prefer HTTP/2 end-to-end, disable downgrade and backend connection reuse, re-audit after infra changes. - Store gateway secrets encrypted (vault/keyring), not plaintext in the config DB. ## Related - [[API Security]] - [[HTTP Request Smuggling]] - [[JSON Web Tokens]] - [[GraphQL Batching Attacks]] - [[SAML Attacks]] - [[SQL Injection]] - [[API Rate Limiting]] ## Sources - [[raw/trendmicro.com/kong-api-gateway-misconfigurations-a-security-case-study-3988|Kong API Gateway Misconfigurations: A Security Case Study]] - [[raw/trendmicro.com/kong-api-gateway-misconfigurations-case-study-trend-micro-4318|Kong API Gateway Misconfigurations Case Study - Trend Micro]] - [[raw/authress.io/api-gateway-authorizers-vulnerable-by-design-3986|API Gateway Authorizers: Vulnerable By Design]] - [[raw/apisec.ai/http-request-smuggling-in-api-gateways-3987|HTTP Request Smuggling in API Gateways]] - [[raw/github.com/kong-graphql-proxy-cache-advanced-leaks-cached-responses-across-caller-14783|Kong graphql-proxy-cache-advanced leaks cached responses across callers]] - [[raw/github.com/kong-gateway-enterprise-saml-plugin-does-not-enforce-audiencerestricti-14138|Kong Gateway Enterprise SAML plugin does not enforce AudienceRestriction]] - [[raw/github.com/sql-injection-in-llm-usage-counters-of-kong-gateway-enterprise-kong-ai-14059|SQL injection in LLM usage counters of Kong Gateway Enterprise / Kong AI Gateway]] - [[raw/guide.sonatype.com/graphql-hive-gateway-batch-execute-authorization-bypass-13388|GraphQL Hive Gateway batch-execute authorization bypass]] - [[raw/bishopfox.com/traefik-version-through-3-7-11-11845|Traefik - Version Through 3.7.11]]