Course contentsShow
← Computer Science
Lesson 2476 of 2,87255. Web SecurityFree lesson

Types of SQL Injection Attacks

Distinguishing between in-band, inferential (blind), and out-of-band SQL injection attack vectors.

Types of SQL Injection Attacks

You'll learn: How SQL injection attacks are classified into three major categories based on how attackers extract data from the database.

The Three Attack Vectors

Not all SQL injection attacks work the same way. Understanding how attackers retrieve data helps you defend against each approach.

In-Band SQL Injection

In-band attacks are the most straightforward: the attacker uses the same communication channel to both launch the attack and gather results. The database error messages or query results appear directly in the web page response.

Think of it like asking a question out loud and hearing the answer immediately in the same conversation.

Two common subtypes:

  • Error-based: Forces the database to produce error messages that reveal data
  • Union-based: Uses the UNION operator to append malicious query results to legitimate ones

Inferential (Blind) SQL Injection

Blind attacks occur when the application doesn't display database errors or query results directly. The attacker asks true/false questions and observes the application's behavior—like testing if the page loads normally or times out.

Imagine asking yes/no questions to someone who can only nod or shake their head. You reconstruct information one bit at a time.

Two approaches:

  • Boolean-based: Observes differences in page content (success vs. error pages)
  • Time-based: Uses database sleep functions to detect true conditions by measuring response delays

Out-of-Band SQL Injection

Out-of-band attacks use a different channel to exfiltrate data, typically when the application is too locked down for in-band methods. The attacker might trigger the database to make DNS requests or HTTP connections to an attacker-controlled server.

This is like passing secret notes through a back channel when direct communication is monitored.

Key Takeaway: SQL injection attacks fall into three categories—in-band (direct response), inferential/blind (indirect observation), and out-of-band (alternate channel)—each requiring different defensive strategies beyond just input sanitization.