How to Buy a €666 Collectible for Free
The server's duplicate coupon check only compared a new code against the last applied code, not all codes in the basket. By alternating two valid coupons, an attacker could apply each multiple times and reduce a €666 item to €0.00.
medium.com
Published on medium.com
Ethical Hacking
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
The target was the Intigriti October 2026 Halloween Store challenge, reachable at https://challenge-1026.challenges.intigriti.io/challenge. It is a small storefront: you receive €66 of store credit, a collectible costs €666, and checkout is disabled until your balance covers the order. The goal was to complete a checkout, not to find a hidden route or a secret endpoint.
The front-end made the objective explicit. After a successful checkout it renders a flag box if the receipt contains a flag:
${receipt.flag ? `<div class="flag-box">...</div>` : ""}
So the task was to make the store accept an order that the available balance could not cover. The flag itself was INTIGRITI{[redacted]}.

Setup
No accounts, roles or special tooling are described beyond the challenge environment itself. The preconditions were:
- €66.00 of store credit on the basket.
- A €666.00 collectible, so the balance was far short of the price.
- Two coupons available to the store:
NIGHT20(20% off) andNEWS30(30% off, first order only).

Using both coupons once gave 50% off: €666 became €333, still far above the €66 balance. The discount values were not the interesting part; the question was how the server decided whether a coupon had already been used.
Finding it
The browser sent coupon codes to POST /api/cart/coupon. The server rejected a code if it matched basket.lastCouponCode:
if (basket.lastCouponCode === code) { return res.status(409).json({ error: "coupon_already_applied" });}
That is the entire duplicate check. It compares the new code with the last code, not with every code already in the basket. The basket already had a promotions array holding all applied coupons, but the server did not use it for duplicate detection. It also exposed a lastCouponCode field, which made the mistake easy to spot once codes were alternated.
The guard therefore enforced the wrong rule:
- Intended rule: each coupon code may be applied at most once per basket.
- Implemented rule: a coupon code may not be applied twice in a row.
So NIGHT20 → NEWS30 → NIGHT20 was allowed. The second NIGHT20 was not a duplicate of the last code, so the check passed and the server added it to promotions again.

Exploitation
Step 1: apply the first coupon
The request was ordinary:
POST /api/cart/coupon HTTP/2Host: challenge-1026.challenges.intigriti.ioContent-Type: application/json
{"code":"NIGHT20"}
This returned 200 and took the subtotal from €666.00 to €532.80, a €133.20 discount, with NIGHT20 ×1 in the basket.
Step 2: repeat the same code
Sending NIGHT20 again returned 409, because it matched lastCouponCode. The basket stayed at €532.80 with NIGHT20 ×1.
Step 3: apply the second coupon
Sending NEWS30 returned 200. The total became €333.00, a €333.00 discount, with NIGHT20 ×1, NEWS30 ×1 in the basket.
Step 4: repeat the second code
Sending NEWS30 again returned 409. The total stayed at €333.00 with NIGHT20 ×1, NEWS30 ×1.
Step 5: go back to the first coupon
Sending NIGHT20 again returned 200. Because the last code was NEWS30, the duplicate check passed and the coupon was added a second time. The total became €199.80, a €466.20 discount, with NIGHT20 ×2, NEWS30 ×1 in the basket.
Step 6: go back to the second coupon
Sending NEWS30 again returned 200. The total became €0.00, a €666.00 discount, with NIGHT20 ×2, NEWS30 ×2 in the basket.
The full sequence, as the report presents it:
1 NIGHT20 200 €133.20 €532.80 NIGHT20 ×12 NIGHT20 409 €133.20 €532.80 NIGHT20 ×13 NEWS30 200 €333.00 €333.00 NIGHT20 ×1, NEWS30 ×14 NEWS30 409 €333.00 €333.00 NIGHT20 ×1, NEWS30 ×15 NIGHT20 200 €466.20 €199.80 NIGHT20 ×2, NEWS30 ×16 NEWS30 200 €666.00 €0.00 NIGHT20 ×2, NEWS30 ×2
The duplicate attempts returned 409; the alternating attempts returned 200. Each coupon was calculated against the original subtotal, not the running total:
subtotal = €666.00NIGHT20 (20%) = €133.20NEWS30 (30%) = €199.80NIGHT20 (20%) = €133.20NEWS30 (30%) = €199.80 --------total discount = €666.00final total = €0.00
Twenty plus thirty plus twenty plus thirty is one hundred: the store had discounted the entire item while applying only valid codes.
Step 7: check out
With the balance covering the order, checkout returned the receipt:
{ "ok": true, "receipt": { "flag": "INTIGRITI{...}" }}


