I Forged My Own Admin Token by Exploiting JWT Algorithm Confusion ($8,500 Bounty)
The JWT verification library trusted the algorithm declared in the token header, so an attacker could change RS256 to HS256 and sign a forged token using the server's public key as the HMAC secret. This allowed privilege escalation to admin and cross-tenant access to any organisation's data.
Most developers who implement JWT authentication understand that the token needs a signature, and they understand that the signature needs a secret key. What a surprising number of them don’t fully internalize is that the algorithm used to verify that signature can, in a misconfigured implementation, be dictated by…
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 function was called without an explicit algorithms option, so it trusted the alg field from the token header and used the RSA public key as an HMAC secret when HS256 was specified.
Impact
An attacker could forge tokens to escalate to admin within their own organisation and to access any other organisation's documents, user lists, and audit logs, with no upper bound on affected accounts.
What the attacker needed
A standard user account; public JWKS endpoint accessible; knowledge of a valid org_id or user_id
The fix
The fix was to explicitly constrain the expected algorithm to RS256 in the verification call, which was applied as an emergency mitigation.
How it was found
- Fetch the JWKS endpoint to obtain the RSA public key in JWK format.
- Convert the JWK modulus and exponent into a PEM-formatted public key.
- Craft a JWT with alg set to HS256, keep the original kid, and modify the payload to set role to admin.
- Sign the forged token using the PEM public key with HS256.
- Send the forged token in the Authorization header to an admin API endpoint.
- Observe a 200 OK response with admin-level data, then repeat with a different org_id to access another organisation.
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 JWT is like a tamper-proof ID card. Normally the server signs it with a private key and checks it with a public key. Here the server let the card itself say which method to use for checking, so an attacker could switch to a method where the public key acts as the secret, letting them create valid cards for anyone.
What is Crypto?
Encryption, signatures, randomness or certificate checks that do not protect what they claim to.