← Business Logic lesson
FoundationsBusiness LogicIntermediate30 min+100 XP

The Shipping Credit

The SwiftShip Checkout trusts a client-controlled value in the checkout flow. Manipulate it to complete the order without paying the intended price.

“Every line of code was correct. The business rule was not.”

CWE-840OWASP Top 10 A04:2021OWASP ASVS 5.1
The story
A workflow is a story with invariants: a price cannot go negative, a coupon is used once, a refund cannot exceed a payment. The attacker changes the story, not the syntax.

The server trusts a client-supplied price, quantity, currency or status. It checks each step in isolation but not the sequence or the final invariant. Negative values, replay and skipped steps turn a valid workflow into a loss.

Your objective
  • Inspect the checkout request
  • Change the trusted value
  • Complete the order and capture the flag
Boundary under test

Client price to server price

Field guide · request anatomy

Where to look before you type a payload

01Model the workflow

List states, allowed transitions, actors and invariants. A business rule is a property of the system, not a field validator.

02Accept input

Receive quantities, prices, coupons and identifiers, but treat every client value as a proposal.

03Recompute

Derive prices, totals, eligibility and limits on the server from trusted data.

04Commit atomically

Check and consume one-time resources in a transaction so concurrent requests cannot both win.

Progressive hints

Open one hint at a time. The first two build the model; the last two point at the boundary.

Hint 1

Map the checkout or workflow and every client-controlled value.

Hint 2

Try negative, zero or oversized values.

Hint 3

The server trusts a client-controlled value. Try a negative, zero or replayed value in the shipping flow.

Hint 4 · near the answer

Break the business invariant and capture the flag.

Guided workbench

Observe → Hypothesize → Test → Prove → Explain

This is the same loop a reviewer expects in a report. Your draft stays in this browser; nothing is submitted until you choose to export it.

0/15steps complete
Observe0/3
Hypothesize0/3
Test0/3
Prove0/3
Explain0/3

Evidence log

Write for a reviewer who was not in the room. Every claim needs a request, response or state change behind it.

Preview the evidence report
# Lab evidence report — The Shipping Credit

- Family: Business Logic
- Lab ID: web-logic-shipping
- Date: 2026-12-05

## Workflow

### Observe

- [ ] Open "The Shipping Credit" and record the entry point, the HTTP method and the role you are given.
- [ ] List every parameter, header, cookie and object identifier the normal flow exposes.
- [ ] Save a baseline response: status, body shape, timing and the fields that change by user.

### Hypothesize

- [ ] Name the server decision that protects the entry point, and the evidence it should use.
- [ ] Use the clue as a constraint, not an answer: The server accepts a value the client should never control. Try a negative or zero amount.
- [ ] Predict the exact status, body or state change that would prove the decision is missing.

### Test

- [ ] Start from the baseline and change one value: the shipping workflow values.
- [ ] Keep the request replayable; vary encoding, method or identifier location only after the first result.
- [ ] Capture the full request and response for the winning attempt, including the flag.

### Prove

- [ ] Capture the flag and name the exact foreign object, role or state change it proves.
- [ ] Repeat from a clean session and confirm the result is not cached or stale.
- [ ] State impact precisely: what data or action did you actually obtain?

### Explain

- [ ] State the root cause without naming the payload: which decision failed?
- [ ] Name the control that prevents recurrence and the layer where it belongs.
- [ ] Write one regression test that fails before the fix and passes after it.

## Evidence

### Target and baseline

_Not recorded._

### Hypothesis

_Not recorded._

### Winning request

_Not recorded._

### Proof

_Not recorded._

### Root cause

_Not recorded._

### Control and regression test

_Not recorded._

## Analyst conclusion

The proof demonstrates the missing control above. The regression test should fail against the vulnerable behavior and pass after remediation.
Solution and debrief
Locked until you capture the flag.

The full request, the reasoning and the debrief unlock after a successful capture. That is deliberate: struggle first, then consolidate.

What a reviewer will ask

False positives to rule out

  • The form rejects negative numbers: test the API directly and try zero, fractional, very large and replayed values.
  • The total looks correct in the UI: the server may trust a hidden price or discount field.
  • The coupon fails on the second attempt: test two parallel attempts, not two sequential ones.

Regression tests to name

  • Negative value: The server rejects the request or recomputes a valid non-negative total
  • Parallel redemption: Exactly one succeeds and the other receives a deterministic failure
  • Currency and rounding: The server normalizes to minor units and rejects mismatches
The defender's move
  • Enforce invariants server-side at the final commit.
  • Use state machines, idempotency keys and explicit limits.
  • Recompute prices and permissions from trusted data, never from the client.
See the secure-code pattern and all 4 regression tests →
الخلاصة

بعض الثغرات ليست في الكود، بل في منطق العمل نفسه.