Root cause
The vulnerability is a state-management mistake, not a maths mistake. The server held two pieces of state:
lastCouponCode, a single string.promotions, a list of applied discounts.
The duplicate check used the single string, while the discount calculation used the list. That mismatch is the whole exploit: the guard was looking at the wrong source of truth. The check was also order-dependent. Applying the same code twice in a row failed; applying it again after a different code succeeded. A correct check would not care about order at all.
No request tampering, secret guessing or authentication bypass was needed. Two valid coupons used in an order the server did not expect were enough.
Impact
In the challenge, the impact was a €0.00 order and a flag. In a production storefront, the same pattern is a direct business-logic risk: a customer can stack valid coupons, drive an order to zero, and bypass the price of any item the coupon rules cover. If the store issues credit or cashback, the same flaw could turn a discount into a payout. The severity depends on the store, but the class of bug is not exotic: a single-field duplicate check standing in for a set-membership check.
Fix
The server already had the right data; it needed to use it:
const alreadyApplied = basket.promotions.some( (promotion) => promotion.code === code);
if (alreadyApplied) { return res.status(409).json({ error: "coupon_already_applied" });}
This checks the set of applied codes instead of the last element, making the duplicate check order-independent and idempotent per coupon. Two defence-in-depth checks are also worth adding:
- Clamp the total at zero and reject a checkout if the discount exceeds the subtotal.
- Validate that the sum of percentage discounts cannot exceed 100%.
The primary bug remains the duplicate check: the guard should ask whether a code has ever been applied, not whether it was the last thing seen.
- Alternating two or more valid codes. Apply code A, then B, then A again, then B again. A positive result is a
200on the repeated code and a total that drops below what a single application of each coupon should allow. - Three or more codes in rotation. If the guard only remembers one previous value, rotating A, B, C, A, B, C should keep succeeding. A positive result is each repeat returning
200and the discount accumulating beyond the intended cap. - Order sensitivity. Apply the same code twice in a row, then once more after a different code. A positive result is
409on the consecutive attempt and200on the separated one, which confirms the check is positional rather than set-based. - Discount stacking against the original subtotal. Watch whether each coupon is computed on the original price or the running total. A positive result is a final total of zero or below while every individual code is legitimate.
- Response fields that leak state. Look for fields such as
lastCouponCodeor a promotions list in basket responses. A positive result is a response that shows only the most recent code while the discount calculation clearly uses the full list. - Checkout after a zeroed total. Confirm that checkout accepts the order once the balance covers it. A positive result is a receipt containing the flag or order confirmation with no further validation of how the total was reached.
What happened, in plain words
A small online shop was set up as a security challenge. You start with €66 of store credit, and the thing you want to buy costs €666. The shop will not let you check out until your balance covers the price. The goal was to complete a checkout anyway, and the reward for doing so was a flag: a short piece of text that proves you solved the challenge.
The shop offered two discount coupons. Used once each, they took 50% off, which still left €333 to pay, far more than the €66 you had. The weakness was not in the discount amounts. It was in how the shop remembered which coupons you had already used. The server only remembered the single most recent coupon code, so if you alternated between the two coupons, it kept accepting them. Four coupon requests later the total was €0.00 and the receipt contained the flag.
This is a beginner's walkthrough of that challenge. It explains every idea from scratch: what a server is, what an API request is, what a coupon check does, and why a check that looks reasonable can be broken by simply changing the order of your actions.

