Cyberlium

Web › Module 6 › Lesson 2

BeginnerModule 6Lesson 2/5

Business Logic Flaws

Happy path works; hostile path still pays — that is a logic flaw, not a CVE string.

15 min+40 XP3 quiz
Module progress2 of 5

Visual · business_logic_flaws

A checkout flowchart with a side door: coupon, price, quantity. Curl or SAFE No bank-steal kit.

Opening

Business logic flaws are correct code doing the wrong business.

OWASP Top 10:2025 A06 Insecure Design covers cases where every function looks tidy and the product still loses: negative quantities accepted, coupons stacked forever, price taken from the client, refunds after shipment without a state machine. That is not “find a 0-day.” That is reading the rules of a system YOU own and asking whether those rules survive a hostile customer. Attack literacy here means naming the invariant: what must stay true after every request. Practical commands hit

1. Invariants: the sentences money and privilege must obey

An invariant is a rule that remains true after every successful operation: quantity ≥ 0, coupon used_at is null or set once, order.state only moves forward through allowed edges, price comes from the catalog not the JSON body. Logic flaws are invariant violations the API still accepts. Write the invariant in plain language before you write the test. If the only place the rule lives is a marketing PDF, A06 already has a finding.

Client-supplied trusted fields are a classic failure: total, role, isPremium, discountPercent. The attacker goal is obvious — pay less, become admin, skip a step. The defender move is equally obvious and often skipped: recompute on the server from authoritative state. You practiced server-side enforcement under A01; A06 asks whether the design ever required that recomputation.

Command guide

A06 Design — Invariants

═══ INSTALL ═══

Linux (Debian/Ubuntu):

Command — copy this

sudo apt install curl

macOS: Built-in

Windows: Built-in (PowerShell: Invoke-WebRequest)

═══ COMMANDS ═══

Command — copy this

SAFE="http://127.0.0.1:8773"

Command — copy this

curl -sS -m 3 -I "$SAFE/" | head -n 12

2. Workflow abuse: skip, reorder, and double-spend the steps

Multi-step flows (cart → address → pay → confirm) invite skipped steps if each endpoint trusts that the previous one finished. Design the state machine: which transitions are legal, who may trigger them, and what is checked again at pay time. A toy lab on 127.0.0.1:8773 can demonstrate “coupon apply without uniqueness” as a state bug YOU introduced — writeups still cite http://192.168.0.1/ as the demo asset. Never against a live merchant.

Refunds, cancellations, and gift cards need the same care. “Refund always allowed” without checking shipment or prior refunds is a business rule hole. Document the allowed transitions. Empty “we will figure refunds later” lines fail this lesson.

Command guide

A06 Design — Workflow abuse

═══ INSTALL ═══

Linux (Debian/Ubuntu):

Command — copy this

sudo apt install curl

macOS: Built-in

Windows: Built-in (PowerShell: Invoke-WebRequest)

═══ COMMANDS ═══

Command — copy this

SAFE="http://127.0.0.1:8773"

Command — copy this

curl -sS -m 3 "$SAFE/coupon" | head -n 12
curl -sS -m 3 -o /dev/null -w "apply %{http_code}
" "$SAFE/coupon/apply"

3. Limits are business rules: quantity, rate, eligibility, uniqueness

Limits are not only rate limits for bots. One coupon per account, max five seats, invite codes single-use, trial once per email — these are design constraints. If uniqueness lives only in the UI, the API will accept the sixth seat. Store the constraint where the write happens. Next lesson deepens races around the same limits; today you name the limit as an invariant and prove broken vs fixed on the coupon toy.

Eligibility checks (student discount, region, age) must use server-side evidence, not a checkbox the client sends. Forgery of eligibility is an attacker goal. Your note should list one eligibility rule and where it is proven.

4. Report shape: invariant broken → impact → fix on your stack

A useful finding: asset http://192.168.0.1/ (or SAFE 127.0.0.1:8773), numbered curl steps, expected vs actual, invariant violated, business impact (overspend, free goods, privilege), and proposed control. No screenshots of stranger checkouts. No bank race PoCs. Own-lab proof → fix/report is the Cyberlium pedagogy.

Keep secrets out of the note. chmod 600. Cite A06. This path is original Cyberlium — not official OWASP certification.

5. Wrong vs right: client totals vs server invariants

Worked failure — same checkout, opposite trust. Right never needs a real payment rail or a router login.

  • Wrong

    Trust price/role/discount from the client. Probe a live store “for logic.” Hydra 192.168.0.1. Ship bank-steal race notes. Skip state machines for refunds. Call this an OWASP cert.

  • Right

    Identify DEMO; if router, use SAFE. Write invariants; run broken vs fixed coupon curls on YOUR toy; lock biz-logic-notes.txt. Next: Race Conditions and Limit Overrun — still on counters you wrote.

6. Hands-on: coupon toy on 8773 + biz-logic-notes.txt

Start a06_coupon_toy.py (binds 127.0.0.1:8773). Broken GET /broken/coupon?user=alice applies forever. Fixed GET /fixed/coupon?user=alice applies once. Record curls. No live merchant. No hydra.

Mission: biz-logic-notes.txt (mode 600)

1) 0.0.1:8773 after starting a06_coupon_toy.py.2) Run broken vs fixed coupon curls; name invariants and server-recomputed fields for a feature YOU own. 3) chmod 600 $HOME/cyberlium-lab/biz-logic-notes.txt. No live merchant. No hydra. No nmap.

Stuck? Ask Cyberlium AI Mentor

If logic flaws still sound like “find CVEs,” ask for a hint — not a bounty target. Try: "Hint only: what is an invariant; why client price is untrusted; why a router login at 192.168.0.1 is OUT OF SCOPE; how to shape a finding on my own app?" You still fill biz-logic-notes.txt.

Business logic literacy is naming invariants and proving them on systems you own — DEMO curls plus SAFE 127.0.0.1:8773. A06 Insecure Design covers the missing rules. Original Cyberlium — not official OWASP certification. Next — Race Conditions and Limit Overrun — concurrency against limits you defined locally.

Knowledge Check

1

APPLY: An API accepts totalPrice from the JSON body for a toy shop YOU run on 127.0.0.1:8773. What is the logic flaw, and what is the fix shape?

Multiple choice

Knowledge Check

2

APPLY: True or False: If unit tests pass the happy path, A06 business logic is automatically fine.

True or False

Knowledge Check

3

APPLY: curl of http://192.168.0.1/ shows a home-router admin login. Coupon lab next step?

Multiple choice

← Previous

Answer all 3 knowledge checks to continue. (0/3 answered)