Escape issue in "Copy as cURL" enables execution of arbitrary commands on users computer
The 'Copy as cURL' feature in Firefox's developer tools did not properly escape commands for Windows PowerShell, allowing a malicious website to craft a request that, when copied and run, would execute arbitrary commands on the user's computer. An attacker could achieve information leakage and arbitrary code execution.
Originally disclosed on Mozilla
- Fixed in 35 days
- Paid in 39 days
- Disclosed after 35 days
Created attachment 9247249 POC.html
Description
The constructed curl command from the "Copy as cURL" feature in devtools isn't properly escaped for the platform WINNT. This means that a malicious website can make network requests that, if the user copies and tries to run them in PowerShell, will enable the website to run arbitrary commands on the users computer.
Steps to reproduce
This proof of concept includes three variants, each one work independently, and there should be many more combinations that should produce information leakage and arbitrary code execution.
- Start the browser and open devtools. Then visit the attached file POC.html.
- Select the "Network" tab in devtools and right click on the POST request and click "Copy as cURL (Windows)" under "Copy".
- Paste the command in PowerShell and execute it.
- Now three things should happen; the remote server should have your environment variable PATH, the shell should (among other things) show "Hello World", and the "calc.exe" application should open.
How and why does it work?
The attack shown above work because it is possible to use the escape character ` to escape itself and other vital characters. Hence circumventing the escaping preformed by Firefox.
The code responsible for this in Firefox is located in the function at: https://searchfox.org/mozilla-central/source/devtools/client/shared/curl.js#429
See also
Bug 1518026, Bug 1607742, and Bug 1614468 are old bugs with similar issues.
Please let me know if I can be of any help!
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
The escaping performed by Firefox for the 'Copy as cURL' feature on Windows did not account for PowerShell's backtick escape character, allowing an attacker to break out of the intended command and inject arbitrary commands.
Impact
A malicious website could cause arbitrary commands to run on a user's computer if the user copies a crafted request as cURL and executes it in PowerShell, leading to information leakage and code execution.
What the attacker needed
Victim uses Firefox on Windows; victim copies request as cURL; victim runs command in PowerShell
How it was found
- Start the browser and open devtools, then visit the attached POC.html file.
- In the Network tab, right-click the POST request and select 'Copy as cURL (Windows)'.
- Paste the copied command into PowerShell and execute it.
- Observe that the remote server receives the PATH environment variable, the shell shows 'Hello World', and calc.exe opens.
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 use the 'Copy as cURL' button in a browser's developer tools, it creates a command you can paste into a terminal to repeat a web request. On Windows, the terminal is PowerShell, which has special characters that can run other commands. The browser didn't escape these characters properly, so a malicious website could make a request that, when copied and run, would also run harmful commands on your computer.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.