JWT None Algorithm Lab: Forge an Admin Token Without a Key

✨ AI Summary
InvoiceCloud signs your login token so nobody can change it. But the token itself tells the server which algorithm to use to check the signature, and the server believes it. Tell it to use no algorithm at all, and it stops checking. Change one word in your token and you are the admin.
Lab at a glance: Beginner · 80 XP · about 15 minutes · runs in your browser, no signup or setup. Try it yourself first; the full solution is behind a spoiler below.

What this lab teaches

A JSON Web Token (JWT) is three base64url-encoded parts joined by dots: a header, a payload and a signature. The header names the signing algorithm, the payload carries claims like your username and role, and the signature proves the server issued it.

This lab teaches why a server must decide for itself how tokens are verified, and never let the token decide.

How InvoiceCloud uses JWTs

After you log in as a guest, the lab shows your token. A “Verify Token” control sends a token to the verifier, which reads the algorithm from the token header and checks the signature accordingly. If the payload says your role is admin, the lab marks you solved.

The attack approach

  • Decode your token. The header and payload are just base64url-encoded JSON, readable by anyone.
  • Look at the algorithm in the header and the role in the payload.
  • The JWT standard defines an algorithm called none, meaning “unsigned”. A safe verifier rejects it; this one does not.
  • Build a token that says “no signature” and claims the admin role.

Full walkthrough (spoiler)

Stuck after a few attempts? Open the steps below. Solving it yourself first is worth more XP, and more learning.

Show the step-by-step solution
  1. Copy your token and decode its header and payload. You can use the browser console or any JWT decoder.
  2. Write a new header that sets the algorithm to none, and a new payload that keeps your user but sets the role to admin.
  3. Base64url-encode each part: standard base64, then remove the padding and swap the two URL-unsafe characters. The lab’s hints show exactly how.
  4. Join header and payload with a dot and add a trailing dot with nothing after it, because there is no signature.
  5. Paste the forged token into Verify Token. The verifier sees “no algorithm”, skips the signature check, reads your admin role and the lab marks you solved.

Why it works

The signature is the only thing that stops anyone editing a JWT. By letting the token choose its own verification method, the server let the attacker switch verification off. The payload was never secret, just signed, so once the signature check is skipped, every claim in it can be rewritten.

Core principleThe server decides which algorithm and key verify a token. Reject anything that does not match, especially none.

Where this happens in the real world

In 2015 researchers showed that several popular JWT libraries accepted alg: none tokens, or could be tricked into verifying with the wrong kind of key, because they trusted the header. Libraries were patched (for example the Node.js jsonwebtoken issue tracked as CVE-2015-9235), but the mistake keeps returning in hand-written verifiers and old dependencies, and JWT flaws remain a regular bug bounty finding.

How to defend against it

  • Pin the algorithm. Pass the expected algorithm to your verify call explicitly and reject tokens whose header disagrees.
  • Never accept none for authentication tokens.
  • Use a maintained library and keep it updated, rather than decoding and checking tokens yourself.
  • Keep secrets out of the payload. It is encoded, not encrypted.
  • Validate the other claims too: expiry, issuer and audience.
Mr Elite tip: When you meet a JWT in a real test, decode it first and read every claim. Then try the classic checks: none algorithm, an empty signature, an expired token, and the algorithm confusion trick from our advanced JWT lab.

Try it, then go further

Reading about it is the easy part. Open the lab, try your own approach before peeking at the spoiler, and see how many attempts it takes.

❓ Frequently asked questions

What is the JWT none algorithm attack?
An attack where the token header is changed to say the algorithm is none, so a vulnerable server skips signature verification and accepts a token with any claims the attacker wants.
Is a JWT encrypted?
Usually not. A standard signed JWT is only base64url-encoded, so anyone can read the header and payload. The signature only proves it was not changed.
How do I prevent JWT none attacks?
Tell your JWT library exactly which algorithm to expect, reject none, and keep the library up to date.
What should I try next?
The JWT algorithm confusion lab, which forges a token by abusing a server that accepts both RS256 and HS256.
⚡
Join free to earn XP for reading this article Track your progress, build streaks and compete on the leaderboard.
Join Free
Lokesh N. Singh aka Mr Elite
Lokesh N. Singh aka Mr Elite
Founder, Securityelites · AI Red Team Educator
Founder of Securityelites and creator of the SE-ARTCP credential. Working penetration tester focused on AI red team, prompt injection research, and LLM security education.
About Lokesh ->

Leave a Comment

Your email address will not be published. Required fields are marked *