CAPEC-7
Blind SQL Injection
Blind SQL Injection results from an insufficient mitigation for SQL Injection. Although suppressing database error messages are considered best practice, the suppression alone is not sufficient to prevent SQL Injection. Blind SQL Injection is a form of SQL Injection that overcomes the lack of error messages. Without the error messages that facilitate SQL Injection, the adversary constructs input strings that probe the target through simple Boolean SQL expressions. The adversary can determine if the syntax and structure of the injection was successful based on whether the query was executed or not. Applied iteratively, the adversary determines how and where the target is vulnerable to SQL Injection.
Abstraction
Detailed
Typical severity
High
Likelihood of attack
High
Understand the attack
What is this attack pattern?
Execution flow
How does the attack proceed, step by step?
Explore
Hypothesize SQL queries in application
Techniques used
- Research types of SQL queries and determine which ones could be used at various places in an application.
Determine how to inject information into the queries
Techniques used
- Add clauses to the SQL queries such that the query logic does not change.
- Add delays to the SQL queries in case server does not provide clear error messages (e.g. WAITFOR DELAY '0:0:10' in SQL Server or BENCHMARK(1000000000,MD5(1) in MySQL). If these can be injected into the queries, then the length of time that the server takes to respond reveals whether the query is injectable or not.
Experiment
Determine user-controllable input susceptible to injection
Techniques used
- Use web browser to inject input through text fields or through HTTP GET parameters.
- Use a web application debugging tool such as Tamper Data, TamperIE, WebScarab,etc. to modify HTTP POST parameters, hidden fields, non-freeform fields, etc.
- Use network-level packet injection tools such as netcat to inject input
- Use modified client (modified by reverse engineering) to inject input.
Determine database type
Techniques used
- Try injecting a string containing char(0x31)=char(0x31) (this evaluates to 1=1 in SQL Server only)
- Try injecting a string containing 0x313D31 (this evaluates to 1=1 in MySQL only)
- Inject other database-specific commands into input fields susceptible to SQL Injection. The adversary can determine the type of database that is running by checking whether the query executed successfully or not (i.e. whether the adversary received a normal response from the server or not).
Exploit
Extract information about database schema
Techniques used
- Automatically extract database schema using a tool such as Absinthe.
- Manually perform the blind SQL Injection to extract desired information about the database schema.
Exploit SQL Injection vulnerability
Techniques used
- Use information about how to inject commands into SQL queries as well as information about the database schema to execute attacks such as dropping tables, inserting records, etc.
Requirements
What does the attack require?
Prerequisites
- SQL queries used by the application to store, retrieve or modify data.
- User-controllable input that is not properly validated by the application as part of SQL queries.
Skills required
- Medium: Determining the database type and version, as well as the right number and type of parameters to the query being injected in the absence of error messages requires greater skill than reverse-engineering database error messages.
Resources required
- None: No specialized resources are required to execute this type of attack.
Detection
What are the indicators of the attack?
Impact
What does a successful attack lead to?
Affected scopes: Integrity
Affected scopes: Confidentiality
Affected scopes: Confidentiality, Integrity, Availability
Defence
How is it prevented and mitigated?
Real world