Blind SQL Injection Explained: The Bug That Steals Data One True-or-False Question at a Time


Normal SQL injection is loud. You break a query, the page shows an error, and data spills onto the screen. Blind SQL injection is the quiet version: the page never shows an error and never prints database data — and the attacker still walks away with everything. It works by asking the server thousands of yes-or-no questions and reading the answers from the page’s behaviour.

Only test this on systems you own or have written permission to test — your own lab, a CTF challenge, or a program whose scope explicitly allows it.

How a blind question works

Imagine a product page that loads an item by its ID:

https://example.com/product?id=42

Behind it, a query like SELECT * FROM products WHERE id = 42. If the code drops your input straight into that query, you can ask the database true-or-false questions through the URL:

?id=42 AND 1=1
?id=42 AND 1=2

If the page loads normally for 1=1 and differently — an error, a missing product, a redirect — for 1=2, the application is answering your questions. That difference is the channel. Everything else is just asking better questions.

Stealing data, one bit at a time

Once the channel exists, the attacker asks the database about itself:

  • Is the first letter of the admin password “a”? — AND SUBSTRING(password,1,1)=’a’
  • Is the database version longer than 10 characters? — AND LENGTH(version())>10

Each question gets a yes or a no. A script automates thousands of them, and a full password or table name comes out one character at a time. It is slow — a single password can take thousands of requests — but it is fully automated, and automation does not get bored.

There is a faster variant, time-based blind injection, where the question makes the database pause: AND IF(SUBSTRING(password,1,1)=’a’, SLEEP(5), 0). If the page takes five seconds to load, the answer was yes. The clock becomes the channel.

Where to look when hunting

  • Inputs that change the page silently. Search boxes, filters, sort options and IDs in URLs are the usual suspects. If a parameter changes what the page shows, it may be reaching a query.
  • Boolean behaviour. A parameter where two different values produce two consistently different page states — even without an error — is a candidate.
  • Time delays. A value that makes a request hang for several seconds, reproducibly, is a strong signal of time-based injection.
  • Tools do the heavy lifting. sqlmap can detect and exploit blind injection automatically. Learn what it is doing, though — a hunter who understands the questions writes better reports than one who just runs a tool.

How to fix it

The fix is the same as for every SQL injection, and it is not input filtering:

  • Use parameterized queries (prepared statements). The database treats your input as data, never as code. This single change kills the entire bug class.
  • Never build queries by gluing strings together. If your code has a query with + user_input + in it, that is the bug.
  • Give the database user minimum permissions. A read-only account on one table cannot dump the admin table, even if a bug slips through.
  • Hide database errors. Generic error pages remove the easy feedback channel — they slow an attacker down, though they do not stop blind injection on their own.

Why it matters

Blind SQL injection is a reminder that “the page doesn’t show errors” is not a defence. Attackers do not need your application to talk to them. They need one observable difference — a page that loads or doesn’t, a response that takes five seconds or one — and they will ask their questions until the database answers. Fix it at the query, not at the error message.

Comments

Popular Posts