Business logic flaws
| Class | Access control |
|---|---|
| Also known as | Logic flaws, application logic vulnerabilities |
| CWE | CWE-841: Improper Enforcement of Behavioral Workflow; CWE-362: Race Condition |
| OWASP Top 10 | A06:2025 Insecure Design |
| OWASP API Top 10 | API6:2023 Unrestricted Access to Sensitive Business Flows |
| Typical severity | From Low to Critical, by the feature affected |
| Affects | Checkout, coupons, transfers, referral credit, booking, and sign-in steps that span several pages |
A shop gives 10% off any order over $1,000. A customer fills the cart to $1,000, the discount is applied, and the customer then removes most of the items and pays. If the server never checks the order again after the discount, the customer keeps 10% off an order that no longer qualifies.1 None of the requests is malformed; the server checked the rule once and never again.
A business logic flaw, also called a logic flaw, is a weakness in how an application's rules are designed or written that lets someone make it behave in a way its builders did not intend.2 "Business" here means the rules of the application, whether or not money is involved.
Where they come from
Most logic flaws start as an assumption about how people will use the application.2 A developer who expects every request to come from the app's own pages lets the browser check the input, and anyone with an intercepting proxy can edit the request after the browser has sent it.1 In a large code base, the person writing one component may hold a wrong idea of what another component guarantees.2
Normal use rarely exposes these flaws. Each one is tied to what a particular application is for, so spotting it takes knowledge of the business, and automated scanners, which have no record of a shop's rules, seldom report one.2
Common forms
Values the server trusts
A bank transfer checks that the amount is not larger than the balance. Sent the amount -1000, the check passes, because minus one thousand is less than any positive balance, and the transfer moves money from the recipient to the sender.1 The same gap appears when a price, a total, a discount or a role travels from the browser and the server uses it as given. When the browser chooses which columns get written, the flaw is Mass assignment.
Steps out of order
Where a workflow needs several actions in sequence, it is vulnerable when the server does not confirm that each one happened, in order and within the allowed time.3 A sign-in that asks for the password on one page and the second-factor code on the next can be bypassed if the account is treated as signed in after the first page.1
Two requests at once
Checkout with a single-use coupon runs in steps: the coupon is checked, the discount is applied, and the coupon is marked as used. Between the check and the write there is a short gap, often a few milliseconds. Two requests that arrive inside that gap both see an unused coupon.4 This is a race condition of the time-of-check to time-of-use kind, and the same pattern lets one gift card be redeemed many times, a balance be overdrawn, or a rate limit on password guesses be exceeded. Over HTTP/2, one network packet can complete 20 to 30 requests at the same moment.4
A flow used at scale
Some features are safe when one person uses them and harmful when a script does: buying a whole stock of a limited product to resell, reserving every time slot, or creating accounts in bulk to collect referral credit for one wallet.5
Example: a coupon redeemed without limit
On 9 March 2026 the open source shop framework Sylius published an advisory, CVE-2026-31824, with a CVSS score of 8.2 (High). Its promotion and coupon limits were read from an object already loaded in memory when the cart was checked, and the usage counter was raised later, when the order completed, with no database lock between the two. The code also wrote the counter as a fixed number (SET used = 1) rather than adding to the stored value (SET used = used + 1). An attacker could prepare several carts with the same coupon and send the order-completion requests together; all of them passed the check, so a single-use coupon could be redeemed any number of times, with no account needed.6 The fix shipped in nine release lines, the newest being 2.2.3.
Finding them
Useful test inputs are those no ordinary user enters: negative and very large numbers, very long text, an unexpected data type, or a parameter removed altogether, one at a time. Multi-step processes are followed to the end, because a value changed at step two can take effect at step four.1 For races, the same request is sent in a group at once and the results are compared with the same group sent one after another.4 The work is manual, and logic flaws are a frequent find in Penetration testing, in code review and for Bug bounty program hunters.2
Prevention
The assumptions behind each workflow belong in its design notes, and the server verifies them at run time: that each input is sensible and that the stored state is what the step expects.2 The server recomputes prices and totals from its own records and rejects negative or out-of-range quantities and amounts.1 Threat modelling of sign-in, checkout and other key flows produces misuse cases, and unit and integration tests then check that each flow resists them.7
For limits, the check and the change happen in one database statement or one transaction (a group of changes that succeed or fail together).4 In Postgres, by default, an UPDATE that meets a row another transaction is changing waits for that transaction to finish and then tests its WHERE condition again on the new row,8 so a conditional increment cannot overrun the limit:
UPDATE coupons
SET used = used + 1
WHERE code = $1
AND used < usage_limit;
-- 0 rows changed: the coupon is used up, reject the orderAs a second guard, a uniqueness constraint in the database, such as one redemption row per customer and coupon, refuses a duplicate. Session variables cannot stop a limit overrun on database rows.4 Flows that do harm in bulk are slowed with device fingerprinting, a CAPTCHA, and checks for non-human patterns, such as an order completed less than a second after the item went into the cart.5
Prompt for a coding agent
Review the checkout, coupon, gift card, referral, transfer and sign-in code in this project. On the server side: recompute prices and totals from the database instead of using values sent by the browser; reject negative, zero or out-of-range quantities and amounts; confirm the previous step was completed before running the next one; and make every "check then update" on a limited counter a single conditional UPDATE or a transaction with a row lock. List each file and line you changed.
In SecFlash
SecFlash reports prices, roles and owner ids held in hidden form fields or data attributes as SF-EXP-409, and browser code that signs requests, letting a visitor change a price before it is signed, as SF-EXP-107. Both show on the Exposure page.
See also
- Mass assignment
- Insecure direct object reference
- Input validation
- Threat modelling
- OWASP API Security Top 10
- OWASP Application Security Verification Standard
- Card testing
- SMS pumping
- Category: Access control
References
- a b c d e f PortSwigger. "Examples of business logic vulnerabilities". Web Security Academy.
- a b c d e f PortSwigger. "Business logic vulnerabilities". Web Security Academy.
- back MITRE (2025). "CWE-841: Improper Enforcement of Behavioral Workflow". Common Weakness Enumeration.
- a b c d e PortSwigger. "Race conditions". Web Security Academy.
- a b OWASP Foundation (2023). "API6:2023 Unrestricted Access to Sensitive Business Flows". OWASP API Security Top 10.
- back Sylius (9 March 2026). "Sylius has a Promotion Usage Limit Bypass via Race Condition" (GHSA-7mp4-25j8-hp5q, CVE-2026-31824). Sylius security advisories, GitHub.
- back "A06:2025 Insecure Design". OWASP Top 10:2025. OWASP Foundation.
- back PostgreSQL Global Development Group. "Transaction Isolation". PostgreSQL documentation.
External links
- API6:2023 Unrestricted Access to Sensitive Business Flows, OWASP API Security Top 10