JWT Authentication Bypass via jku Header Injection
The server accepted a JWT whose jku header pointed to an attacker-controlled JWKS URL, allowing the attacker to sign a token with their own RSA key and change the subject to administrator. This let them access the admin panel and delete another user's account.
medium.com
Published on medium.com
This vulnerability revolves around how the application handles JSON Web Tokens (JWTs) and, more specifically, how it trusts external key sources.
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
Impact
An attacker could forge tokens to escalate privileges and access administrative functions without credentials.
What the attacker needed
Valid user credentials; ability to host a file on an external server; Burp Suite with JWT Editor extension
How it was found
- Log in with the provided user credentials and capture the request to /my-account?id=wiener.
- Generate a new RSA key pair in Burp's JWT Editor extension.
- Create a jwks.json file containing the public key and host it on the exploit server.
- Modify the JWT header to set the jku parameter to the exploit server URL and change the sub claim to administrator.
- Sign the token with the private key and forward the request to /admin.
- Send a delete request to remove the carlos account.
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 website gives you after login. The server checks the signature using a public key, which it normally gets from a trusted address. Here, the server trusted any address the token named, so an attacker could supply their own key and forge an admin ID.
What is OAuth / SSO?
Mistakes in OAuth, OpenID Connect, SAML or token handling that leak codes and tokens or link an attacker's identity to a victim's account.