Skip to content
File upload Disclosed report Intermediate

Reflected File Download in community.ubnt.com/restapi/

The community.ubnt.com REST API reflected a user-supplied callback parameter into a downloadable file without sanitising special characters. An attacker could craft a link that, when clicked, downloads a file named Ubiquiti_update.cmd containing arbitrary commands, which executes on the victim's machine.

a0xnirudh Follow

Originally disclosed on HackerOne

  • Triaged in 3 months
  • Fixed in 3 months
  • Paid in 3 months
  • Disclosed after 17 months

Hello,

https://community.ubnt.com/restapi/vc/authentication/sessions/Ubiquiti_update.cmd?restapi.response_format=json&callback=%22||calc||

The above URL is vulnerable to RFD. Here is the proof of concept:

Browser Chrome:

  • Embedded the above URL in html 5 anchor tags with download attribute:
<a href='https://community.ubnt.com/restapi/vc/authentication/sessions/Ubiquiti_update.cmd?restapi.response_format=json&callback=\%22||calc||' download='ubiquiti_update.cmd'>Download</a>

We can embedded this on any webpage and the moment user clicks on, it gets automatically download and when clicked can compromise the victim PC by executing any commands. (a calculator pops up in this case)

Browser IE10/8:

  • Give the URL directly in IE 10/8 and it directly download a file named Ubiquiti_update.cmd. The moment user clicks on the file, it executes and a calculator pops up.

Browser Firefox:

  • Embedded the download link in such a way that user has to do save link as option in firefox and downloads the file ubiquiti_update.cmd.
<a href='https://community.ubnt.com/restapi/vc/authentication/sessions/Ubiquiti_update.cmd?restapi.response_format=json&callback=\%22||calc||' download='ubiquiti_update.cmd' onclick="return false">Download</a>

I can give any commands inside the file as I want and inturn use this for a complete victim machine compromise. If victim checks where the download occurs, it will show as community.ubnt.com.

References about this attack:

http://www.paulosyibelo.com/2015/10/coinbase-reflected-file-download.html (RFD reported in coinbase) https://www.trustwave.com/Resources/SpiderLabs-Blog/Reflected-File-Download---A-New-Web-Attack-Vector/ (original research work)

Mitigation:

Callbacks should contain only alphabets and not special characters. All special characters much be stripped of before reflecting it in the response !

The original report as published on HackerOne, by a0xnirudh. 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 REST API reflected the callback parameter into the response body without stripping special characters, and the URL path ended in .cmd so browsers saved the response as an executable batch file.

Impact

An attacker could execute arbitrary commands on a victim's machine if the victim clicks a crafted link and then opens the downloaded file, though the exploit requires that user interaction.

What the attacker needed

Victim clicks a crafted link; victim opens the downloaded file

The fix

The callback parameter should be restricted to alphabetic characters only, with all special characters stripped before being reflected in the response.

How it was found

  1. Craft a URL to the REST API with a .cmd path and a callback parameter containing special characters.
  2. Embed the URL in an HTML anchor tag with a download attribute on any webpage.
  3. When the victim clicks the link, the browser downloads a file named Ubiquiti_update.cmd.
  4. When the victim opens the downloaded file, the attacker's commands execute.

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 reflected file download (RFD) happens when a website lets you control part of a file it sends back, and the browser saves that file with a dangerous name like .cmd. If a victim opens the downloaded file, the attacker's commands run on their computer. Here the site put the attacker's text into a file called Ubiquiti_update.cmd.

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.

More by a0xnirudh

View all

5 more disclosed reports, best first.

More from Ubiquiti Inc.

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Unrestricted file upload

The lesson behind this report.

An upload feature accepts a file that the server or other users' browsers then treat as code or as something trusted.