LogicTrail
  • Trails
  • Check my app
  • Pricing
  • Sign in
  1. Trails
  2. /
  3. Don't trust the browser
  4. · 4 minutes · Pro

One coupon, fifty orders

You posted a single-use 100%-off code for a launch giveaway. Within one second it was used for fifty free orders.

This answers: Why was a single-use coupon used many times? No coding needed. 3 quick decisions.

  • Where your data lives
  • Payments and webhooks

Checking your access…

Why was a single-use coupon used many times?

Because the code checks whether the coupon was used and marks it used in two separate steps. When many requests arrive at once, they all pass the check before any update happens. Make the database enforce it in one step, for example an update that only succeeds where used is false, or a unique constraint on redemptions.

Trail of the bug
  1. Bot script
  2. Your server
  3. Database

Breaks at Your server: Check and update are two separate steps

Why AI tools write this bug

AI-generated code reads, checks and writes in sequence, which is correct one request at a time and is rarely tested with parallel requests.

How to fix it

  1. Find check-then-update code for coupons, credits, stock and invites.

3 more steps, and a prompt that checks your own app for this bug. Part of Pro.

Unlock

Common questions

Doesn't disabling the button prevent double redemption?
Only for people clicking it. Scripts send requests directly, so the protection has to live in the database.

Related scenarios

  • One field, a million creditsPro · 4 min
  • The double orderPro · 5 min
  • The webhook that arrived twicePro · 5 min

More on this trail

Don't trust the browser: Prices, webhooks, uploads, form limits and coupons: what visitors can change, and what your server must decide.

Want someone to look?

We check AI-built apps for this and three other common leaks, in plain English.

Check my app
Sign in

Sign in to walk this one

3 decisions, about 4 minutes, and a prompt to check your own app for the same problem.

Sign in No password. We email you a link.

How to fix it

  1. Find check-then-update code for coupons, credits, stock and invites.

3 more steps, and a prompt that checks your own app for this bug. Part of Pro.

Unlock