The setup
The target was the Intigriti October 2026 Halloween Store challenge, reachable at https://challenge-1026.challenges.intigriti.io/challenge. Intigriti is a platform that runs security challenges and bug bounty programmes; a challenge is a deliberately vulnerable application you are allowed to attack, in a safe environment, to practise.
A few terms before we go further:
- A server is the computer (or program) that holds the shop's data and decides what is allowed. Your browser is the client: it asks, the server answers.
- An API is the way the browser talks to the server behind the scenes. When a web page needs to change something, such as adding a coupon to a basket, it sends a small message to a specific address on the server, called an endpoint, and the server replies with data. Think of an API as a service counter: you hand over a request form at a named window, and the clerk hands back a result.
- A basket (or cart) is the server's record of what you intend to buy, plus any discounts applied to it.
- A coupon is a code that changes the price. The server keeps track of which codes have been applied to your basket.
The challenge is a small storefront. You receive €66 of store credit, a collectible costs €666, and checkout is disabled until your balance covers the order. The goal was to complete a checkout, not to find a hidden route or a secret endpoint.
The front-end made the objective explicit. The front-end is the part of the site that runs in your browser and draws the page. After a successful checkout it renders a flag box if the receipt contains a flag:
${receipt.flag ? `<div class="flag-box">...</div>` : ""}
Line by line:
${ ... }means "put the result of this expression into the page here". It is template syntax used by JavaScript to build HTML.receipt.flagmeans "look inside the receipt object for a field calledflag". A field is a named piece of data, like a box with a label on it.?is the conditional operator: if the thing before it is true, use the value before the colon; otherwise use the value after it.`<div class="flag-box">...</div>`is a snippet of HTML, the language that describes page elements. It would draw a box on the page.: ""means: if there is no flag, insert an empty string, that is, nothing.
So the page only shows the flag box when the server's receipt contains a flag. That tells you the flag is not sitting somewhere in the page to be found; it is handed out by the server after a successful checkout. The task was to make the store accept an order that the available balance could not cover. The flag itself was INTIGRITI{[redacted]}.

Setup
No accounts, roles or special tooling are described beyond the challenge environment itself. The preconditions were:
- €66.00 of store credit on the basket.
- A €666.00 collectible, so the balance was far short of the price.
- Two coupons available to the store:
NIGHT20(20% off) andNEWS30(30% off, first order only).
A percentage discount means the price is reduced by that fraction: 20% off €666 is €133.20 off, and 30% off is €199.80 off. "First order only" is a rule the shop intends to enforce: the code should work once, on your first order, and never again.
Using both coupons once gave 50% off: €666 became €333, still far above the €66 balance. The discount values were not the interesting part; the question was how the server decided whether a coupon had already been used. That is the heart of this challenge: not a broken padlock, but a rule that is checked in the wrong way.
Finding it
The browser sent coupon codes to POST /api/cart/coupon. Let us unpack that address:
POSTis the HTTP method, the verb of the request.GETmeans "give me something";POSTmeans "here is data, do something with it". Applying a coupon changes the basket, so it is aPOST./api/cart/couponis the path, the name of the counter you are walking up to. It says: this is the API, it concerns the cart, and specifically the coupon feature.
A request is the message your browser sends. It has a method, a path, some headers (small labels with extra information, such as what kind of data is being sent), and usually a body (the actual data). The server answers with a status code, a number that says how it went: 200 means success, 409 means conflict, that is, the request clashes with the current state.
The server rejected a code if it matched basket.lastCouponCode:
if (basket.lastCouponCode === code) { return res.status(409).json({ error: "coupon_already_applied" });}
Line by line:
if (basket.lastCouponCode === code)asks a question: is the code the user just sent exactly equal to the code stored in the basket'slastCouponCodefield?===means "strictly equal" in JavaScript.basketis the server's record of your cart.lastCouponCodeis a single field inside it, holding one string, that is, one piece of text.returnstops the function here and sends the answer back.res.status(409)sets the HTTP status code to 409, conflict..json({ error: "coupon_already_applied" })sends a small JSON body back. JSON is a text format for structured data, made of names and values in curly braces. The message says, in effect, "this coupon was already applied".
That is the entire duplicate check. It compares the new code with the last code, not with every code already in the basket. The basket already had a promotions array holding all applied coupons, but the server did not use it for duplicate detection. An array is an ordered list of items; here, a list of the discounts applied so far. It also exposed a lastCouponCode field, which made the mistake easy to spot once codes were alternated: the server was showing you what it remembered, and it only remembered one thing.
The guard therefore enforced the wrong rule:
- Intended rule: each coupon code may be applied at most once per basket.
- Implemented rule: a coupon code may not be applied twice in a row.
A useful comparison: imagine a bouncer at a door who is told "nobody gets in twice". Instead of keeping a list of everyone who has entered, he only remembers the last person he let through. Show him a different face, then come back, and he lets you in again. The rule is about the whole set of visitors; the check is about one previous visitor.
So NIGHT20 → NEWS30 → NIGHT20 was allowed. The second NIGHT20 was not a duplicate of the last code, so the check passed and the server added it to promotions again.

