OWASP Business Logic Flaws

Some weaknesses come from broken rules, not broken code. A business logic flaw lets users bend the intended workflow of an application to gain an unfair benefit. Scanners rarely find these flaws, because every request looks valid. Understanding how the business should work reveals them.

The Loyalty Card Comparison

A café offers a free coffee after ten stamps. A customer who photocopies the card collects free coffee forever. The cashier and the stamp machine work perfectly, but the rule has a gap. Business logic flaws hide in gaps like this.

Typical Examples

AreaFlawResult
Shopping cartThe server trusts the price sent by the browserItems sell for a chosen price
CouponsOne code works unlimited timesRevenue loss
QuantityNegative numbers acceptedOrders create credit instead of charges
WorkflowUsers jump straight to the final stepPayment step skipped
TimingTwo requests arrive at the same momentA single gift balance spends twice
Referral programNo limit on self-referralsEndless bonus credit

Intended Flow Versus Abused Flow

 Intended:   Cart → Address → Payment → Confirmation

 Abused:     Cart ————————————————————→ Confirmation
             (payment step skipped because the server
              never checks that payment happened)

Race Conditions in Plain Words

A race condition appears when two actions run at once and the application checks a rule before either action finishes. Imagine two people withdrawing the last 100 dollars from a joint account at the same second. Both checks see 100 dollars and both withdrawals proceed. Locks and atomic database operations prevent the double spend.

Why Tools Miss These Flaws

Automated scanners look for known patterns such as injected characters. Business logic abuse uses normal-looking requests in an unexpected order or amount. Only people who understand the rules of the business notice the gap, which makes design review and abuse-case thinking essential.

Prevention Techniques

  1. Write the business rules down in plain language. Include limits, order of steps, and who may do what.
  2. Recalculate prices, totals, and discounts on the server. Treat browser values as suggestions.
  3. Enforce workflow state on the server. Each step confirms that the previous step finished.
  4. Apply limits on quantity, frequency, and value for every sensitive action.
  5. Make coupon and reward redemption single-use with database constraints.
  6. Use database transactions and locks for balance changes.
  7. Rate limit actions that create accounts, referrals, and orders.
  8. Monitor business metrics for unusual spikes, such as many refunds from one account.

Abuse-Case Thinking

Teams usually write user stories about what customers want to do. Add abuse stories about what a dishonest person might try. For a gift card feature, ask these questions: What if someone redeems the same card twice at once? What if someone guesses card numbers? What if someone cancels an order after using the credit? Each answer becomes a rule or a test.

Testing Ideas

  • Replay requests in a different order in a test environment.
  • Submit zero, negative, and extremely large values.
  • Send the same request twice in parallel.
  • Remove or repeat steps in a multi-step form.

Key Takeaways

  • Business logic flaws break rules, not syntax.
  • Server-side enforcement of prices, state, and limits stops most abuse.
  • Race conditions need locks and transactions.
  • Abuse stories during design expose gaps before launch.