Race Condition - Hackviser __top__
import requests import threading
Time-of-Check to Time-of-Use (TOCTOU) flaw. The Check: The system verifies if a condition is met (e.g., "Does this user have enough balance?"). The Window: A millisecond-scale gap where the system assumes the check is still valid. The Use: The system performs the action based on the initial check. DEV Community By sending multiple concurrent requests, an attacker can "squeeze" extra actions into that window before the system updates the state (e.g., withdrawing money twice before the balance updates). jorianwoltjer.com Common Exploitation Scenarios Platforms like Hackviser and PortSwigger use specific labs to demonstrate these vulnerabilities: Limit Overruns: Attackers bypass restrictions such as one-time promo codes or voting limits by triggering the "apply" action multiple times simultaneously before the "used" flag is set in the database. File Upload Vulnerabilities: An attacker uploads a malicious script (like a PHP web shell). The server might briefly store it before a security scanner deletes it. If the attacker requests the file in the split second before deletion, they can achieve Remote Code Execution (RCE). Bypassing Business Logic: In e-commerce, this can lead to "collision" where price updates and coupon applications happen out of order, resulting in unintended discounts. Medium +5 Detection and Prevention Detection: Testers often use tools like race condition hackviser
If you can send two requests simultaneously, you can trick the server. The first request starts the "Check" and sees you have 100 credits. Before it can deduct the credits ("Use"), the second request also starts the "Check." Because the first request hasn't finished yet, the second request also sees 100 credits. Both requests pass the check, and you effectively spend 100 credits twice to get two items (double spending). The Use: The system performs the action based
This is the standard methodology for solving a web-based race condition challenge. File Upload Vulnerabilities: An attacker uploads a malicious
import threading import requests
def send_request(): data = {'amount': '100', 'to_user': 'attacker'} try: r = requests.post(target_url, data=data, cookies=cookies) print(f"Status: {r.status_code}") except Exception as e: print(e)