Skip to content
Account takeover Write-up Beginner

️ JWT Do It? How None Algorithm and Leaky Secrets Let Me Forge Admin Tokens

The application accepted JSON Web Tokens with the 'none' algorithm, so an attacker could forge a token with an admin role and gain access to the admin dashboard. Additionally, a .env file exposed the JWT secret key, allowing the attacker to sign valid tokens for any role.

infosecwriteups.com

Published on infosecwriteups.com

Free Link 🎈

Iski, on infosecwriteups.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 JWT implementation accepted tokens with the 'none' algorithm, skipping signature verification, and the secret key was exposed in a publicly accessible .env file.

Impact

The attacker could access the admin dashboard, view PII of over 100K users, delete accounts, change roles, and escalate any user to admin, support, or superadmin.

What the attacker needed

A free account; victim clicks a link; none

The fix

The application should always validate the JWT algorithm and reject 'none', restrict access to .env files, and use libraries that enforce signing.

How it was found

  1. Perform reconnaissance to find a development authentication endpoint.
  2. Log in as a normal user and capture the JWT from localStorage.
  3. Decode the JWT and notice the algorithm is set to 'none'.
  4. Modify the payload to set the role to 'admin' and re-encode without a signature.
  5. Send the forged token to access the admin dashboard.
  6. Discover a .env file containing the JWT secret key and use it to sign tokens for any role.

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 card that a website gives you after you log in. It contains information about you, such as your user ID and role, and is signed by the server to prevent tampering. If the server accepts tokens without checking the signature, or if the secret key used for signing is leaked, an attacker can create their own token claiming to be an administrator and access restricted areas.

What is Account takeover?

Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.

Similar reports

View all

Same bug class and techniques, clearest first.

Account takeover

The lesson behind this report.

Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.