Skip to content
Account takeover Write-up Intermediate

Writeup 02: I know your JWT Private Key?

A test account's credentials were left in an HTML comment on the login page, and the JWT issued after login used a weak, guessable signing key. An attacker could log in as the test user, crack the key, forge a token with the admin flag set, and read the admin-only flag endpoint.

bl4ckd3v0p5 Follow

Published on medium.com

Another Challenge from Cyber Premier League hosted and organized by sanifu organization. Flag was hidden inside a page where only admin is authorized to access it.

BL4CKD3V0P5, 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

Likely two mistakes combined: test credentials were left in an HTML comment, and the JWT signing secret was weak enough to be cracked offline.

Impact

An authenticated low-privilege user could forge an admin token and read the admin-only flag endpoint, which in a real bank would mean unauthorised access to admin data.

What the attacker needed

Access to the login page source; a weak JWT signing secret; ability to run an offline cracking tool

The fix

The report says credentials should not be left in page source and that a strong, hard-to-guess JWT signing key should be used and rotated; it does not say the challenge was patched.

How it was found

  1. Open the bank portal and view the source of the login page.
  2. Find the test user credentials in an HTML comment and log in with them.
  3. Note the JWT returned in the login response and in the cookie.
  4. Enumerate the /api path to find the /flag endpoint.
  5. Crack the JWT signing key with john.
  6. Re-sign the token with isAdmin set to true, replace the cookie value, and request the flag endpoint.

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 a small signed note a website gives you after login, saying who you are. The site checks the signature with a secret key, so if that key is weak someone can guess it, change the note to claim they are an admin, and sign it again. Here the login page also had a test username and password hidden in the page source, which gave the attacker a starting account.

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.