Skip to content
Leaked secrets Write-up Beginner

$750 Bug Bounty: The Story of a Hidden Discount Code in JS Files.

A publicly accessible JavaScript file contained a hardcoded employee-only coupon code that gave a 70% discount without any verification. Anyone who found the code could buy products at a large discount, causing financial loss to the company.

medium.com

Published on medium.com

While exploring an e-commerce platform, I stumbled upon a hidden JavaScript file containing a secret coupon code EM70%. This code allowed anyone to buy products at a 70% discount without verification.

Tanvir Ahmed, 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 a hardcoded employee-only coupon code was left in a publicly served JavaScript file and the discount was not restricted server-side.

Impact

Anyone with access to the JavaScript file could buy products at a massive discount, bypassing internal policies and posing a serious financial risk that could be exploited at scale.

What the attacker needed

Access to the public JavaScript file; a product to purchase

The fix

Internal coupon codes should not be stored in publicly accessible JavaScript files, and all discount codes should be verified server-side so only authorised users can redeem them.

How it was found

  1. Search GitHub and find large JavaScript files belonging to the target.
  2. Check several files until a coupon code is found near the bottom of one file.
  3. Go to the target site, select a product, and enter the code at checkout.
  4. Observe the price drop, confirming the code works without verification.

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 website's JavaScript files are downloaded by every visitor's browser, so anything written inside them is public. Here, a secret discount code meant for staff was left in one of those files. Anyone who read the file could use the code to buy products very cheaply, and the site did not check whether the person was allowed to use it.

What is Leaked secrets?

Keys, tokens or passwords left in public code, apps, logs or responses, that grant real access.

Similar reports

View all

Same bug class and techniques, clearest first.

Leaked secrets and credentials

The lesson behind this report.

Keys, tokens or passwords left in public code, apps, logs or responses, that grant real access.