Skip to content
Tutorials Center
My learning

Topics

Lesson 24 of 53 ยท Web Application Security

Business Logic Flaws

Learn what business logic flaws are, why scanners miss them, and how price tampering, workflow bypass, coupon and rate abuse are found in authorized tests and prevented on the server.

Most vulnerabilities in this course break a technical rule: unescaped input becomes code, a missing check exposes data. Business logic flaws are different. The code does exactly what it was written to do, and every request is valid HTTP, yet the application can be made to do something its designers never intended: buy a product for a negative price, skip a payment step, redeem a coupon a hundred times or transfer more money than exists. There is no malicious payload to detect and no signature for a scanner to match. Finding these flaws takes understanding what the application is for.

Test business logic only on applications you own or are authorized to test, ideally lab shops and demo apps. Logic abuse can cost a real business real money, create fake orders and corrupt records. Agree in writing which workflows may be exercised and use test accounts and test payment modes. The code here is a fake shop in memory.

Why scanners miss them

A scanner sends known bad inputs and looks for known bad responses. A logic flaw has neither. Adding -1 to a quantity returns a normal page. Calling step 3 of a checkout before step 2 returns a normal page. Only someone who knows that "quantity must be positive" and "payment must come before shipping" can recognize the problem. That is why manual testing with a proxy and a good mental model of the business is the main method.

The root cause is nearly always the same: the server trusts the client or trusts that the user will follow the intended flow. The browser's validation, hidden fields and the order of screens are suggestions, not controls.

Common patterns

Where logic breaks

Price and quantity Client sends the price or a negative amount.
Workflow skipping Jump to the last step.
Coupons and credits Reuse, stacking, race conditions.

The app trusts the happy path.

1 / 2
  • Price and quantity tampering. The price is sent from the browser in a hidden field, or the quantity accepts zero or negative numbers, producing a refund-like credit. Fix: the server looks up prices itself and validates ranges.
  • Workflow bypass. A multi-step process (cart, address, payment, confirmation) lets a user request the confirmation URL directly. Fix: the server tracks state and refuses a step unless the earlier ones are complete.
  • Coupon and credit abuse. A one-use code works repeatedly, discounts stack beyond 100 percent, or a referral gives a reward to yourself. Fix: enforce limits server-side, record redemptions and test combinations.
  • Rate and limit abuse. Unlimited free-trial signups, password reset floods, voting or review spam. Fix: per-account and per-device limits, verification and monitoring.
  • Trusting client-supplied roles or IDs. A form field such as role=admin or userId=42 is accepted as given. This overlaps with access control problems.
  • Race conditions. Two simultaneous requests both pass a balance check before either updates the balance, spending funds twice. Fix: transactions and locks, atomic updates.
  • Numeric and rounding errors. Integer overflow, rounding that favors the buyer after many tiny purchases, currency mix-ups.

A fake shop with logic flaws

The stand-in below models a checkout in memory. The vulnerable version trusts the price and quantity it receives and does not check the order of steps. The test cases act like a tester looking at what the browser would send.

Node.js Price tampering and step skipping

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

The vulnerable total is negative or near zero, which means the shop would owe the customer money. Notice the fix never mentions "attack" at all: it simply states the rules that were always supposed to hold.

Races and one-use codes

Race conditions happen because checks and updates are separate steps. The second stand-in simulates two requests interleaving in the vulnerable version and shows how an atomic redeem avoids the problem. It uses explicit steps to make the interleaving deterministic instead of depending on real timing.

Node.js A one-use coupon and a race

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

In a real database the fix is a single conditional update (and checking the number of rows it changed), or a transaction with the right locking, rather than "SELECT then UPDATE".

How to test logic

  1. Learn the business. Write down each workflow, who can do what and the rules that should always hold (price is positive, balance never negative, a coupon is used once).
  2. List what the client controls with a proxy: IDs, prices, quantities, state flags, roles, order of calls.
  3. Break each rule on purpose in a lab or test environment: change values, skip steps, repeat steps, send things out of order, send things twice at the same time.
  4. Check consequences, not just responses. Did a refund appear? Did the stock count go negative? Did an order ship without payment?
  5. Document the impact in business terms: "a customer can obtain any item for 0.01", not just "the price parameter is tamperable". See Reporting.

Preventing logic flaws

  • Treat every client value as input: validate type, range and relationships on the server.
  • Keep authoritative data (prices, roles, state) on the server.
  • Model workflows as state machines and reject invalid transitions.
  • Make sensitive operations atomic and idempotent where repeating them would be harmful.
  • Write tests for abuse cases, not only for happy paths, as part of secure development.
  • Monitor for anomalies: negative totals, coupons used from many accounts, impossible sequences. The Clark-Wilson ideas of approved transactions and audit trails apply directly.

Concurrent requests and race conditions

Logic checks that read, decide and then write in separate steps can be defeated by sending many requests at the same moment: a coupon is redeemed twice, a balance is withdrawn twice, a rate limit is bypassed. Testers use tools that can send parallel requests, such as Burp's Turbo Intruder, OWASP ZAP scripts, Postman collection runners or ffuf with several threads, to see whether the server handles them atomically.

Prevention: make the check and the update a single atomic operation (database transaction with row locks, a unique constraint, or an atomic increment), use idempotency keys for payments, and test with parallel requests in your automated suite. Real incidents, such as API abuse at a large restaurant group in 2025 that exposed ordering and account functions through poorly protected back-end endpoints, show that business logic must be treated as an attack surface, not just a feature.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why do automated scanners usually miss business logic flaws?

    Logic flaws depend on the application's intended rules. Nothing about the traffic looks malicious.
  2. 2. A checkout accepts the price from a hidden form field. What is the right fix?

    Client-supplied values can be changed. Authoritative data must live on the server.
  3. 3. Two requests redeem a one-use coupon at the same time and both succeed. What is this?

    Both requests passed the check before either updated the state. An atomic conditional update or transaction prevents it.
  4. 4. Which approach helps stop workflow skipping?

    The server must enforce the order. The visible order of screens is not a control.

Summary

  • Business logic flaws let valid requests produce unintended outcomes, so scanners rarely find them.
  • The cause is trusting the client or the intended order of steps.
  • Common patterns: price and quantity tampering, workflow bypass, coupon and limit abuse, client-chosen roles, race conditions and rounding errors.
  • Test by learning the business rules, listing what the client controls and deliberately breaking each rule in a lab.
  • Prevent by validating on the server, keeping authority server-side, modeling workflows as state machines, making operations atomic and testing abuse cases.

Next: API Security Testing and Hardening