Exploiting a Logic Bug in Discount Codes Generation
The club feature allowed users to join without email verification and generate new discount codes each time they deactivated and reactivated their account, while old codes remained valid. An attacker could collect thousands of valid discount codes, leading to financial loss for the business.
medium.com
Published on medium.com
In online shopping, we will find a wonderful feature most sites offer: discount codes, which provide great discounts on some products. So, what happens when hackers find a logic bug that allows them to create thousands of discount codes?
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 system generated new discount codes on each club rejoin without invalidating previous codes and without enforcing email verification.
Impact
An attacker could generate unlimited valid discount codes, potentially causing financial loss and abuse of membership privileges; the WAF did not block the automated collection.
What the attacker needed
A free account; ability to intercept HTTP requests; no email verification required
How it was found
- Create an account and join the club via the join endpoint.
- Obtain a CSRF token by adding a product to favourites and intercepting the request.
- Send a POST request to the join endpoint with the CSRF token.
- Read the discount codes from the discount codes endpoint.
- Deactivate and reactivate the account to receive new discount codes.
- Repeat the process to collect thousands of codes.
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 discount code is a short string that gives money off a purchase. The website let people get new codes over and over without checking their email, and it never cancelled the old ones. So someone could gather many working codes and use or sell them, costing the shop money.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.