*JWT Authentication Bypass via Algorithm Confusion With No Exposed Key*
The application accepted JWT tokens with a symmetric algorithm (HS256) even though it normally used RSA (RS256), and it treated the RSA public key as the HMAC secret. An attacker who obtained a legitimate token could derive the public key from it, forge a token claiming to be an administrator, and access the admin panel to delete a user.
Published on meetcyber.net
RSA is normally used in asymmetric mode, meaning the server signs tokens with a private key and verifies them using the public key. In a secure environment, this separation prevents users from forging their own valid tokens.
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
Likely the server did not restrict the JWT 'alg' header to a whitelist and allowed HS256, then used the RSA public key as the HMAC secret.
Impact
An attacker with any legitimate account could forge tokens for any user, including administrators, leading to administrative access and account takeovers.
What the attacker needed
A free account on the target; ability to capture HTTP traffic; Docker installed to run the tool
How it was found
- Log in as wiener and capture two separate JWTs from the responses.
- Use the sig2n tool with the two tokens to derive the RSA public key and produce tampered JWT variants.
- Send a request to /my-account with the tampered JWT from the x509 key version to confirm it is valid.
- In JWT Editor, create a symmetric key using the Base64-encoded x509 key as the secret.
- Modify the JWT header to HS256 and the payload sub to administrator, then sign it.
- Send a request to /admin with the forged JWT to access the admin panel and delete user carlos.
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 a token a website gives you after login to prove who you are. Normally the site signs it with a private key that only the site knows, and checks it with a public key. Here the site also accepted tokens signed with a shared secret, and it used its public key as that secret, so anyone who saw a public key could create their own valid token for any user.
What is Crypto?
Encryption, signatures, randomness or certificate checks that do not protect what they claim to.