Race conditions: when speed becomes a weapon
A race condition occurs when the result depends on the order of events executed at almost the same time, such as several requests affecting one order. In ecommerce, the flaw can affect discounts, stock, credit or payment state.
Race condition on discount coupons
Fictional example: a coupon should be used once. If several requests check its state before the first has updated it, they may all receive approval. The test checks whether the operation remains atomic when requests arrive together.
The flaw often appears in a read-check-write sequence without locking or an atomic operation. Testing should stay within an authorised environment and use fictional orders so that it creates no real financial impact.
Race condition on stock
Another common scenario involves stock management. A limited-edition product has 1 unit remaining. Multiple buyers send purchase requests simultaneously. The application checks the stock (1 available), validates the purchase, then decrements the stock. If multiple requests are processed simultaneously, the stock can be sold multiple times before the counter is decremented. The impact goes beyond financial loss: it creates logistics, customer satisfaction, and reputation problems.
Race condition on balances and credits
Virtual wallets, referral credits, and loyalty point systems are prime targets. If a user has 100 euros in credit, they can attempt to simultaneously send multiple requests to spend those 100 euros, potentially exceeding their actual balance. This type of race condition can be systematically exploited to generate fictitious value.
Price manipulation
Price manipulation is a category of vulnerabilities where an attacker modifies a product's price in requests sent to the server. Although this seems simplistic, many e-commerce platforms are vulnerable to this type of attack.
Prices in client requests
Some implementations include the product price in data sent by the client (hidden HTML form field, cookie, request parameter). An attacker can simply modify this price before submitting the order. The golden rule: never trust client data for financial calculations. All prices must be recalculated server-side from the database at the time of order validation.
Cart manipulation
More subtle manipulations target cart logic. For example: adding a product to the cart, getting a reduced price through a promotion, then modifying the cart contents while keeping the reduced price. Or: manipulating quantities to trigger volume discounts, then reducing the quantity at the payment step while keeping the reduced unit price. These attacks exploit flaws in calculation consistency across the checkout tunnel steps.
Currency and rounding manipulation
Multi-currency platforms are exposed to manipulations related to conversions and rounding. An attacker can exploit rounding differences between currencies to generate small gains which, multiplied by thousands of transactions, become significant. This type of attack is hard to detect because each individual transaction appears normal.
Coupon and promotion abuse
Other promotion abuses include unintended coupon combinations, codes that are too easy to guess and fake accounts created to obtain referral credit. Rules should be enforced server-side, including when several discounts or accounts are involved in one journey.
Payment logic bypasses
Integrations with payment systems (Stripe, PayPal, Adyen) are risk zones if poorly implemented. Several types of bypasses are common.
Insufficient payment webhook validation allows an attacker to forge a successful payment notification without actually paying. If the application doesn't verify the webhook signature or doesn't reconcile the paid amount with the expected amount, the order is validated without payment.
Payment tunnel bypass can be done by directly accessing the order confirmation endpoint, without going through the payment step. If the server doesn't verify that a valid payment was made before validating the order, the attacker gets their order for free.
Post-creation payment intent amount modification is another variant: the attacker creates a 100-euro cart, gets a 100-euro Stripe payment intent, then modifies their cart to add additional products before finalizing the 100-euro payment.
Defense strategies
For race conditions: use database-level locking mechanisms (SELECT FOR UPDATE, SERIALIZABLE transactions). Implement idempotency for critical operations. Use anti-replay tokens for financial operations. Specifically test concurrency scenarios in your test suite.
For price manipulation: never trust prices sent by the client. Recalculate all amounts server-side at validation time. Verify consistency between the paid amount and the expected amount. Implement alerts for transactions with abnormal amounts.
For coupon abuse: generate unpredictable random codes. Implement checks with locking mechanisms. Limit the number of coupons per account and per IP address. Monitor abnormal usage patterns.