SuperAPI AI Directory

race-condition-methodology

General & other

View repository

Updated 10-16 08:49

About this skill

Race Condition Vulnerability Methodology

A race condition exploits the time window between "check" and "execution" (TOCTOU — Time Of Check to Time Of Use). Sending concurrent requests within this window can bypass operations that should only execute once.

Phase 1: Identify Race Entry Points

The following scenarios inherently carry race condition risk:

Scenario Race Target Exploitation Effect
Balance consumption/transfer Check balance → deduct With a balance of 100, initiate two 100 consumptions simultaneously
Coupon/redemption code Check if already used → mark as used Use the same redemption code multiple times
Voting/liking Check if already voted → record vote Vote manipulation
File upload Upload → check → delete malicious file Access the uploaded webshell before deletion
One-time token Verify token → invalidate token Use the same token multiple times
Registration/creation Check uniqueness → insert Create duplicate accounts
Purchase-limited products Check stock → place order and deduct stock Excess purchase

⛔ In-depth Reference (Required Reading)

  • ⛔Required Reading curl/Python/Barrier concurrency scripts, file upload race scripts → read_skill(id="race-condition-methodology", path="references/race-scripts.md")

Phase 2: Concurrent Request Techniques

Quick Method (curl):

for i in $(seq 1 20); do
  curl -s -X POST 'http://target/api/transfer' \
    -H 'Cookie: session=xxx' -d 'amount=100&to=attacker' &
done; wait

→ Python multithreading / Barrier synchronized release (more precise) / file upload two-group race → read_skill(id="race-condition-methodology", path="references/race-scripts.md")

Phase 3: Verify Race Success

  • Balance type: Compare whether the balance before and after is abnormal
  • Redemption code type: Whether multiple success responses are received
  • File upload type: Whether the webshell was successfully accessed

Phase 4: CTF Flag Acquisition

Abnormal balance → purchase flag item | Upload race success → webshell reads flag

Notes

  • A concurrency count of 10-50 is sufficient; too many may cause a crash
  • Races are probabilistic; try several rounds
  • threading.Barrier can make requests more synchronized

Phase 5: Supplementary Techniques

5.1 Barrier Synchronization Technique

  • Establish connections first: once the preparatory requests are ready, the barrier signal sends all requests simultaneously

5.2 File Upload Race

  • Continuously access (loop requests/polling) the uploaded file URL to execute it before deletion

5.3 TOCTOU Exploitation

  • 20 concurrent requests simulate multiple purchases to achieve excess consumption (double spending)