Copy As Curl (Posix) - Code Execution - bug 1949994 bypass
The fix for a previous command injection in Firefox's 'Copy as cURL' feature only blocked the ampersand character, but the pipe character still allowed command execution. An attacker could craft a request that, when copied as cURL and pasted into a command prompt, executes arbitrary commands on the victim's machine.
Originally disclosed on Mozilla
- Fixed in 3 days
- Paid in 3 days
- Disclosed after 3 days
Hi Team, while retesting my another fixed issue (Ref added below), i have found a way to bypass the fix and get my code executed on victim machine
Ref: https://bugzilla.mozilla.org/show_bug.cgi?id=1949994
Root Cause: & and | both allows cmd to execute multiple commands seems only & is handled in above ticket. Using | i can still execute code
Payload
'''js
fetch("/", {
credentials: "omit",
headers: {
"Accept-Language": "en-US",
"Content-Type": "text/plain",
},
body: "query=evil\n\n | cmd /c calc.exe \n\n",
method: "POST",
});
'''
Steps to reproduce
1. Paste the above code in console (or) include it in a html file to auto send the request
2. Copy the request as curl (posix) feature
3. Paste it on cmd and you can see calc pops up
Tested it on latest firefox nightly (on which #1949994 is fixed)
I have attached the poc video for reference
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 fix for the previous issue only sanitised the ampersand character but did not account for the pipe character, which also allows command chaining in Windows cmd.
Impact
An attacker could execute arbitrary commands on a victim's machine if the victim copies a crafted request as cURL and pastes it into a command prompt, but this requires user interaction and is limited to Windows systems using cmd.
What the attacker needed
Victim uses Firefox with the vulnerable feature; victim copies a crafted request as cURL; victim pastes the command into Windows cmd
How it was found
- Paste the provided JavaScript code into the browser console or include it in an HTML file to automatically send the request.
- Use the 'Copy as cURL (POSIX)' feature on the crafted request.
- Paste the copied command into a Windows command prompt and observe the calculator application launching.
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 web request as a cURL command, Firefox builds a command line. If the request contains special characters like '|', the command line can be tricked into running extra commands. This report shows that a previous fix only blocked '&' but not '|', so an attacker could still run programs on your computer if you copy and paste the generated command.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.