TL;DR
You’re getting timeouts during a Blind SQL injection attack because the database queries are taking too long to execute, often due to complex conditions or slow network connections. This guide explains how to identify and fix these issues.
Understanding the Problem
Blind SQL injection happens when you can’t see the results of your query directly in the application’s response. Instead, you infer information based on the server’s behaviour – usually whether a request takes longer than expected (time-based) or returns an error.
Timeouts occur because each injected query adds processing time to the database. Complex queries, large datasets, and network latency can all contribute to this delay. If the application has a strict timeout limit, your requests will be cut off.
Fixing Blind SQL Injection Timeouts
- Identify the Vulnerable Parameter: First, confirm which input field is causing the issue. This usually involves testing different parameters with simple injection attempts (e.g., adding a single quote ‘ ).
- Reduce Query Complexity: The most common cause of timeouts is overly complex SQL queries created by your injections.
- Break Down Queries: Instead of trying to extract everything at once, split the attack into smaller, more manageable steps. Extract one character or piece of information at a time.
- Use Efficient Conditions: Avoid unnecessarily complex
WHEREclauses. For example, instead of multiple nestedORconditions, try simpler comparisons.
- Slow Down Injection Rate: Sending requests too quickly can overwhelm the server and increase the chance of timeouts.
- Introduce Delays: Add a short delay between each request using tools like
sleep()in your injection payload (if supported by the database).
SELECT * FROM users WHERE username = 'admin' AND IF(1=1, SLEEP(2), 0); - Introduce Delays: Add a short delay between each request using tools like
- Use a Rate Limiter: Implement a rate limiter in your testing tool to control the number of requests per second.
- Optimize Database Queries (If Possible): If you have access to the database server, consider these optimizations:
- Indexing: Ensure that relevant columns are indexed to speed up query execution.
- Query Analysis: Use database tools to analyze slow queries and identify bottlenecks.
- Check Network Connectivity: A poor network connection between your testing machine and the server can significantly increase latency.
- Test Connection Speed: Use tools like
pingortracerouteto check the network connection. - Reduce Geographic Distance: If possible, test from a location closer to the server.
- Test Connection Speed: Use tools like
- Adjust Application Timeout Settings (If Possible): This is usually only an option if you have control over the application’s configuration.
- Increase Timeout Value: Increase the timeout value for requests that are expected to take longer. Be cautious, as this could also increase the risk of denial-of-service attacks.
- Review Timeout Policies: Understand why the current timeout limit is in place and whether it can be adjusted without compromising security.
- Use Alternative Injection Techniques: If time-based injection is consistently timing out, explore other techniques like error-based injection (if possible).
Example Scenario
Let’s say you are trying to extract the database version using a time-based injection. A naive approach might be:
SELECT IF(SUBSTRING(version(), 1, 1) = '5', SLEEP(5), 0);
If this times out, try breaking it down into smaller steps:
- Check if the first character is correct:
- If that works, check the second character:
- And so on…
SELECT IF(SUBSTRING(version(), 1, 1) = '5', SLEEP(2), 0);
SELECT IF(SUBSTRING(version(), 2, 1) = '7', SLEEP(2), 0);

