How a JWT Algorithm Confusion Vulnerability Allowed a $4,500 Authentication Bypass
The API gateway's JWT verification did not enforce a specific algorithm, so an attacker could change the token's algorithm from RS256 to HS256 and sign it using the server's public RSA key as an HMAC secret. This allowed forging an admin token and gaining full administrative access across all tenant organisations.
JSON Web Tokens (JWTs) are the standard mechanism for stateless authentication in modern microservices. When implemented properly using asymmetric cryptography — such as RS256 (RSA Signature with SHA-256) — an Identity Provider signs tokens using a private key, while downstream microservices verify those tokens using…
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The JWT verification library was called without an explicit list of allowed algorithms, so it trusted the algorithm named in the token header and treated the RSA public key as an HMAC secret when the header said HS256.
Impact
The attacker could forge an administrative token and gain full administrative access across all tenant organisations.
What the attacker needed
A low-privilege account; access to the public JWKS endpoint
The fix
The JWT verification should explicitly enforce an allowlist of expected algorithms and isolate key types so the token header cannot dictate the cryptographic method.
How it was found
- Log in with a low-privilege account and obtain a JWT.
- Fetch the public key from the JWKS endpoint and convert it to PEM format.
- Change the token header algorithm from RS256 to HS256.
- Change the payload role to admin and set the subject to an administrative user ID.
- Sign the modified token with HMAC-SHA256 using the PEM public key as the secret.
- Send the forged token to an administrative API endpoint to gain access.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A JSON Web Token (JWT) is like a signed ID card that a server gives you after login. Normally the server checks the signature using a public key that only matches its private key. Here, the server also accepted a different signing method that uses a shared secret, and it mistakenly used its public key as that secret. So an attacker could create their own valid-looking admin ID card.
What is Crypto?
Encryption, signatures, randomness or certificate checks that do not protect what they claim to.