Command injection in the "Copy as cURL (Windows)" feature
Firefox's 'Copy as cURL (Windows)' feature did not escape dollar signs in request headers, allowing a PowerShell subexpression to be included in the copied command. If a user copied such a request and pasted it into PowerShell, the subexpression would execute arbitrary commands.
Originally disclosed on Mozilla
- Fixed in 2 months
- Paid in 4 months
- Disclosed after 2 months
Created attachment 9126600
example_POC.html
Firefox does not perform any kind of escaping on $ characters in the "Copy as cURL (Windows)" functionality. This allows a PowerShell subexpression to be used in the copied cURL command, which if pasted into PowerShell will lead to command injection. This would be possible by creating a request which contains the $() characters in any portion which does not get URL encoded.
For example, the following code snippet with create a request with an unencoded header containing the value $(calc.exe) which will execute calc.exe if the request is copied using "Copy as cURL (Windows)" and pasted into PowerShell.
xhttp.open("GET", "//example.com:8000", true);
xhttp.setRequestHeader("test", "$(calc.exe)");
xhttp.send();
Steps to reproduce
1. Use something like python -m SimpleHTTPServer to serve the attached example_POC.html locally.
2. open http://127.0.0.1:8000/example_POC.html in Firefox
3. Open dev tools with F12 and click the Network tab
4. click the "Request data" button
5. Right click the request that is sent and click "Copy as cURL(windows)"
6. Open Powershell, paste the command and hit enter
7. calc.exe will open
I have also attached an HTML page which can be open in Firefox.
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
Impact
If a user copies a crafted request as a cURL command and pastes it into PowerShell, arbitrary commands could be executed on their system.
What the attacker needed
Victim uses Firefox; victim copies request as cURL (Windows); victim pastes into PowerShell
How it was found
- Serve the provided example HTML page locally using a simple HTTP server.
- Open the example page in Firefox.
- Open the developer tools and go to the Network tab.
- Click the button that triggers the request.
- Right-click the request and choose 'Copy as cURL(windows)'.
- Paste the copied command into PowerShell and press Enter.
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 copy a network request as a cURL command in Firefox, the tool builds a command line from the request details. If a header contains special characters like $(), PowerShell will treat that as a command to run. So a malicious website could make your browser send a request with such a header, and if you copy that request and paste it into PowerShell, it could run programs 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.