Skip to content
OAuth / SSO Write-up Intermediate

JWT Authentication Bypass via JWK Header Injection

The server accepted a JSON Web Key (JWK) embedded in the JWT header without verifying its origin, so an attacker could supply their own RSA public key and sign a token impersonating any user, including administrators. This allowed full authentication bypass and administrative actions such as deleting users.

osintteam.blog

Published on osintteam.blog

JWT systems often rely on strict validation rules to ensure that only trusted keys can verify a token’s signature. In some implementations, servers allow a jwk (JSON Web Key) field to be included inside the JWT header.

Bash Overflow, on osintteam.blog

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 failed to validate that the JWK embedded in the JWT header belonged to a trusted issuer, instead using any key supplied by the token to verify the signature.

Impact

An attacker could generate administrator-level tokens, access restricted dashboards, extract sensitive data, or maintain long-term persistence by issuing additional forged tokens.

What the attacker needed

Valid low-privilege account; ability to intercept and modify HTTP requests

The fix

The server should not trust keys embedded in the JWT header; it should verify tokens only with keys from a trusted issuer or a preconfigured key set.

How it was found

  1. Log in with the provided credentials and capture a valid JWT from the account request.
  2. Use the JWT Editor extension to modify the subject claim to administrator.
  3. Generate a new RSA key pair in the JWT Editor Keys tab.
  4. Inject the public key as a JWK in the token header and re-sign the token with the private key.
  5. Send the forged token to the admin endpoint to gain administrator access.
  6. Use the admin endpoint to delete the target user.

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 uses to know who you are. Normally the website checks the signature using a key it trusts. Here, the website trusted a key that the attacker put inside the token itself, so the attacker could make a fake ID card that looked valid and pretend to be an administrator.

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.

Similar reports

View all

Same bug class and techniques, clearest first.

OAuth and single sign-on flaws

The lesson behind this report.

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.