Skip to main content
Be Bitwise

Business Logic Flaws in APIs

API Vulnerability Classes · API Security track

7 min read

In this module

Beyond Technical Bugs

Every vulnerability we've examined so far (BOLA, injection, mass assignment) follows a recognisable technical pattern. A scanner can check for SQL injection by firing a single quote and watching for an error. Business logic flaws are different. They exploit the intended functionality of an application in ways the developers never anticipated.

A business logic flaw is not a broken feature. Every individual component works correctly. The vulnerability emerges in the gap between how the system was designed to be used and how it can actually be used.

What Makes Business Logic Unique

Consider a standard e-commerce API. Each endpoint works as documented: you can add items to a cart, apply discount codes, and complete a purchase. The logic flaw shows up when an attacker applies a 50% discount code twice, or applies it after a price has already been reduced, or adds an item at one price and checks out after the price changes.

Why Scanners Cannot Find Business Logic Flaws

Automated vulnerability scanners test for technical patterns: malformed input that triggers errors, missing headers, known CVE signatures. Business logic flaws involve valid requests in an unexpected sequence or combination. No scanner knows that applying a coupon twice shouldn't work, because the scanner doesn't understand the business rules.

That's why business logic testing demands a human tester who understands the application's purpose and can think adversarially about its workflows.

Common Patterns

Price Manipulation

APIs that calculate prices on the client side and send the total to the server are vulnerable to direct price modification:

http
POST /api/v1/orders HTTP/1.1
Content-Type: application/json
{
"items": [
{ "product_id": "laptop_pro", "quantity": 1 }
],
"total": 1.00,
"currency": "GBP"
}

Even when the server calculates prices, manipulation is possible through negative quantities, currency conversion rounding errors, or coupon stacking:

json
{
"product_id": "laptop_pro",
"quantity": -1,
"coupon": "SAVE50"
}

A negative quantity combined with a discount code can leave the attacker with a credit on their account.

Workflow Bypass

Multi-step processes often assume clients follow the prescribed order. APIs that don't enforce step sequencing let attackers skip validation stages entirely.

If each step is an independent API endpoint and the final step doesn't verify that the earlier ones were completed successfully, the attacker leapfrogs straight to approval by calling step 4 without doing steps 2 or 3.

Race Conditions

Race conditions in APIs occur when two or more requests are processed concurrently and the outcome depends on the order of execution. The classic case is a double-spend:

The naive way to test it is a script that fires 20 redemption requests from 20 threads. That races poorly. Each thread opens its own connection, and the TLS handshakes, scheduling and network jitter smear the requests across tens of milliseconds, while the gap between the server's check and its update may be well under one. Most requests simply arrive after the voucher is already marked used.

The modern technique is the single-packet attack, published by James Kettle of PortSwigger in 2023. Over HTTP/2, many requests share one connection, so you can send 20 to 30 of them with their final bytes held back, then release all the final frames in a single TCP packet. They reach the server together and are processed within about a millisecond of each other, whatever the network jitter. Burp Repeater does this when you group tabs and choose Send group in parallel; Turbo Intruder does the same with more control, and falls back to last-byte synchronisation over HTTP/1.1.

If the server checks whether the voucher has been redeemed, then processes the redemption in a separate step, multiple concurrent requests can all pass the check before any of them mark the voucher as used. Result: a single-use voucher redeemed twenty times.

Shrink it to two requests and you can play the scheduler yourself. Each thread below is one redemption handler: read the redeemed flag, bail out if it's set, mark it used, add £100 credit. Run T1's read, then T2's read, then let both finish. Both pass the check and credit ends at 200.

Voucher redemption: check, then act

Pick which thread runs next and watch shared memory and registers change.

Memory model
T1
  1. 0r1 = redeemed;// SELECT redeemed
  2. 1if (r1 != 0) goto 4;// already used: reject
  3. 2redeemed = 1;// UPDATE redeemed = 1
  4. 3fetch_add(&credit, 100);// add the credit
Registers
  • r1 = 0
