How Blind SQL Injection Works: Boolean and Time-Based Explained

Blind SQL injection is SQL injection where the application never shows database output or error messages, so an attacker cannot read data directly. Instead, they ask the database yes-or-no questions through a vulnerable input and infer the answer from how the application behaves. In boolean-based blind injection, the clue is a page that looks different for true and false conditions.

May 23, 2025 - 14:05
Updated: 
104.6k

Web & API Security in Cybersecurity & Ethical Hacking · Explainer

Ethical Hacking

How Blind SQL Injection Works: Boolean and Time-Based Explained

Quick answer: Blind SQL injection is SQL injection where the application never shows database output or error messages, so an attacker cannot read data directly. Instead, they ask the database yes-or-no questions through a vulnerable input and infer the answer from how the application behaves. In boolean-based blind injection, the clue is a page that looks different for true and false conditions. In time-based blind injection, the clue is a response delay the attacker makes the database add when a condition is true. Data leaks one bit at a time, slowly but completely. Parameterised queries stop it, as they stop all SQL injection (CWE-89).

Key takeaways

  • Blind does not mean safe: data can still be extracted.
  • Boolean-based uses page differences; time-based uses delays.
  • Hiding errors does not fix the flaw.
  • Parameterised queries are the primary defence.
  • High request volume and consistent latency spikes are detection clues.

Table of Contents

What Makes SQL Injection Blind?

In classic SQL injection, query results or database errors appear on the page. Many apps hide errors and show only generic content, so developers assume they are protected. The OWASP blind SQL injection page explains that the root flaw remains: user input is concatenated into SQL. The attacker just needs another signal. MITRE lists the pattern as CAPEC-7 under weakness CWE-89.

How Do Boolean-Based and Time-Based Blind Injection Differ?

AspectBoolean-basedTime-based
SignalPage content, status code or length changesResponse time changes
Needs visible differenceYesNo
SpeedFasterSlower; each question waits
Noise in logsMany similar requestsMany requests with long durations
FixParameterised queriesParameterised queries

A related out-of-band variant makes the database contact an external server, which egress filtering on database hosts prevents.

What Does a Time-Based Scenario Look Like?

Imagine an online shop with a product page that reads an ID from the URL and builds SQL by string concatenation. Errors are hidden and every response looks identical. An attacker appends a condition that tells the database to pause only if a statement is true, for example whether the first letter of the admin user name comes after M in the alphabet. If the page takes several seconds longer, the answer is yes. Repeating such questions, a script narrows down each character, then each value, until table names, password hashes or customer emails are recovered. No error message was ever shown. We deliberately do not show the strings involved.

How Can Defenders Detect Blind SQL Injection?

  • Bursts of hundreds of near-identical requests to one parameter from one source.
  • Response times that cluster at a fixed extra delay.
  • Database slow-query logs showing unusual sleep or wait functions.
  • WAF alerts on SQL keywords in parameters.
# Nginx: log request time, then list slowest requests by URL
# log_format timed '$remote_addr $request $status $request_time';
awk '{print $NF, $2}' /var/log/nginx/access_timed.log | sort -rn | head -20

Turning on the MySQL slow query log or PostgreSQL log_min_duration_statement helps correlate.

What Do Vulnerable and Safe Queries Look Like?

The OWASP SQL Injection Prevention Cheat Sheet lists parameterised queries as the first defence.

# UNSAFE (Python): input becomes part of the SQL text
cur.execute('SELECT name, price FROM products WHERE id = ' + product_id)

# SAFE: input is sent separately as a bound parameter
cur.execute('SELECT name, price FROM products WHERE id = %s', (product_id,))
// SAFE (PHP PDO prepared statement)
$stmt = $pdo->prepare('SELECT name, price FROM products WHERE id = ?');
$stmt->execute([$productId]);

With binding, the database treats the value as data only, so no condition can be added. See the Query Parameterization Cheat Sheet for other languages.

Which Extra Defences Reduce the Damage?

ControlEffect
Least-privilege database accountLimits which tables can be read
Query timeouts (for example MySQL max_execution_time)Caps delays and resource use
Allow-list validation of IDsRejects non-numeric input early
WAF and rate limitingSlows automated inference
No egress from database serversBlocks out-of-band variants

CISA and the FBI's March 2024 Secure by Design alert urges vendors to eliminate SQL injection through parameterised queries.

How Should Teams Test for It Safely?

Follow OWASP WSTG-INPV-05 on your own staging systems, combine static analysis with code review, and test only with written authorisation; unauthorised testing breaches Sections 43 and 66 of the IT Act 2000. Start with our SQL injection basics and the FortiWeb SQL injection patch guide. WebAsha offers web application security training.

References

Frequently Asked Questions

It is SQL injection where the app shows no query results or errors, so attackers infer data from true or false behaviour or response delays.

Boolean-based relies on visible page differences for true and false conditions, while time-based relies on deliberate delays in the database response.

No. Hiding errors only removes one signal. Attackers can still use blind techniques, so the query itself must be parameterised.

They send user input separately from the SQL text, so the database always treats it as a value and never as part of the query logic.

Look for bursts of similar requests to one parameter, response times clustering at a fixed delay, and unusual wait functions in slow query logs.

A WAF and rate limits can detect and slow many attempts, but they can be bypassed, so parameterised queries remain the real fix.

Blind SQL injection falls under MITRE CWE-89, SQL Injection, and the attack pattern is described in CAPEC-7.

Only with written authorisation from the owner. Unauthorised testing can breach Sections 43 and 66 of India’s IT Act 2000.

What's Your Reaction?

Like Like 0
Dislike Dislike 0
Love Love 0
Funny Funny 0
Wow Wow 0
Sad Sad 0
Angry Angry 0
Vaishnavi

Vaishnavi is a skilled tech professional at the Ethical Hacking Training Institute in Pune, responsible for managing and optimizing the technical infrastructure that supports advanced cybersecurity education. With deep expertise in network security, backend operations, and system performance, she ensures that practical labs, online modules, and assessments run smoothly and securely. Her behind-the-scenes contributions play a vital role in delivering a seamless and secure learning experience for aspiring ethical hackers.