Skip to content
Crypto Write-up Intermediate

Cracking JWTs: A Bug Bounty Hunting Guide [Part 6]

The server trusted the JWT 'alg' header and accepted a token signed with HS256 using the server's own public key as the HMAC secret. An attacker could forge an administrator token and access the admin interface to delete a user.

infosecwriteups.com

Published on infosecwriteups.com

Welcome back, Hackers! This is Part 6 of my Cracking JWTs series — your one-stop guide to mastering JWT exploitation techniques in real-world bug bounty hunting.

Aditya Bhatt, 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

Impact

An attacker could bypass authentication, impersonate an administrator, and delete users without knowing the private key.

What the attacker needed

Access to the lab environment; valid user credentials; Burp Suite with JWT Editor extension

The fix

The server should enforce a strict expected algorithm and never use a public key as an HMAC secret.

How it was found

  1. Log in to the lab with the provided credentials.
  2. Try to access /admin and see the admin-only message.
  3. Send the /admin request to Burp Repeater.
  4. Fetch the server's public key from the JWKS endpoint.
  5. Create a symmetric key in JWT Editor using the Base64-encoded public key as the secret.
  6. Modify the JWT to set alg to HS256 and sub to administrator, sign it with the symmetric key, and send the request.

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 JWT is a signed token that proves who you are. The server checks the signature using a key. Here the server let the attacker choose the checking method and used its own public key as a shared secret, so the attacker could sign a fake admin token.

What is Crypto?

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.

Similar reports

View all

Same bug class and techniques, clearest first.

Cryptographic weaknesses

The lesson behind this report.

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.