Skip to content
OAuth / SSO Write-up Beginner

JWT: How I turned a Regular User into an Admin in 3 Steps

A JWT implementation accepted tokens with the algorithm set to 'none', skipping signature verification. An attacker could forge a token with an admin role and gain administrator access.

medium.com

Published on medium.com

Imagine a regular user signing up for your application. They have basic permissions and can only view their own profile.

0xPedrop, on medium.com

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 server trusted the algorithm specified in the token's header and accepted 'none', thereby skipping signature verification.

Impact

An attacker could escalate from a regular user to an administrator, gaining full access to all data.

What the attacker needed

A free account; server accepts alg:none

The fix

The server should enforce the expected algorithm (e.g., HS256) during verification instead of trusting the client-supplied alg value.

How it was found

  1. Register and log in as a regular user to obtain a valid JWT.
  2. Decode the token and change the header's alg value to 'none'.
  3. Modify the payload to set the role to 'admin' and discard the signature.
  4. Replace the stored token with the forged one and reload the page.
  5. Access the admin panel, which is now enabled.

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 digital ID badge that a server gives you after login. The server is supposed to check a special signature on the badge to make sure nobody tampered with it. In this case, the server was tricked into ignoring the signature, so someone could change their badge to say 'admin' and the server believed it.

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.