Skip to content
Access control Write-up Beginner

How I Bought a Product for ₹1 and Forged an Admin Session: A Li

The application exposed its JWT signing secret in a public JavaScript file, letting an attacker forge an admin session, and its purchase endpoint trusted a client-supplied price with no authentication, allowing a product to be bought for one rupee. Both flaws were used to retrieve hidden CTF flags.

Kavitajoshi Kiran Follow

Published on medium.com

In application security, a common phrase is: “Security tools look for known patterns, but human testers look for logical mistakes.”

Kavitajoshi Kiran, 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 the JWT signing secret was shipped in client-side JavaScript, and the purchase endpoint trusted a client-supplied price without authentication or server-side validation.

Impact

An attacker could forge an admin session and buy products at an arbitrary price without authentication, though this was demonstrated only on a CTF application.

What the attacker needed

Access to the web application; ability to intercept HTTP requests

The fix

The report recommends removing secrets from client-side code, requiring authentication on sensitive endpoints, and validating prices server-side from an authoritative database.

How it was found

  1. Read robots.txt to find hidden paths /modi and /admin.
  2. Open the JavaScript file referenced by the admin page and find the hardcoded JWT secret.
  3. Extract your session JWT from the browser cookie store.
  4. Change the token payload role to admin and sign it with the exposed secret.
  5. Replace your cookie with the forged token and reload /admin to get the first flag.
  6. Intercept the buy request, remove the price constraint by setting it to 1, and resend to get the second flag.

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 signed piece of data a site uses to remember who you are; if the signing key leaks, anyone can create a token claiming to be an admin. Separately, the shop's buy request included the price, and the server believed whatever price the browser sent instead of checking its own database.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.