API Gateway Security Testing and JWT Validation After the WSO2 Forged Token Attacks
The WSO2 API Manager forged admin token attacks show why a gateway that validates JWTs for every backend is a single point of failure. A CISSP and CEH explains the JWT validation bugs that keep returning, the attack path, and how to scope an API pentest that forges tokens on purpose.
Somewhere in your environment there is a backend service whose entire authorization model is a comment that reads "the gateway already checked this." I have found that comment, or its spiritual equivalent, in nearly every API assessment I have run over the last few years. It is usually true on the day somebody writes it. It stops being true the day an attacker learns to mint a token the gateway accepts, and that is exactly what happened this fall when attackers started walking into WSO2 API Manager deployments with forged admin tokens. API gateway security testing is the discipline of finding that day before somebody else does, and most organizations are not doing it, because they test the services and assume the front door is somebody else's problem.
This post is about that front door. Not the specific WSO2 bug, which has a patch and an advisory, but the architectural habit that makes a single token validation mistake at the gateway worth every service behind it. If you run a SaaS platform, an internal microservices estate, or even a modest set of partner APIs fronted by Kong, Apigee, Azure API Management, AWS API Gateway, Tyk, or a homegrown NGINX config with a Lua script nobody wants to touch, the lesson applies to you.
Why the API gateway became the authorization layer nobody tests
The pitch for an API gateway is a good one, and I do not want to pretend otherwise. You centralize authentication, rate limiting, logging, and request shaping in one place, and every service team gets to stop reinventing JWT parsing. NIST describes this pattern in its microservices security guidance (NIST SP 800-204, https://csrc.nist.gov/pubs/sp/800/204/final), and it is sound architecture when the gateway is treated as a security control with its own threat model.
Here is the thing, though. Centralization concentrates trust. Once the gateway validates a JSON Web Token and forwards the request with a nice clean header like X-User-Id or X-Tenant-Id, the backend services start reading those headers as gospel. Over a couple of release cycles, the services quietly lose their own authorization logic, because why would a team spend sprint points rechecking something the platform group promised was handled. The gateway becomes the only place where signature, issuer, audience, expiry, and algorithm are checked, and the services become what I like to call trust sponges. They absorb whatever identity claims arrive and act on them.
That is a perfectly defensible design until the validation at the gateway is wrong. Then every service inherits the mistake at once, and you have converted a single bug into an organization-wide authorization failure. The WSO2 exploitation in September is the clean example. A forged token with admin claims got accepted, and the blast radius was not one endpoint. It was everything the gateway fronted.
From a CISSP lens, this is a classic single point of failure in a control that was never documented as one. From a CEH lens, it is the most efficient attack path in the building, because the attacker only needs to defeat one validator to impersonate any user against any service. Attackers love efficient. So should your test plan.
The JWT validation failures that keep coming back
JSON Web Tokens have a long and honestly a little embarrassing history of implementation bugs, and almost all of them come down to a validator trusting something in the token that it should have decided for itself. The guidance on how to do this right has existed for years in RFC 8725, the JWT Best Current Practices document (https://datatracker.ietf.org/doc/html/rfc8725). The bugs keep shipping anyway.
The oldest member of the family is the alg none problem. A JWT header declares the signing algorithm, and early libraries honored it, including the value none, which means no signature at all. An attacker removes the signature, sets the algorithm to none, edits the claims to say they are an administrator, and the library shrugs and accepts it. Tim McLean's 2015 research blew this open across multiple languages, and it still shows up today in custom middleware and in gateway plugins written by someone in a hurry.
The second member is algorithm confusion, sometimes called key confusion. A service expects tokens signed with RS256, an asymmetric algorithm where the private key signs and the public key verifies. The attacker changes the header to HS256, a symmetric HMAC algorithm, and signs the token using the server's public key as the HMAC secret. If the validator lets the token header pick the algorithm, it dutifully runs an HMAC check using the public key, which the attacker already has, and the forged token verifies. The Node.js jsonwebtoken library lived through this as CVE-2015-9235, and the pattern has resurfaced in other ecosystems many times since.
The third member is the one that should humble anyone who thinks this is a solved problem. CVE-2022-21449, the Psychic Signatures bug in Java's ECDSA implementation, let a signature made entirely of zeros pass verification on affected Java versions. Every JWT library that relied on the JDK's ECDSA verifier inherited the flaw without changing a line of its own code. Gateways built on the JVM were in scope whether their maintainers knew it or not.
Then there are the header-driven key lookups. The kid header tells the validator which key to use, and when a gateway builds a file path or a database query from that value without sanitizing it, you get path traversal to a predictable file or SQL injection that returns a key the attacker controls. The jku and x5u headers point to a URL where the validator should fetch the signing keys, and a validator that follows any URL in the header will happily fetch the attacker's key set from the attacker's server. The embedded jwk header lets a token carry its own public key, which is about as sensible as a visitor printing their own badge, and the Cisco node-jose library shipped exactly that behavior as CVE-2018-0114.
Beyond signatures, there is a quieter category of claim validation failures that does not get conference talks but causes plenty of real damage. Gateways that check the signature but not the audience will accept a token minted for a completely different application by the same identity provider. Gateways that skip the issuer check will accept a token from a test tenant. Gateways with generous clock skew or no expiry check will honor tokens long after a user left the company. None of these need cryptographic tricks. They need a tester who asks for a token from the wrong place and sees whether it works.
The attack path from a forged token to every backend service
It helps to walk the path the way an attacker would, because it makes the control objectives obvious. In MITRE ATT&CK terms, the forged token is T1606, forging web credentials, and what it buys the attacker is T1078, valid accounts. That combination is nasty because the subsequent activity looks like a legitimate user doing legitimate things.
Step one is reconnaissance against the gateway itself. The attacker pulls the public signing keys from the JWKS endpoint, which is supposed to be public, and collects a few legitimately issued tokens by signing up for a free tier or a trial account. Now they know the algorithm, the key identifiers, the issuer string, the audience, and the claim structure, including which claim carries roles or tenant identifiers.
Step two is mutation. They try alg none. They try HS256 with the public key. They try a jku pointing to their own server. They try a kid of ../../../../dev/null, which on some systems produces an empty key and a trivially forgeable HMAC. They try a token from a sister application with a different audience. Each of these takes seconds, and tools like jwt_tool and Burp Suite extensions automate the whole battery.
Step three is where the backend trust sponge pays off. Once any forged token is accepted, the attacker edits the role claim to admin and the tenant claim to someone else's tenant. The gateway forwards it, the service reads the headers, and the attacker is now an administrator of a customer account they have never seen. In OWASP terms (https://owasp.org/API-Security/editions/2023/en/0x11-t10/), you have chained API2 broken authentication into API1 broken object level authorization and API5 broken function level authorization in a single request.
Step four is quiet persistence. A smart attacker uses the forged admin access to create a real API key or OAuth client inside the platform, so that when the gateway gets patched, they still hold legitimate credentials. That is why the WSO2 response guidance included rotating credentials and reviewing created applications, not just applying the fix.
The direct header injection variant deserves its own mention because it requires no cryptography at all. If a backend service is reachable without passing through the gateway, through a forgotten internal load balancer, a Kubernetes service with a NodePort, or a staging hostname that resolves publicly, an attacker can simply send X-User-Id: 1 straight to it. I have seen this in production more than once. The gateway was flawless. It just was not in the path.
Control objectives for API gateway security testing that actually hold
If I map this to NIST SP 800-53, three controls carry most of the weight. IA-5 covers authenticator management, which here means the signing keys, their rotation, their storage, and the rule that the validator, not the token, decides which key and which algorithm are acceptable. SC-23 covers session authenticity, which is the formal name for making sure a session token cannot be forged or replayed outside its intended context. AC-3 covers access enforcement, and this is where the gateway-only model breaks down, because AC-3 says enforcement happens at the resource, and a backend that never checks anything is not enforcing access at all.
Translating those into engineering decisions, the gateway should pin the allowed algorithm per issuer in configuration and reject anything else, including none. It should fetch keys only from a JWKS URL defined in its own configuration, never from a URL inside the token, and it should ignore embedded jwk headers entirely. It should validate issuer, audience, expiry, and not-before on every request, with clock skew measured in seconds rather than minutes. It should treat kid as an opaque lookup key against a known set, not as input to a file path or query. And it should strip any inbound identity headers from the client request before it adds its own, because otherwise an attacker can send X-User-Id themselves and hope the gateway appends rather than replaces.
The backend side matters just as much, and this is the part platform teams push back on. Services should verify the token themselves, or verify a short-lived internal token the gateway mints and signs with a key the services trust, rather than reading bare headers. Services should enforce object-level and function-level authorization against their own data, because the gateway has no idea whether invoice 48213 belongs to tenant A or tenant B. And services should only be reachable through the gateway, enforced at the network layer with mutual TLS or a service mesh policy, not by convention. Defense in depth is not redundancy for its own sake here. It is the difference between one bug and one breach.
I wrote earlier this fall about the load balancer tier as an overlooked control plane (read it here), and the same logic applies. The appliances that route your traffic are security infrastructure, even when the org chart files them under networking.
How to scope an API pentest that forges tokens on purpose
Most API penetration tests I review are scoped wrong for this risk. The tester receives a valid token, a Postman collection, and a list of endpoints, and spends the engagement testing the services with legitimately issued credentials. That finds real bugs, such as injection, mass assignment, and object level authorization gaps, but it treats the gateway as a given. It never asks whether the token itself can be forged.
A properly scoped API gateway security testing engagement has two halves. The first half targets the gateway as an authentication system. The tester gets the JWKS endpoint, a low-privilege account in two separate tenants, and ideally a token from a second application registered with the same identity provider. Their job is to run the full mutation battery against the gateway, covering algorithm substitution, unsigned tokens, header-driven key lookups, cross-audience and cross-issuer replay, expired and not-yet-valid tokens, and identity header smuggling. The deliverable is a clear statement of which forgeries the gateway rejected and how, with request and response evidence for each.
The second half assumes the first half failed. This is the part most clients never ask for, and it is the most valuable part of the work. The tester is handed a token they could not legitimately obtain, or is given network access that bypasses the gateway, and is asked what the backend services do with it. Do they recheck signatures? Do they enforce tenant boundaries against their own data? Do they accept bare headers from an internal caller? This half of the test measures your blast radius, which is the number that actually matters to a CFO and an insurer.
Scoping should also include discovery of every path to the backend that does not go through the gateway. The tester should enumerate DNS, cloud load balancers, Kubernetes ingress and service objects, and any legacy hostnames, and try to reach the services directly. In my experience, this step finds something more often than the cryptographic tests do, which tells you something about how environments actually drift.
Finally, ask for detection validation. The tester should note the timestamp of each forged token attempt, and your SOC or logging pipeline should be able to show you those attempts afterward. A gateway that rejected thirty forged tokens in five minutes without a single alert is a gateway that will also stay quiet the day one of them works. Log the reason for every token rejection, ship those logs off the gateway host, and alert on bursts of signature or algorithm failures from a single client.
This week's intel happened to land on the web tier again, with the Drupal installer flaw under active exploitation and an unauthenticated RCE in the Idunno.AntiCsrf library on IIS. Neither is a JWT bug, but both reinforce the same point I made in the SQL injection post (read it here). The shared framework code that every route trusts is where one flaw becomes total compromise, and it deserves dedicated test time rather than incidental coverage.
What this looks like for a mid-sized SaaS team in practice
Let me make this concrete. Picture a fifty-person SaaS company in Frisco running a multi-tenant platform on Kubernetes, with Kong in front, Auth0 as the identity provider, and a dozen services written by four teams in three languages. Their last pentest was clean except for two medium findings. Their SOC 2 report is in good shape.
Week one, the platform team pins RS256 for their Auth0 issuer in the Kong JWT plugin configuration, confirms the JWKS URL is static, and adds explicit audience and issuer checks that were missing because the default plugin settings did not require them. They also configure Kong to strip inbound X-Tenant-Id and X-User-Id headers before adding its own. None of this is exotic. It is configuration that was never set because the defaults worked in the demo.
Weeks two through four, each service team adds a lightweight middleware that verifies the token signature and claims locally, using the same pinned algorithm and JWKS source, and enforces that the tenant in the token matches the tenant that owns the requested object. The teams grumble about latency until they measure it and find that local JWT verification with cached keys costs well under a millisecond.
Weeks five and six, the infrastructure team applies network policies so the services only accept traffic from the gateway namespace, and they discover two services that were also exposed through a legacy internal load balancer someone stood up for a partner integration back in 2023, and that finding alone justified the project.
Week eight, they bring in a tester with the two-halves scope described above. The gateway holds. The backend bypass attempt gets blocked at the network layer, and when the tester is given an injected token anyway, the services reject it on tenant mismatch. The report reads like a control validation rather than a list of problems, which is exactly what their enterprise customers' security questionnaires want to see.
That is roughly two months of focused work with no new products purchased. Most of the risk reduction came from configuration and a small amount of shared middleware, which is a reassuring answer for anyone bracing for a budget fight.
Keeping the gateway honest over time
Fixing the gateway once is not the same as keeping it fixed. Gateways get plugin updates, identity providers change key rotation behavior, new services get added by teams that missed the memo, and somebody eventually adds a second issuer for a partner and forgets to pin its algorithm. Treat the gateway's token validation configuration as code, put it under change review, and run an automated forged-token test suite against it in CI on every configuration change. The suite does not need to be clever. A handful of known-bad tokens that must always be rejected will catch most regressions.
Patch cadence matters too. Gateways and their plugins sit on the internet by design, and when the vendor ships an authentication fix, it should move on the same clock you use for VPN appliances, not the quarterly maintenance window. The WSO2 exploitation moved from advisory to active abuse fast, and the organizations that were hurt were the ones treating the API manager like middleware instead of like an edge device.
Retest after material changes, not only on the annual calendar. A new identity provider, a new gateway product, a new tenant model, or a merger that adds a second token issuer are all events that should trigger a focused API gateway security test. The annual pentest is the floor, and in API land the floor moves every sprint.
Bringing API gateway testing into one program
The WSO2 forged token attacks are a reminder that the most dangerous bugs are the ones sitting in the component everything else trusts. API gateway security testing that forges tokens on purpose, tests the backend as if the gateway already failed, and hunts for paths around the gateway entirely is how you turn a single point of failure back into one layer of several. None of this requires heroics. It requires pinning algorithms, checking audiences, stripping headers, making services verify their own tokens, and asking a tester to break the front door instead of politely walking through it.
This is the kind of work CyberSphere was built to keep organized. The platform's Penetration Testing module scopes web application and API assessments against the controls a team actually has to defend, including the gateway as its own target and the backend blast radius as a separate objective, then pushes each finding into the remediation queue with the request evidence attached so the platform team and the service teams are reading the same proof. When the retest comes around after the next gateway upgrade, the history is already there instead of living in a PDF somebody emailed last spring. You can see how it fits together at CyberSphere. Whatever tooling you use, test the token before you trust it, because the attackers already are.
Frequently Asked Questions
How quickly does Innovation Network Design respond to a security incident?
Our SOC triages and notifies within 15 minutes with confirmed details and containment steps, rather than handing you a queued alert. Incident response retainer clients carry a 2-hour guaranteed response.
Do you only work with businesses in the Dallas-Fort Worth area?
We are based in McKinney, Texas and work on-site across Plano, Allen, Frisco and the wider DFW metroplex. Our monitoring and response operate remotely, so we also support organizations nationwide.
How do we get started?
Start with a free assessment. Contact us or call 512-518-4408 and we will review your current setup and give you clear, prioritized recommendations before you commit to anything.
Happening right now?
Business email taken over, or a payment sent to the wrong account?
Call us now. The first hours matter most: your bank may still be able to recall the payment, and whoever is in the mailbox keeps access until it is locked down. We handle the lockout and help trace the payment.
Not an emergency? Get a free security assessment instead.
Danny Mercer
Innovation Network Design
With nearly a decade in cybersecurity and IT infrastructure, our team delivers expert insights to help businesses in McKinney, Dallas, and across DFW make informed security decisions. Have a question? Get in touch.
Ready to Secure Your Business?
Get a free security assessment and find out where your organization stands.