Skip to content
RCE Disclosed report Intermediate

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.

Ameen Basha M K Follow

Originally disclosed on Mozilla

  • Fixed in 3 days
  • Paid in 3 days
  • Disclosed after 3 days
Text
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

The original report as published on Mozilla's Bugzilla, by Ameen Basha M K. 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 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

  1. Paste the provided JavaScript code into the browser console or include it in an HTML file to automatically send the request.
  2. Use the 'Copy as cURL (POSIX)' feature on the crafted request.
  3. 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.

More by Ameen Basha M K

View all

23 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.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.