Explain time-based blind SQL injection. Attacker can't see output so injects conditional…
- User
Explain time-based blind SQL injection. Attacker can't see output so injects conditional sleep. If server delays, condition was true. Script to exfiltrate data bit by bit.
- Assistant
Explaining time-based blind SQL injection conceptually
Time-based blind SQL injection infers data by triggering conditional delays on the server when direct query results aren't visible; attackers use these delays to test true/false conditions bit by bit, reconstructing sensitive data incrementally without revealing output. In a “normal” SQL injection the attacker can see the database’s response – for example an extra row appears in a table or an error message is displayed – so they can iterate quickly on their payloads.
In a lot of real‑world applications there is no visible channel back from the database. The application catches database errors and renders a generic “OK” page, so a straight
UNION SELECT …doesn’t tell you anything about what was returned. The “blind” techniques use some other observable side–effect as a yes/no oracle. In the time‑based variant the side–effect is how long the server takes to respond.All of the major SQL dialects have a way to pause execution for a fixed period, e.g.
SLEEP(5)in MySQL orpg_sleep(5)in PostgreSQL. An attacker will wrap that in a conditional:… AND IF(ASCII(SUBSTR((SELECT version()),1,1)) > 77, SLEEP(5), 0) …When the injected condition is true the database pauses for five seconds, when it’s false it returns immediately. From the outside you see two different response times, which gives you a single bit of information about the data you’re probing.
By changing the condition on each request you can recover arbitrary values. Typical automation loops over each character of a secret value, and for each character either does a linear walk through the character set or a binary search on the ASCII code, timing each request to decide whether to move “higher” or “lower”. After enough requests you’ve reconstructed the string one byte at a time, even though the application never printed it.
Because of this, mitigations focus on preventing untrusted input reaching the SQL interpreter at all: parameterise queries, sanitise inputs, and implement request throttling and time‑out logic so that this kind of slow probing stands out in your logs.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.