At a glance
- Controls
- CWE-841 · A04:2021 Insecure Design
What it is
A discount code or promotional credit has terms: one use, one account, no stacking. When those terms are checked only at the first step, later requests can apply the same code again. Codes can also be combined in ways the business never planned.
An attacker reapplies a code, swaps the order of steps, or redeems it from several accounts. AI-assisted tools can map a checkout flow and try every ordering of steps quickly, which exposes gaps in workflow checks.
Where it hides
What a reviewer can look for in the code and in the behaviour, before anyone proves it.
- Apply-coupon and remove-coupon endpoints at checkout
- Referral and sign-up credit flows
- Promotional credits added by background jobs
- Subscription upgrade and renewal paths that reuse earlier discounts
How MATT tests it
The proof runs against the deployed product, on every release, whoever wrote the code.
- 01Sign in with the test account and apply a single-use test code to an order.
- 02Apply the same code again, then add a second code, then reapply after removing it.
- 03Complete a test-mode checkout and compare the final discount with the code's terms.
Each discount must apply only as many times as its terms allow.
Executable checkas test user: POST /v1/cart/coupons {"code": "ONCE10"} twice expect: second call returns 409 or 422 expect: discount on the order equals one use of the code as test user B: POST /v1/cart/coupons {"code": "ONCE10"} after A has used it expect: 409 or 422 when the code is single-use
Every rule MATT holds →What the fix looks like
- 01
Store each redemption on the server against the code, account and organisation.
- 02
Check the code's terms again at final payment, beyond the moment it was entered.
- 03
Define in one place which discounts can combine and enforce it on the server.
- 04
Make redemption atomic so two parallel requests cannot both succeed.
A check that was never written is found by proving the deployed behaviour, fixed with the engineer who shipped it, and kept fixed by running the control on every change. What is ExploitOps? →