Business logic vulnerabilities
The e-commerce site applied a 15% discount coupon when the cart reached $400, but the coupon remained valid after items were removed and the cart value dropped to $120. An attacker could obtain the discount on a purchase below the threshold.
Published on sagarsajeev.medium.com
Bug Bounty
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.
Context
This is a write-up of a business logic flaw found in an e-commerce website. The site ran a promotion: any purchase whose cart total reached $400 or above received a 15% instant discount, with terms and conditions applying. The discount coupon was added to the cart automatically once the threshold was met, so the customer never had to enter a code.
The author quotes OWASP's definition of business logic vulnerabilities as ways of using the legitimate processing flow of an application in a way that results in a negative consequence to the organisation. The target's name is deliberately omitted: the security team allowed the write-up but asked that the website not be named.
Setup
No special tooling, accounts or roles are described. The researcher used a normal shopping flow on the public site: adding products to a cart, reaching the checkout page and completing a purchase. The only precondition was that the cart first had to reach the $400 threshold so that the automatic 15% coupon would be applied.
Finding it
The interesting part of the flow was the last checkout page. It listed every item in the cart and offered an option to remove any item from it. Removing items recalculates the cart value, and the natural expectation is that any discount tied to a minimum spend is re-evaluated at the same time. The researcher tested exactly that: after the coupon had been granted at the $400 threshold, items were removed until the cart value dropped to around $120, and the coupon was still valid, still offering the 15% instant discount even though the cart was far below the $400 minimum.
That mismatch between the advertised condition (a $400 minimum) and the state of the cart (about $120) is what made the behaviour look wrong.
Exploitation
Step 1: Reach the discount threshold
The researcher added products to the cart until the cart value reached the $400 threshold required for the promotion.
Step 2: Let the coupon be applied
Once the threshold was met, the 15% discount coupon was added automatically. No manual coupon entry was involved.
Step 3: Remove items at the checkout page
On the last checkout page, which lists all items in the cart and provides an option to remove any item, the researcher removed a number of items and brought the cart value down to around $120.
Step 4: Observe that the coupon survives
After the removals, the coupon was still valid and the 15% instant discount was still offered, despite the cart value being less than $400.
Step 5: Complete the purchase
The researcher made the purchase for $120, and the invoice confirmed that the discount had indeed been applied.
No HTTP requests, parameters, headers or responses are reproduced in the write-up; the steps above are the whole of the demonstrated flow.
Root cause
The report does not describe the server-side implementation, so the exact mistake is not shown. What the behaviour implies is that the eligibility check for the coupon ran when the coupon was granted (when the cart crossed $400) and was not repeated when the cart contents changed at checkout. The behaviour suggests the discount was treated as still valid while the cart total was recalculated, so the two drifted apart. The report does not describe any defences or how the promotion logic was implemented.
Impact
An attacker could obtain the 15% instant discount on a cart well below the advertised $400 minimum: in the demonstrated case, a cart of around $120 was purchased with the discount applied and confirmed on the invoice. The loss falls on the merchant, which honours a discount that its own terms do not allow. The report does not quantify how often this could be repeated or what the total exposure would be. The security department of the e-commerce site rated it as a high severity bug.
Fix
The behaviour described implies the fix should be to re-validate the coupon's minimum-spend condition whenever the cart contents change, in particular on item removal at checkout, and again when the order is placed, so that a coupon granted at $400 is withdrawn or recalculated once the total falls below the threshold.
Variants to test
- Remove items after a minimum-spend coupon is applied, as here. A positive result is the discount remaining on a cart below the threshold and appearing on the invoice.
- Change item quantities downward at checkout rather than removing lines. A positive result is the same stale discount surviving the recalculation.
- Apply a coupon at the threshold, then swap items for cheaper ones. A positive result is the coupon staying attached to a cart that no longer qualifies.
- Test other threshold-based benefits, such as free shipping or gift items, the same way. A positive result is the benefit persisting after the qualifying total drops.
- Check whether the discount is re-evaluated at order placement or only in the cart UI. A positive result is the server accepting an order whose stored total no longer meets the condition.
Timeline
| Event | Date |
|---|---|
| Submitted | 28-07-2022 |
| Accepted | 28-07-2022 |
| Resolved | 29-07-2022 |
| Bounty awarded | 29-07-2022 |
The researcher received $400 as a bounty plus an additional $200 coupon redeemable only on that e-commerce site. The security team responded, resolved and rewarded within 24 hours.
The author's closing tip: logic vulnerabilities tend to be unique, so the best approach is to try things that can break the application logic, and when a function seems obvious, think about how a malicious user could exploit it.
What happened, in plain words
Imagine a shop that says: spend $400 or more in one order and we will take 15% off the whole bill. The discount is applied automatically at the checkout, so you do not need a code. Now imagine you fill your basket to $400, the discount appears, and then, on the final checkout page, you remove most of the items until the basket is only about $120. A sensible shop would notice that you no longer qualify and remove the discount. This shop did not. The 15% discount stayed on the order, and the researcher bought about $120 of goods with the discount applied. The invoice confirmed it.
That is a business logic vulnerability: the website followed its normal steps correctly, but the rules it was supposed to enforce had a gap. The researcher, Sagar Sajeev, reported it to the shop's security team. They rated it high severity, resolved it, and paid a $400 bounty plus a $200 store coupon, all within 24 hours. The shop asked not to be named, so the write-up does not name it.
This article walks through the same story for someone who has never done security testing. You only need a browser and the ability to click around a shopping site. Every technical term is explained where it first appears, and there is a glossary at the end.
Background: what an e-commerce site and a cart are
An e-commerce website is an online shop. You browse products, put them in a virtual basket (the cart), and pay at the end. The cart is not just a picture on your screen: the shop's server keeps a record of what is in it, how much it costs, and any discounts that apply. The server is the computer that runs the shop and stores the real data; your browser is just the window you look through.
A promotion is a temporary rule, such as "spend $400 and get 15% off". The shop's programmers write code that checks the rule. When the rule is met, the shop adds a coupon to your cart. A coupon here is not a piece of paper: it is a discount entry in the shop's system that says "this order gets 15% off". Because the shop adds it automatically, you never type a code.
The author quotes OWASP, a well-known organisation that publishes security guidance, defining business logic vulnerabilities as ways of using the legitimate processing flow of an application in a way that results in a negative consequence to the organisation. In plain words: you use the site exactly as it is meant to be used, but in an order or combination the programmers did not think about, and the shop loses money.
Setting up
There was no special setup. No hacking tools, no special accounts, no administrator access. The researcher used the public shop like any customer: added products to the cart, went to checkout, and paid. The only precondition was to get the cart to $400 first, because that is what triggers the automatic 15% coupon. Think of it like testing a vending machine: you do not need to open it, you just press the buttons in an unusual order.
Finding it
The checkout page and the remove option
The last checkout page is the screen where you review your order before paying. It lists every item in the cart and, on this site, offered a link or button to remove any item. When you remove an item, the shop recalculates the cart total. You would expect it to also recheck any discount that depends on a minimum spend. That is the natural behaviour: if the condition no longer holds, the benefit should go away.
The researcher tested exactly that expectation. After the coupon had been granted at the $400 threshold, they removed items until the cart was around $120. The coupon was still valid and still offered the 15% discount, even though the cart was far below the $400 minimum. The mismatch between the advertised condition (spend $400) and the actual cart (about $120) is what made the behaviour look wrong.
Why does this matter? Because the shop is honouring a discount its own terms do not allow. The shop honours a discount its own terms do not allow.
Exploitation, step by step
Step 1: Reach the discount threshold
The researcher added products to the cart until the total reached $400, the amount required for the promotion. This is the normal, intended way to earn the coupon. Without this step, there is no coupon to test.
Step 2: Let the coupon be applied
Once the cart hit $400, the 15% discount coupon was added automatically. No code was entered. The shop's server decided the order qualified and attached the discount. At this moment everything is correct: the cart meets the condition.
Step 3: Remove items at the checkout page
On the final checkout page, which lists all items and offers a remove option, the researcher removed a number of items and brought the cart value down to around $120. The goal was to see whether the shop would notice that the condition for the discount no longer held. Removing items is a completely normal feature; the question is what happens to the discount afterwards.
Step 4: Observe that the coupon survives
After the removals, the coupon was still valid and the 15% instant discount was still offered, despite the cart being less than $400. The total shown was lower, but the coupon's condition was not rechecked. In everyday terms: the shop checked your ticket at the door but not again when you left with the goods.
Step 5: Complete the purchase
The researcher bought the roughly $120 cart, and the invoice confirmed the discount had been applied. The invoice is the final record of the sale, and it showed the discount had been applied.
The write-up does not include any HTTP requests, parameters, headers or responses. The steps above are the whole of the demonstrated flow. There are no code blocks to copy because the researcher did everything through the normal web interface.
Why it worked (root cause)
The report does not describe the server-side code, so we cannot see the exact mistake. But the behaviour tells us what likely happened: the shop checked the $400 condition when it granted the coupon, and did not check it again when the cart changed at checkout. The discount appeared to stay valid once it had been granted. Meanwhile the cart total was recalculated independently. The two values drifted apart: the total went down, the discount stayed.
In plain words: the shop remembered "this order qualified" and never asked again.
Impact
An attacker could get the 15% discount on a cart well below the $400 minimum. In the demonstrated case, a cart of around $120 was purchased with the discount applied and confirmed on the invoice. The loss falls on the merchant, which honours a discount its own terms do not allow. The shop's security department rated it as a high severity bug.
How to fix it
The behaviour implies the fix should be to re-validate the coupon's minimum-spend condition whenever the cart contents change, especially when an item is removed at checkout, and again when the order is placed. That way, a coupon granted at $400 is withdrawn or recalculated once the total falls below the threshold. In everyday terms: check the ticket again at the exit, not just at the door.
Other things to test
These are variations on the same idea. They are listed so you can recognise the pattern, not as instructions to attack a site without permission.
- Remove items after a minimum-spend coupon is applied, as here. A positive result is the discount remaining on a cart below the threshold and appearing on the invoice.
- Change item quantities downward at checkout rather than removing lines. A positive result is the same stale discount surviving the recalculation.
- Apply a coupon at the threshold, then swap items for cheaper ones. A positive result is the coupon staying attached to a cart that no longer qualifies.
- Test other threshold-based benefits, such as free shipping or gift items, the same way. A positive result is the benefit persisting after the qualifying total drops.
- Check whether the discount is re-evaluated at order placement or only in the cart UI. A positive result is the server accepting an order whose stored total no longer meets the condition.
Timeline
| Event | Date |
|---|---|
| Submitted | 28-07-2022 |
| Accepted | 28-07-2022 |
| Resolved | 29-07-2022 |
| Bounty awarded | 29-07-2022 |
The researcher received $400 as a bounty plus an additional $200 coupon redeemable only on that e-commerce site. The security team responded, resolved and rewarded within 24 hours.
The author's closing tip: logic vulnerabilities tend to be unique, so the best approach is to try things that can break the application logic, and when a function seems obvious, think about how a malicious user could exploit it.
Glossary
- Business logic vulnerability: a flaw in the rules a website follows, where normal features are used in an unexpected order or combination to produce a result the site's owners did not intend.
- E-commerce website: an online shop where you browse products, add them to a cart, and pay.
- Cart: the virtual basket that holds the items you intend to buy, along with their prices and any discounts.
- Checkout page: the final screen where you review your order, remove items, and pay.
- Coupon: a discount entry in the shop's system that reduces the price, here added automatically when a condition is met.
- Promotion: a temporary rule, such as "spend $400 and get 15% off".
- Threshold: the minimum amount you must spend to qualify for a promotion.
- Server: the computer that runs the website and stores the real data; your browser displays it.
- Client: the browser or app you use; it sends requests to the server.
- Request: a message your browser sends to the server asking for something, such as a page or an action.
- Response: the server's reply to a request.
- HTTP: the language browsers and servers use to exchange requests and responses.
- Parameter: a piece of data sent with a request, such as an item ID or a quantity.
- Header: extra information attached to a request or response, such as the type of browser or a cookie.
- Cookie: a small piece of data a site stores in your browser so it can remember you between requests, for example to keep your cart.
- Token: a value used to prove who you are or to authorise an action, often stored in a cookie or header.
- API: a way for programs to talk to each other; a website's own pages use APIs behind the scenes to fetch and change data.
- Invoice: the final record of a sale, showing items, prices, discounts and the amount charged.
- Root cause: the underlying reason a vulnerability exists, as opposed to its visible symptom.
- Re-validate: check a condition again, at the moment it matters, rather than trusting an earlier check.
- State: the current situation of an order or cart, such as its contents and total.
- Stale: old information that is no longer true but is still being used.
- OWASP: a non-profit organisation that publishes widely used security guidance and definitions.
- Bounty: a reward paid by a company to someone who reports a security problem responsibly.
- Severity: a rating of how serious a vulnerability is, often high, medium or low.
- UI (user interface): the part of a website you see and interact with in the browser.