T2
  1. 0r1 = redeemed;// SELECT redeemed
  2. 1if (r1 != 0) goto 4;// already used: reject
  3. 2redeemed = 1;// UPDATE redeemed = 1
  4. 3fetch_add(&credit, 100);// add the credit
Registers
  • r1 = 0
Shared memory
  • credit = 0
  • redeemed = 0
0 steps
Every possible schedule

60 of 66 possible schedules end with an unexpected result.

Final resultSchedules
credit = 200, redeemed = 160
credit = 100, redeemed = 16

The fix is to make the check and the update one indivisible step, which in SQL is a conditional UPDATE vouchers SET redeemed = 1 WHERE code = ? AND redeemed = 0 followed by a look at the affected row count. Below, that's modelled as a compare-and-swap. Try every order you like: only one thread ever gets the credit.

Voucher redemption: atomic claim

Pick which thread runs next and watch shared memory and registers change.

Memory model
T1
  1. 0r1 = cas(&redeemed, 0, 1);// UPDATE ... WHERE redeemed = 0
  2. 1if (r1 == 0) goto 3;// no row updated: reject
  3. 2fetch_add(&credit, 100);// add the credit
Registers
  • r1 = 0
T2
  1. 0r1 = cas(&redeemed, 0, 1);// UPDATE ... WHERE redeemed = 0
  2. 1if (r1 == 0) goto 3;// no row updated: reject
  3. 2fetch_add(&credit, 100);// add the credit
Registers
  • r1 = 0
Shared memory
  • credit = 0
  • redeemed = 0
0 steps
Every possible schedule

0 of 12 possible schedules end with an unexpected result.

Final resultSchedules
credit = 100, redeemed = 112

The same pattern applies to any finite resource: account balances, limited stock, one-time tokens, referral bonuses.

Feature Abuse and Automation

OWASP API6 (Unrestricted Access to Sensitive Business Flows) specifically addresses automated abuse of legitimate features. Examples include:

  • Ticket scalping: Bots purchasing event tickets faster than human users
  • Referral abuse: Automated creation of fake accounts to exploit referral bonuses
  • Content scraping: Systematically extracting pricing, inventory, or user-generated content
  • Review manipulation: Automated submission of fake reviews or ratings

These aren't technical vulnerabilities. The API is doing exactly what it was designed to do. The flaw is the absence of controls against automated, large-scale use of the feature.

Testing Methodology

Business logic testing demands understanding the application before attacking it. The approach:

1. Map the Workflows

Document every multi-step process: registration, checkout, payment, password reset, account upgrade. Note what each step validates and what state it mutates.

2. Question Every Assumption

For each workflow, ask:

  • What happens if I skip a step?
  • What happens if I repeat a step?
  • What happens if I perform steps out of order?
  • What happens if I modify values between steps?
  • What happens if two requests arrive simultaneously?

3. Test Boundary Conditions

Explore the edges of numerical inputs:

  • Zero values, negative values, extremely large values
  • Minimum and maximum quantities
  • Currency precision (what happens with 0.001 of a currency?)
  • Integer overflow on quantities or prices

4. Test with Multiple Accounts

Some logic flaws only surface through interactions between accounts:

  • Can User A's discount code be used on User B's order?
  • Can a cancelled account still perform privileged operations during a grace period?
  • Do referral bonuses validate that the referrer and referee are different people?

5. Time-Based Testing

Modify timestamps, test with expired tokens that aren't properly validated, and check whether time-limited offers are enforced server-side.

Think Like a Fraudster

The most productive business logic testing starts with one question: "If I wanted to steal money, goods, or access from this application, how would I do it using only the features it provides?" Every legitimate feature is a potential attack surface when used outside its intended context.

Business logic flaws are often the highest-impact findings in API security assessments because they hit revenue, user trust, and business operations directly. They can't be patched with a generic fix. Each one demands understanding and redesigning the specific business process. The next module shifts into advanced exploitation techniques, starting with GraphQL-specific attacks.