Course contentsShow
← Security
Lesson 570 of 3,05213. Web Security - Injection AttacksFree lesson

Time-Based Blind SQL Injection

Using database sleep functions to infer information through response time differences.

Time-Based Blind SQL Injection

What you'll learn: How attackers use database sleep functions to extract information by measuring server response delays.

The Core Idea

In Time-Based Blind SQL Injection, the attacker cannot see query results or error messages directly. Instead, they manipulate the database to delay its response conditionally. By measuring whether the server responds immediately or after a delay, the attacker infers information one bit at a time—like playing a slow game of "hot or cold."

How It Works

Remember from Boolean-Based Blind SQL Injection that you asked true/false questions and observed visible behavior changes? Time-based attacks work similarly, but when nothing visible changes at all. The only observable difference is time.

Most databases provide sleep or delay functions:

  • MySQL: SLEEP(5)
  • PostgreSQL: pg_sleep(5)
  • SQL Server: WAITFOR DELAY '00:00:05'

An attacker injects logic like:

' AND IF(SUBSTRING(password,1,1)='a', SLEEP(5), 0)--

If the first character of the password is 'a', the database sleeps for 5 seconds before responding. If not, it responds immediately. The attacker measures response time to determine the answer, then moves to the second character, third, and so on.

Why It Matters

This technique works even when:

  • The application shows identical output for all queries
  • Error messages are suppressed
  • The attacker has no other way to extract data

It's extremely stealthy but slow—extracting data takes many requests.

Key Takeaway: Time-Based Blind SQL Injection exploits database sleep functions to infer sensitive information through measurable response delays, making it effective when no visible feedback exists.