Skip to content
File upload Disclosed report Intermediate CVE-2022-22756

Tricking user into creating an executable by hijacking drag n drop of an image

Firefox's drag-and-drop file promise feature allowed a web page to set the destination filename and URL, so dragging an image could create an executable file with attacker-controlled contents. An attacker could trick a user into saving and opening a malicious executable disguised as an image.

Abdulrahman Alqabandi Follow

Originally disclosed on Mozilla

  • Fixed in 5.1 years
  • Paid in 2.5 years
  • Disclosed after 5.1 years
Text
Created attachment 8811122
DnD-PoC.html

User Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.87 Safari/537.36

Steps to reproduce:

Run attached PoC on latest firefox (I confirmed this on latest stable and nightly) and simply drag and drop the img seen into any folder on your local disk.


Actual results:

We can successfully hijack 'application/x-moz-file-promise-dest-filename' and 'application/x-moz-file-promise-url' and be able to set the filename and contents of the newly created file. The result is a .bat file with the contents to run calc on windows. 

I assume the file promise feature exists in order to drag and drop images you see on the web and easily save them on your desktop. If we drag and drop anchor tags into a folder we just get an 'internet shortcut' file pointing to the url. 

It's clear though this is unintended, if we assume this feature is purely for images then an attacker could easily create an executable with an icon of an image, with some tricks to obfuscate the '.exe' and we could potentially have a user unintentionally open an executable assuming its the image they saw.

Also, because of Bug 1317023 (I assume since this part does not work with e10s disabled) if we choose 'application/x-moz-file-promise-url' to equal say file:///C:// we can save a file locally with the full directory contents of C: drive. But this would require the user to resubmit the 'image' they just saved.


Expected results:

Perhaps 'application/x-moz-file-promise-dest-filename' and 'application/x-moz-file-promise-url' should be read only? and also make sure that those are only set on valid images.

The original report as published on Mozilla's Bugzilla, by Abdulrahman Alqabandi. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

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 file promise data transfer items for destination filename and URL were not read-only and were not validated to be images, allowing a page to set arbitrary values.

Impact

An attacker could create an executable file disguised as an image, potentially leading a user to open it unintentionally; additionally, with a related bug, a user could save a file containing directory listings, but this requires the user to resubmit the saved image.

What the attacker needed

Victim uses Firefox; victim drags image to local folder; victim opens the saved file

How it was found

  1. Open the proof-of-concept page in Firefox.
  2. Drag the displayed image to any folder on the local disk.
  3. The saved file is a .bat file with contents that run the calculator.

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 drag an image from a web page to your desktop, Firefox uses a 'file promise' to save it. The bug let a malicious page control the saved file's name and contents, so it could save a program instead of an image. If you then opened that file thinking it was a picture, it could run harmful code.

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 Abdulrahman Alqabandi

View all

33 more disclosed reports, best first.

More from Mozilla

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.