Tactical LogHuntress CTF 2026 // team archive

Days / Day 27 / Web Exploitation / Double Spent

DAY 27//LANE: WEB EXPLOITATION//STATUS: CORRECT x3

Double Spent

Web Exploitation SSTTMM Modes reported CORRECT in this write-up
  • Category: Web Exploitation (Day 27, lane sampler for Day 21), 3 modes
  • Game Master ID: web-exploitation-day-21-double-spent
  • Prompt (GM):

    One credit, two purchases. The ledger can't count what it can't see coming — race it and spend the same credit twice.

  • Question: "Recover the proof from Target 1." (answer id proof-1, exact text)

Modes and flags (GM-accepted)

ModeFlagSolved byAt
Single SolveToken18b902edafc7493b4ef9bbbe78845eafthe team solver (agent-6)2026-10-27T13:07:54Z
Time TrialTokena4f8a2c1908b73d78f6c39e7b67a3d8bBlandman32026-10-27T13:11:02Z
MasteryTokenb88b822ee26568b6d9cd55d5473b79c0Blandman32026-10-27T13:12:16Z

Target shape

Each attempt returns a Rails app at https://<attempt-host>.2026.huntress.ctf.games/. Public endpoints:

  • GET /api/clues returns a JSON advertisement: {"framework":"Rails","feature_route":"/execute-<nonce>","secondary_route":"/audit-<nonce>","current_role":"analyst"}
  • POST /execute-<nonce> with empty body: redeems the single ledger credit. 200 {"ok":true,"credits":<N-1>,"effect":"credit_redeemed"} on success, 409 {"ok":false,"credits":<N>,"effect":"credit_unavailable"} when credits <= 0.
  • GET /audit-<nonce>: 403 {"error":"credit_not_overspent","credits":<N>} while credits >= 0; 200 {"ok":true,"effect":"single_credit_spent_twice","evidence":"proof_HEX"} once credits < 0.

The ledger starts at credits=1 and the credits > 0 guard around the decrement is NOT atomic. Serial POST /execute can spend at most one credit (credits bottoms at 0, no proof). Firing many parallel POSTs while the ledger is still at 1 lets several requests pass the guard before any has committed its decrement; the counter goes negative and the audit endpoint emits the proof.

Exploit (reproduced in scripts/race.py and solver_copy.py:_tech_double_spent_race)

  1. GET /api/clues to resolve the per-target feature/secondary routes.
  2. Fire ~40 parallel POST /execute-<nonce> requests (no body, no auth, no cookies).
  3. GET /audit-<nonce> -> the response body carries evidence: proof_<32 hex>.
  4. Submit proof_<hex> under proof-1 to the Game Master.

Sample timing: 50 parallel POSTs produced 5 x 200/credit_redeemed, final counter credits=-4, audit returned Proofproof_767453bda8c24ff4af3a015b88cd6d36, which the GM accepted as CORRECT for Single Solve.

Operational notes (framework-specific)

  • The first POST I sent was sequential, which left the fresh target stuck at credits=0 and killed the race window. op=reset (via GM._post(op='reset', ...)) tears the target down and prepares a fresh one on the same untimed attempt - essential for retrying a web race-condition single without burning a timed variant.
  • The web battery dispatcher folds routes[].path into target_url, so a technique must rebuild base = scheme://netloc from the URL (hitting /api/clues at the appended route prefix 404s on this Rails app, which serves the API at the host root).
  • HUNTRESS_WEB_LIVE_BATTERY=1 is required for _lfi_handler to run the technique battery at all; autosolve_web injects it for timed modes.

Lesson tag

  • speed / trick: web race condition on a non-atomic credit > 0 check; parallel POSTs before any decrement commits + an audit endpoint that observes credits < 0.