Exploitation
Exploitation means using the weakness on purpose to get a result the system did not intend. Here it is done step by step, with the exact requests.
Step 1: apply the first coupon
The request was ordinary:
POST /api/cart/coupon HTTP/2Host: challenge-1026.challenges.intigriti.ioContent-Type: application/json
Line by line:
POST /api/cart/couponis the method and path: send data to the coupon endpoint.HTTP/2is the version of the HTTP protocol being used. A protocol is an agreed set of rules for how two computers talk.Host: challenge-1026.challenges.intigriti.iois a header that tells the server which site name the request is for. One server can host many sites, so it needs to know which one you mean.Content-Type: application/jsonis a header saying the body is JSON, so the server knows how to read it.
{"code":"NIGHT20"}
This is the body: a JSON object with one field, code, whose value is the string NIGHT20. In plain words: "please apply the coupon called NIGHT20 to my basket".
This returned 200 and took the subtotal from €666.00 to €532.80, a €133.20 discount, with NIGHT20 ×1 in the basket. The subtotal is the price before discounts. NIGHT20 ×1 means the basket's promotions list now contains that code once.
Step 2: repeat the same code
Sending NIGHT20 again returned 409, because it matched lastCouponCode. The basket stayed at €532.80 with NIGHT20 ×1. This step is the control: it shows the guard does work in the simple case, which is exactly why the bug is easy to miss.
Step 3: apply the second coupon
Sending NEWS30 returned 200. The total became €333.00, a €333.00 discount, with NIGHT20 ×1, NEWS30 ×1 in the basket. Note that the second coupon is not compared with the first one; only with the last code, which was NIGHT20, so NEWS30 passes.
Step 4: repeat the second code
Sending NEWS30 again returned 409. The total stayed at €333.00 with NIGHT20 ×1, NEWS30 ×1. Again the guard behaves correctly for a consecutive repeat.
Step 5: go back to the first coupon
Sending NIGHT20 again returned 200. Because the last code was NEWS30, the duplicate check passed and the coupon was added a second time. The total became €199.80, a €466.20 discount, with NIGHT20 ×2, NEWS30 ×1 in the basket. This is the moment the bug pays off: a code that was already in the basket is accepted again, simply because something else was sent in between.
Step 6: go back to the second coupon
Sending NEWS30 again returned 200. The total became €0.00, a €666.00 discount, with NIGHT20 ×2, NEWS30 ×2 in the basket. The order is now free.
The full sequence, as the report presents it:
1 NIGHT20 200 €133.20 €532.80 NIGHT20 ×12 NIGHT20 409 €133.20 €532.80 NIGHT20 ×13 NEWS30 200 €333.00 €333.00 NIGHT20 ×1, NEWS30 ×14 NEWS30 409 €333.00 €333.00 NIGHT20 ×1, NEWS30 ×15 NIGHT20 200 €466.20 €199.80 NIGHT20 ×2, NEWS30 ×16 NEWS30 200 €666.00 €0.00 NIGHT20 ×2, NEWS30 ×2
Reading the columns from left to right: the step number, the code sent, the status code returned, the total discount so far, the price still to pay, and the contents of the promotions list. The duplicate attempts returned 409; the alternating attempts returned 200. That is the bug in one table.
Each coupon was calculated against the original subtotal, not the running total:
subtotal = €666.00NIGHT20 (20%) = €133.20NEWS30 (30%) = €199.80NIGHT20 (20%) = €133.20NEWS30 (30%) = €199.80 --------total discount = €666.00final total = €0.00
Line by line: the starting price is €666.00. Each of the four applications is worked out from that same starting price, not from the price left after the previous discount. 20% of €666 is €133.20, and 30% of €666 is €199.80. Adding the four amounts gives €666.00 of discount, so the final total is €0.00. Twenty plus thirty plus twenty plus thirty is one hundred: the store had discounted the entire item while applying only valid codes. No code was forged and no price was edited; the shop did the arithmetic itself.
Step 7: check out
With the balance covering the order, checkout returned the receipt:
{ "ok": true, "receipt": { "flag": "INTIGRITI{...}" }}
Line by line:
- The outer curly braces hold one JSON object, the server's answer.
"ok": truesays the operation succeeded."receipt": { ... }is a nested object, a receipt inside the answer."flag": "INTIGRITI{...}"is the field the front-end was looking for. The value is shown shortened here; the full flag is the one quoted earlier.


Root cause
The vulnerability is a state-management mistake, not a maths mistake. State is simply the information a program keeps about the current situation: what is in your basket, which coupons are on it, what the total is. State management is how the program stores and updates that information.
The server held two pieces of state:
lastCouponCode, a single string.promotions, a list of applied discounts.
The duplicate check used the single string, while the discount calculation used the list. That mismatch is the whole exploit: the guard was looking at the wrong source of truth. A source of truth is the one place that holds the correct, authoritative version of a fact. Here the list was the truth about which coupons had been used, but the guard consulted the string instead.
The check was also order-dependent. Applying the same code twice in a row failed; applying it again after a different code succeeded. A correct check would not care about order at all. If a rule says "each coupon once", then the answer to "has this code been used?" must be the same no matter what was sent before it.
No request tampering, secret guessing or authentication bypass was needed. Authentication is proving who you are, usually with a username and password; bypassing it would mean getting in without proving it. Nothing like that happened here. Two valid coupons used in an order the server did not expect were enough.
Impact
Impact means what damage the weakness could cause in the real world. In the challenge, the impact was a €0.00 order and a flag. In a production storefront, the same pattern is a direct business-logic risk: a customer can stack valid coupons, drive an order to zero, and bypass the price of any item the coupon rules cover. Business logic is the set of rules that make the shop work as a business, such as prices, discounts and limits; a business-logic bug breaks those rules without breaking any lock.
If the store issues credit or cashback, the same flaw could turn a discount into a payout: instead of merely paying nothing, you could end up being owed money. The severity depends on the store, but the class of bug is not exotic: a single-field duplicate check standing in for a set-membership check. A set-membership check asks "is this item in the collection?", which is the right question for "has this coupon been used?".
Fix
The server already had the right data; it needed to use it:
const alreadyApplied = basket.promotions.some( (promotion) => promotion.code === code);
Line by line:
const alreadyApplied =creates a named value,alreadyApplied, to hold the answer.basket.promotionsis the list of discounts already on the basket..some(...)is a JavaScript method that asks: is there at least one item in this list for which the following test is true? It returnstrueorfalse.(promotion) => promotion.code === codeis the test. For each item in the list, calledpromotion, it checks whether that item'scodefield equals the code just sent. The=>syntax is an arrow function, a short way of writing a small function.
In plain words: "look through every coupon already applied and see whether any of them is this one".
if (alreadyApplied) { return res.status(409).json({ error: "coupon_already_applied" });}
Line by line: if the answer is true, stop and reply with status 409 and the same JSON error as before. The difference is what is being checked: the whole list, not the last entry.
This checks the set of applied codes instead of the last element, making the duplicate check order-independent and idempotent per coupon. Idempotent means doing the same thing twice has the same effect as doing it once: the second attempt changes nothing.
Two defence-in-depth checks are also worth adding. Defence in depth means adding extra safety layers so that one mistake does not lead to a bad outcome on its own:
- Clamp the total at zero and reject a checkout if the discount exceeds the subtotal. Clamping means forcing a value into an allowed range; here, never letting the price go below zero.
- Validate that the sum of percentage discounts cannot exceed 100%.
The primary bug remains the duplicate check: the guard should ask whether a code has ever been applied, not whether it was the last thing seen.
Once you understand a bug like this, you can look for the same shape elsewhere.
- Alternating two or more valid codes. Apply code A, then B, then A again, then B again. A positive result is a
200on the repeated code and a total that drops below what a single application of each coupon should allow. - Three or more codes in rotation. If the guard only remembers one previous value, rotating A, B, C, A, B, C should keep succeeding. A positive result is each repeat returning
200and the discount accumulating beyond the intended cap. - Order sensitivity. Apply the same code twice in a row, then once more after a different code. A positive result is
409on the consecutive attempt and200on the separated one, which confirms the check is positional rather than set-based. - Discount stacking against the original subtotal. Watch whether each coupon is computed on the original price or the running total. A positive result is a final total of zero or below while every individual code is legitimate.
- Response fields that leak state. Look for fields such as
lastCouponCodeor a promotions list in basket responses. A positive result is a response that shows only the most recent code while the discount calculation clearly uses the full list. - Checkout after a zeroed total. Confirm that checkout accepts the order once the balance covers it. A positive result is a receipt containing the flag or order confirmation with no further validation of how the total was reached.
Glossary
- API: the set of addresses and rules a program uses to talk to a server behind the scenes, separate from the visible web pages.
- Array: an ordered list of items in a program.
- Authentication: proving who you are, usually with a username and password.
- Basket (cart): the server's record of what you intend to buy and the discounts applied to it.
- Body: the part of an HTTP request or response that carries the actual data.
- Business logic: the rules that make a service work as a business, such as prices, discounts and limits.
- Challenge: a deliberately vulnerable application provided so people can practise attacking it safely.
- Client: the program that asks the server for things, usually your browser.
- Clamping: forcing a value into an allowed range, for example never letting a price go below zero.
- Content-Type: an HTTP header that says what format the body is in, such as JSON.
- Coupon: a code that changes the price of an order.
- Defence in depth: adding extra safety layers so one mistake does not cause a bad outcome on its own.
- Endpoint: a specific address on a server that accepts a particular kind of request.
- Exploitation: using a weakness on purpose to get a result the system did not intend.
- Field: a named piece of data inside a structured record.
- Flag: a short piece of text that proves you solved a challenge.
- Front-end: the part of a site that runs in your browser and draws the page.
- GET: an HTTP method meaning "give me something".
- Header: a small label attached to an HTTP request or response carrying extra information.
- Host: an HTTP header naming which site the request is for.
- HTTP: the protocol browsers and servers use to exchange requests and responses.
- HTTP method: the verb of a request, such as GET or POST, saying what kind of action is wanted.
- Idempotent: doing the same operation twice has the same effect as doing it once.
- Impact: what damage a weakness could cause in the real world.
- Intigriti: a platform that runs security challenges and bug bounty programmes.
- JSON: a text format for structured data made of names and values in curly braces.
- Path: the part of a URL that names the resource, such as
/api/cart/coupon. - Percentage discount: a price reduction by a given fraction, such as 20% off.
- POST: an HTTP method meaning "here is data, do something with it".
- Protocol: an agreed set of rules for how two computers communicate.
- Request: the message a client sends to a server.
- Response: the message a server sends back to a client.
- Server: the computer or program that holds data and decides what is allowed.
- Set-membership check: a check that asks whether an item is in a collection.
- Source of truth: the one place holding the correct, authoritative version of a fact.
- State: the information a program keeps about the current situation.
- State management: how a program stores and updates that information.
- Status code: a number in an HTTP response saying how the request went, such as 200 for success or 409 for conflict.
- Subtotal: the price before discounts.
- Template syntax: the
${ ... }notation used to insert a computed value into a page. - Vulnerability: a weakness in a system that can be used to make it behave in a way its owners did not intend.