RCE: DnDing shortcut files to chrome://brave allows loading HTML files in Muon's context
Brave allowed dragging a shortcut file onto a tab to navigate to the privileged chrome://brave origin, where loaded HTML could reach private Electron APIs such as ipcRenderer and ipcMain. An attacker able to supply the shortcut file (for example via a man-in-the-middle position) could then send arbitrary IPC commands, read local files, change settings and run code on the machine.
- Triaged in 7 hours
- Fixed in 8 days
- Paid in 7 days
- Disclosed after 25 days
Summary:
#395737 has shown that Brave supports
chrome://brave/<local_file>URLs. The Brave team introduced a patch which blocks navigation tochrome://braveand removedchrome.remote.requireto prevent command execution on the machine.
Navigation to chrome://brave via shortcut files
From my understanding:
- Brave allows DnDing files
- DnD of shortcut files is handled on Chromium-level (shortcut files : e.g.,
.weblocon macOS or.desktopon Linux) - DnDing a shortcut => navigation to URL the file points to.
This approach allows navigating to chrome://brave/ origin.
Attack requirements
- The victim has to dnd a shortcut file to a tab
- Attacker needs MITM OR local reflected XSS OR an attacker-supplied HTML file which absolute path is known.
MITM is the easiest way so far.
Local files reading
Yeah, reading local files from chrome://brave is possible.
The same PoC as in #390362, but the origin is chrome://brave:
<head>
<!-- Local files reading -->
<script>
function show() {
var file = link.import.querySelector('body')
alert(file.innerHTML)
}
</script>
<link id="link" onload="show()" rel="import" as="document" href="chrome://brave/etc/passwd">
</head>
ipcRender and ipcMain
HTML file loaded in chrome://brave/ context has access to private APIs, like ipcRenderer and ipcMain:
let ipcMain = chrome.remote.getBuiltin('ipcMain')
let ipcRenderer = chrome.ipcRenderer
Sending arbitrary IPC commands -> full control over the browser. RCE through arbitrary IPC commands: #188086 (includes PoC)
Impact: UXSS, URL spoofing, changing browser settings, etc.
chrome.remote.getBuiltin(module)
Sending arbitrary IPC commands is a serious problem, but the impact isn't limited to it.
chrome.remote.getBuiltin(module) returns electron[module].
// Alias to remote.require('electron').xxx.
binding.getBuiltin = function (module) {
return metaToValue(ipcRenderer.sendSync('ELECTRON_BROWSER_GET_BUILTIN', module))
}
It's possible to leverage this func to obtain some "hidden" modules like autoUpdater, Tray, protocol and other.
Running attacker's executables on machine (download .terminal via IPC + <lack-of-quarantine> + chrome.shell.openExternal)
IPC allows doing many damaging things and possibly running shell commands too.
But there is an alternative way for an RCE:
- IPC downloads a
.terminalfile from the web - #374106 -
.terminalfiles could execute shell commands without-xpermission chrome.remote.shell.openExternalopens downloaded.terminalfile- Commands from
.terminalget executed
No PoC provided, since the impact is already apparent, but could make it if required
Persistence
I'm sure, it's clear for the Brave team that it allows an attacker to persist on the device via changing browser settings.
However, I want to highlight that chrome.remote.getBuiltin(module) allows accessing protocol module, which allows:
registerBufferProtocol: (...)
registerHttpProtocol: (...)
registerNavigatorHandler: (...)
registerServiceWorkerSchemes: ƒ ()
registerStandardSchemes: (...)
registerStringProtocol: ƒ ()
MITM in Brave
chrome://braveis always vulnerable to MITM even when HTTPSE is activefile://is vulnerable to MITM, when HTTPSE is inactive
Not sure whether HTTPSE is turned on by default. As far as I know, HTTPS Everywhere isn't enabled by default.
Products affected:
Brave: 0.24.0 V8: 6.9.427.23 rev: f657f15bf7e0e0c50a2b854c6b05edb59bfc556c Muon: 8.1.6 OS Release: 17.7.0 Update Channel: Release OS Architecture: x64 OS Platform: macOS Node.js: 7.9.0 Brave Sync: v1.4.2 libchromiumcontent: 69.0.3497.100
Steps To Reproduce:
PoC for shortcut navigation
- Open any page in Brave
- DnD
etc-passwd.weblocfile to Brave - Brave opens
chrome://brave/etc/passwdshowing/etc/passwdfile inchrome://braveorigin's context
Exploit (macOS)
-1. Make sure to stop httpd on macOS
0. Insert next line into your /etc/hosts: 127.0.0.1 maps.googleapis.com
sudo node server.js- starts MITM server- Open any page in Brave
- DnD
exploit.weblocfile - Opened page shows an alert with
/etc/passwdcontents + working<webview>tag + startsCalculator.app
Supporting Material/References:
Screencast attached.
Impact
A remote attacker with a MITM access (or specific conditions like reflected XSS on file:/// origin) could send arbitrary IPC commands(trigger RCE) when a user drag-n-drops
crafted shortcut file into Brave.
Attachments
Context
Brave's desktop browser at the time of this report was built on Muon, an Electron-derived framework, rather than on the Chromium browser UI. Muon exposed a set of privileged origins and private APIs to the HTML that ran inside them. One of those origins is chrome://brave, and the report opens by noting that an earlier issue, #395737, had already shown that Brave supports chrome://brave/<local_file> URLs. The Brave team responded to that earlier issue with a patch that blocked navigation to chrome://brave and removed chrome.remote.require, in order to prevent command execution on the machine.
This report shows that the navigation block can be bypassed by drag-and-drop of shortcut files, and that once HTML runs in the chrome://brave/ origin it still has access to powerful private APIs, including chrome.remote.getBuiltin, which the earlier removal of chrome.remote.require did not cover.
Setup
The affected product and build details given in the report are:
| Component | Version |
|---|---|
| Brave | 0.24.0 |
| V8 | 6.9.427.23 |
| rev | [redacted] |
| Muon | 8.1.6 |
| OS Release | 17.7.0 |
| Update Channel | Release |
| OS Architecture | x64 |
| OS Platform | macOS |
| Node.js | 7.9.0 |
| Brave Sync | v1.4.2 |
| libchromiumcontent | 69.0.3497.100 |
The exploit walkthrough is written for macOS. The attack requirements stated in the report are:
- The victim has to drag and drop a shortcut file onto a tab.
- The attacker needs a MITM position, or a local reflected XSS, or an attacker-supplied HTML file whose absolute path is known.
The report calls MITM the easiest of these.
Finding it
The researcher's reasoning about the bypass is laid out as three observations:
- Brave allows drag-and-drop of files.
- Drag-and-drop of shortcut files is handled at the Chromium level. Shortcut files are, for example,
.weblocon macOS or.desktopon Linux. - Dropping a shortcut navigates to the URL that the file points to.
Because the drop is handled at the Chromium level, the destination URL can be a chrome://brave/ origin. That is the bypass of the patch that blocked navigation to chrome://brave: the block applies to ordinary navigation, not to the navigation produced by dropping a shortcut file.
Exploitation
Step 1: Navigate to chrome://brave with a shortcut file
The reproduction steps for the shortcut navigation are:
- Open any page in Brave.
- Drag and drop the
etc-passwd.weblocfile onto Brave. - Brave opens
chrome://brave/etc/passwd, showing the/etc/passwdfile in the context of thechrome://braveorigin.
That third step is the core of the bypass: a local file is rendered under a privileged origin, and any HTML the attacker can get into that origin inherits its privileges.
Step 2: Read local files from chrome://brave
The report states that reading local files from chrome://brave is possible, using the same proof of concept as in #390362 but with chrome://brave as the origin:
<head>
<!-- Local files reading -->
<script>
function show() {
var file = link.import.querySelector('body')
alert(file.innerHTML)
}
</script>
<link id="link" onload="show()" rel="import" as="document" href="chrome://brave/etc/passwd">
</head>
The page uses an HTML import (rel="import") pointing at chrome://brave/etc/passwd. When the import loads, show() runs, takes the body of the imported document and shows its innerHTML in an alert. The result is the contents of the local file, read from the privileged origin.
Step 3: Reach ipcRenderer and ipcMain
HTML loaded in the chrome://brave/ context has access to private APIs, including ipcRenderer and ipcMain:
let ipcMain = chrome.remote.getBuiltin('ipcMain')
let ipcRenderer = chrome.ipcRenderer
With these, the page can send arbitrary IPC commands, which the report describes as full control over the browser. It points to #188086 for RCE through arbitrary IPC commands, including a proof of concept. The impact listed for this is UXSS, URL spoofing, changing browser settings, and similar.
Step 4: Obtain hidden modules with chrome.remote.getBuiltin(module)
Sending arbitrary IPC commands is serious, but the report stresses that the impact is not limited to it. chrome.remote.getBuiltin(module) returns electron[module], and the report quotes the binding implementation:
// Alias to remote.require('electron').xxx.
binding.getBuiltin = function (module) {
return metaToValue(ipcRenderer.sendSync('ELECTRON_BROWSER_GET_BUILTIN', module))
}
The function sends a synchronous IPC message, ELECTRON_BROWSER_GET_BUILTIN, with the requested module name and converts the reply back into a value. Through it, the page can obtain modules that are otherwise hidden, such as autoUpdater, Tray, protocol and others.
Step 5: Run attacker executables via a downloaded .terminal file
IPC already allows many damaging actions and possibly running shell commands, but the report describes an alternative route to RCE:
- IPC downloads a
.terminalfile from the web. - Per #374106,
.terminalfiles could execute shell commands without-xpermission. chrome.remote.shell.openExternalopens the downloaded.terminalfile.- The commands in the
.terminalfile get executed.
The report gives no proof of concept for this chain, saying the impact is already apparent, but offers to make one if required.
Step 6: Persistence through the protocol module
The report notes that it should be clear to the Brave team that an attacker can persist on the device by changing browser settings. It highlights that chrome.remote.getBuiltin(module) also gives access to the protocol module, which allows:
registerBufferProtocol: (...)
registerHttpProtocol: (...)
registerNavigatorHandler: (...)
registerServiceWorkerSchemes: ƒ ()
registerStandardSchemes: (...)
registerStringProtocol: ƒ ()
Step 7: Full macOS exploit chain
The end-to-end exploit on macOS is given as:
-1. Make sure to stop httpd on macOS
0. Insert the next line into your /etc/hosts: [redacted] maps.googleapis.com
sudo node server.jsstarts the MITM server- Open any page in Brave
- Drag and drop the
exploit.weblocfile - The opened page shows an alert with the contents of
/etc/passwd, a working<webview>tag, and startsCalculator.app
The /etc/hosts entry points maps.googleapis.com at the loopback address, and server.js is the MITM server started with sudo. The victim drops the exploit.webloc file. The result demonstrates local file read, a working <webview> tag, and execution of a local application.
MITM in Brave
The report adds two notes on MITM exposure:
chrome://braveis always vulnerable to MITM even when HTTPSE is active.file://is vulnerable to MITM when HTTPSE is inactive.
The researcher is not sure whether HTTPSE is turned on by default, and states that as far as they know, HTTPS Everywhere is not enabled by default.
Root cause
The navigation block added after #395737 covered ordinary navigation to chrome://brave, but drag-and-drop of shortcut files is handled at the Chromium level and navigates to the URL the shortcut points to, so it reaches the privileged origin anyway. The removal of chrome.remote.require closed one path to Electron modules, but chrome.remote.getBuiltin(module) remained and returns electron[module] over the ELECTRON_BROWSER_GET_BUILTIN synchronous IPC call, so HTML in the chrome://brave/ origin can still obtain modules such as autoUpdater, Tray and protocol. The origin also exposes ipcRenderer and ipcMain, which allow arbitrary IPC commands. Once attacker HTML is loaded in the chrome://brave/ origin, it inherits the origin's privileges.
Impact
A remote attacker with MITM access, or with specific conditions such as reflected XSS on a file:/// origin, could send arbitrary IPC commands and trigger RCE when a user drags and drops a crafted shortcut file into Brave. The report also lists UXSS, URL spoofing and changing browser settings as impact of arbitrary IPC, and persistence on the device through the protocol module. The .terminal chain would run attacker-supplied commands on the machine. All of these depend on the victim performing the drag-and-drop of the crafted shortcut file.
Fix
The report does not describe a fix for this issue. The earlier patch it references blocked navigation to chrome://brave and removed chrome.remote.require; this report shows both measures were insufficient, since shortcut drops still reach the origin and chrome.remote.getBuiltin still exposes Electron modules.
Variants to test
- Drop a
.desktopshortcut on Linux, or a.weblocon macOS, pointing atchrome://brave/<path>. A positive result is the privileged origin rendering the target path. - Point a dropped shortcut at other privileged or internal origins and see whether the same navigation bypass applies. A positive result is attacker HTML or a local file rendering under that origin.
- From HTML in the privileged origin, call
chrome.remote.getBuiltinwith module names such asautoUpdater,Trayandprotocol. A positive result is a usable module object coming back. - Use the
protocolmodule'sregister*methods to install a handler or scheme. A positive result is a persistent change that survives a restart. - Combine a downloaded
.terminalfile withchrome.remote.shell.openExternal. A positive result is the commands in the file executing. - Repeat the MITM setup with HTTPSE both on and off, against
chrome://braveandfile://. A positive result is the attacker's content loading in either case.
Attachments
The report attaches a screencast, brave-dnd-shortcut-chrome-brave-origin.mp4.
What happened, in plain words
Brave is a web browser. At the time of this report, its desktop version was not built on the same browser engine code as Chrome's user interface. It was built on a framework called Muon, which itself is based on Electron. Electron is a toolkit that lets people build desktop applications using web technology (HTML, CSS, JavaScript). Many popular desktop apps are made this way.
A browser has special internal pages. You have probably seen addresses starting with chrome:// in Chrome or Brave, such as the settings page. These internal pages are trusted by the browser in a way ordinary websites are not. They can use private features that normal web pages are not allowed to touch. One of these internal addresses in Brave is chrome://brave.
An earlier bug report, numbered #395737, had already shown that Brave would happily open addresses of the form chrome://brave/<local_file>, where <local_file> is a file on your own computer. That is dangerous, because it means a file from your disk can be displayed inside a trusted internal page. The Brave team fixed that by adding a patch: they blocked normal navigation to chrome://brave, and they removed a function called chrome.remote.require, which could be used to run commands on the machine.
This report shows that the fix was not enough. There is another way to reach chrome://brave: dragging and dropping a shortcut file onto the browser window. And even after chrome.remote.require was removed, a similar function called chrome.remote.getBuiltin was still available, and it can do much of the same damage.
The researcher who wrote the report is credited as metnew. The report was disclosed on 22 October 2018 and rated high severity, with a CVSS score of 8.3. CVSS is a standard scoring system for how serious a security flaw is; 8.3 out of 10 is in the high range.
The setup
The report lists the exact software versions involved, so that anyone can try to reproduce the problem on the same build:
| Component | Version |
|---|---|
| Brave | 0.24.0 |
| V8 | 6.9.427.23 |
| rev | [redacted] |
| Muon | 8.1.6 |
| OS Release | 17.7.0 |
| Update Channel | Release |
| OS Architecture | x64 |
| OS Platform | macOS |
| Node.js | 7.9.0 |
| Brave Sync | v1.4.2 |
| libchromiumcontent | 69.0.3497.100 |
A few of these need explaining. V8 is the JavaScript engine, the part of the browser that runs JavaScript code. Muon is the Electron-based framework Brave was built on. Node.js is a runtime that lets JavaScript run outside a browser, and Electron apps use it to reach the operating system. libchromiumcontent is the bundled Chromium engine. The rev is a source code revision identifier. The exploit walkthrough is written for macOS, Apple's operating system.
The report states what an attacker needs for the attack to work:
- The victim has to drag and drop a shortcut file onto a tab.
- The attacker needs a MITM position, or a local reflected XSS, or an attacker-supplied HTML file whose absolute path is known.
MITM stands for man in the middle: the attacker sits between the victim's computer and a website, and can read or change the traffic passing between them. XSS stands for cross-site scripting: a way of getting a website to run JavaScript that the attacker wrote. Reflected XSS means the malicious script is bounced back to the victim in a response, for example through a link. An absolute path is the full location of a file on a disk, such as /Users/me/file.html. The report calls MITM the easiest of the three.
Finding it
The researcher's reasoning about how to get around the patch is laid out as three observations:
- Brave allows drag-and-drop of files.
- Drag-and-drop of shortcut files is handled at the Chromium level. Shortcut files are, for example,
.weblocon macOS or.desktopon Linux. - Dropping a shortcut navigates to the URL that the file points to.
A shortcut file is a small file that contains a web address. Double-clicking it opens that address. On macOS the file extension is .webloc; on Linux it is .desktop. The key point is that the drop is handled at the Chromium level. The patch blocked ordinary navigation to chrome://brave, but it did not block the navigation that happens when a shortcut file is dropped. So a dropped shortcut can point at chrome://brave/ and get there anyway.
Exploitation
Step 1: Navigate to chrome://brave with a shortcut file
The reproduction steps for the shortcut navigation are:
- Open any page in Brave.
- Drag and drop the
etc-passwd.weblocfile onto Brave. - Brave opens
chrome://brave/etc/passwd, showing the/etc/passwdfile in the context of thechrome://braveorigin.
/etc/passwd is a standard file on Unix-like systems that lists user accounts. It is a classic target in demonstrations because it is readable by everyone and its contents are easy to recognise. The third step is the heart of the bypass: a local file is rendered under a privileged origin. An origin, in browser terms, is the combination of scheme, host and port that a page belongs to; pages from the same origin share privileges. Any HTML the attacker can get into the chrome://brave origin inherits those privileges.
Step 2: Read local files from chrome://brave
The report states that reading local files from chrome://brave is possible, using the same proof of concept as in #390362 but with chrome://brave as the origin:
<head>
<!-- Local files reading -->
<script>
function show() {
var file = link.import.querySelector('body')
alert(file.innerHTML)
}
</script>
<link id="link" onload="show()" rel="import" as="document" href="chrome://brave/etc/passwd">
</head>
Line by line:
<head>opens the head section of an HTML page, the part that holds information about the page rather than visible content.- The comment
<!-- Local files reading -->is just a note for humans. <script>starts a block of JavaScript, the programming language web pages use.function show() {defines a function namedshow, a named block of code that can be called later.var file = link.import.querySelector('body')finds the element with the idlink(the<link>tag further down), takes the document it imported, and searches inside it for thebodyelement.querySelectoris a standard way to find an element by a CSS selector.alert(file.innerHTML)shows a pop-up box containing the HTML inside that body element.innerHTMLis the text of everything inside an element.- The closing braces and tags end the function and the script.
<link id="link" ...>creates an element with the idlink. Therel="import"attribute marks it as an HTML import, an older web feature that pulls another document into the page.as="document"says the imported thing is a document.href="chrome://brave/etc/passwd"is the address being imported: the local password file, through the privileged origin.onload="show()"says: when the import has finished loading, run theshowfunction.
So the page imports the local file as if it were a web document, and when it arrives, the script reads its contents and displays them. The result is the contents of the local file, read from the privileged origin.
Step 3: Reach ipcRenderer and ipcMain
HTML loaded in the chrome://brave/ context has access to private APIs, including ipcRenderer and ipcMain:
let ipcMain = chrome.remote.getBuiltin('ipcMain')
let ipcRenderer = chrome.ipcRenderer
An API is a set of functions a program offers so that other code can use its features, like a menu of services. IPC stands for inter-process communication: a way for separate parts of an application to send messages to each other. In Electron, ipcRenderer is the side that sends messages from a page, and ipcMain is the side in the main process that receives and acts on them. The main process is the part of the application with full access to the operating system.
Line by line:
let ipcMain = chrome.remote.getBuiltin('ipcMain')asks thechrome.remoteobject for a built-in module namedipcMainand stores it in a variable.letdeclares a variable in JavaScript.let ipcRenderer = chrome.ipcRendererstores the page's own IPC sender in a variable.
With these, the page can send arbitrary IPC commands, which the report describes as full control over the browser. It points to #188086 for RCE through arbitrary IPC commands, including a proof of concept. RCE stands for remote code execution: an attacker can make the victim's machine run code of the attacker's choosing. The impact listed for this is UXSS, URL spoofing, changing browser settings, and similar. UXSS is universal cross-site scripting, where the scripting flaw affects every site the browser visits. URL spoofing means showing a fake address in the address bar so the user believes they are somewhere they are not.
Step 4: Obtain hidden modules with chrome.remote.getBuiltin(module)
Sending arbitrary IPC commands is serious, but the report stresses that the impact is not limited to it. chrome.remote.getBuiltin(module) returns electron[module], and the report quotes the binding implementation:
// Alias to remote.require('electron').xxx.
binding.getBuiltin = function (module) {
return metaToValue(ipcRenderer.sendSync('ELECTRON_BROWSER_GET_BUILTIN', module))
}
Line by line:
- The comment says this function is an alias for
remote.require('electron').xxx, meaning it is a stand-in for the removedchrome.remote.require. binding.getBuiltin = function (module) {defines a function that takes one argument, the name of a module.return metaToValue(ipcRenderer.sendSync('ELECTRON_BROWSER_GET_BUILTIN', module))sends a synchronous IPC message namedELECTRON_BROWSER_GET_BUILTINwith the requested module name. Synchronous means the code waits for the reply before continuing.metaToValueconverts the reply back into a usable value in the page.- The closing brace ends the function.
Through it, the page can obtain modules that are otherwise hidden, such as autoUpdater, Tray, protocol and others. A module is a packaged piece of functionality. autoUpdater handles application updates, Tray controls the icon in the system tray or menu bar, and protocol handles custom URL schemes.
Step 5: Run attacker executables via a downloaded .terminal file
IPC already allows many damaging actions and possibly running shell commands, but the report describes an alternative route to RCE:
- IPC downloads a
.terminalfile from the web. - Per #374106,
.terminalfiles could execute shell commands without-xpermission. chrome.remote.shell.openExternalopens the downloaded.terminalfile.- The commands in the
.terminalfile get executed.
A .terminal file on macOS is a settings file that tells the Terminal application to run a command. The referenced issue #374106 says these files could run commands without the -x permission, meaning without being marked as executable. chrome.remote.shell.openExternal is a function that asks the operating system to open a file or address with its default application. The report gives no proof of concept for this chain, saying the impact is already apparent, but offers to make one if required.
Step 6: Persistence through the protocol module
The report notes that it should be clear to the Brave team that an attacker can persist on the device by changing browser settings. Persistence means the attacker's changes survive a restart, so the attacker keeps a foothold. It highlights that chrome.remote.getBuiltin(module) also gives access to the protocol module, which allows:
registerBufferProtocol: (...)
registerHttpProtocol: (...)
registerNavigatorHandler: (...)
registerServiceWorkerSchemes: ƒ ()
registerStandardSchemes: (...)
registerStringProtocol: ƒ ()
This is a list of functions the protocol module offers. Each register... function installs a handler for a kind of address or scheme. A scheme is the part before the colon in a URL, such as http or file. registerHttpProtocol would let the attacker answer HTTP requests themselves; registerStringProtocol and registerBufferProtocol serve content from strings or buffers; registerStandardSchemes and registerServiceWorkerSchemes declare which schemes are treated as standard or allowed to use service workers. (...) and ƒ () are shorthand for the arguments each function takes. Installing such a handler is a change that can outlive the browsing session, which is why the report calls it persistence.
Step 7: Full macOS exploit chain
The end-to-end exploit on macOS is given as:
-1. Make sure to stop httpd on macOS
0. Insert the next line into your /etc/hosts: [redacted] maps.googleapis.com
sudo node server.jsstarts the MITM server- Open any page in Brave
- Drag and drop the
exploit.weblocfile - The opened page shows an alert with the contents of
/etc/passwd, a working<webview>tag, and startsCalculator.app
Step by step:
- Step -1:
httpdis the built-in web server on macOS. It is stopped before running the MITM server. - Step 0:
/etc/hostsis a file that maps names to addresses before any network lookup happens. The line[redacted] maps.googleapis.commakes the namemaps.googleapis.comresolve to[redacted], the loopback address, which always means "this computer". So requests meant for Google's maps service go to the attacker's own machine instead. - Step 1:
sudo node server.jsruns a Node.js script with administrator rights.sudoruns a command as the superuser. The script is the MITM server that answers in place of the real service. - Step 2: the victim opens any page in Brave.
- Step 3: the victim drags and drops the
exploit.weblocfile. - Step 4: the result demonstrates three things at once: local file read (the alert with
/etc/passwd), a working<webview>tag (a tag that embeds another web page inside the current one), and execution of a local application (Calculator.app).
MITM in Brave
The report adds two notes on MITM exposure:
chrome://braveis always vulnerable to MITM even when HTTPSE is active.file://is vulnerable to MITM when HTTPSE is inactive.
HTTPSE is HTTPS Everywhere, a browser extension that rewrites http:// addresses to https:// so traffic is encrypted. file:// is the scheme for local files. The researcher is not sure whether HTTPSE is turned on by default, and states that as far as they know, HTTPS Everywhere is not enabled by default.
Root cause
The navigation block added after #395737 covered ordinary navigation to chrome://brave, but drag-and-drop of shortcut files is handled at the Chromium level and navigates to the URL the shortcut points to, so it reaches the privileged origin anyway. The removal of chrome.remote.require closed one path to Electron modules, but chrome.remote.getBuiltin(module) remained and returns electron[module] over the ELECTRON_BROWSER_GET_BUILTIN synchronous IPC call, so HTML in the chrome://brave/ origin can still obtain modules such as autoUpdater, Tray and protocol. The origin also exposes ipcRenderer and ipcMain, which allow arbitrary IPC commands. Once attacker HTML is loaded in the chrome://brave/ origin, it inherits the origin's privileges.
Impact
A remote attacker with MITM access, or with specific conditions such as reflected XSS on a file:/// origin, could send arbitrary IPC commands and trigger RCE when a user drags and drops a crafted shortcut file into Brave. The report also lists UXSS, URL spoofing and changing browser settings as impact of arbitrary IPC, and persistence on the device through the protocol module. The .terminal chain would run attacker-supplied commands on the machine. All of these depend on the victim performing the drag-and-drop of the crafted shortcut file.
Fix
The report does not describe a fix for this issue. The earlier patch it references blocked navigation to chrome://brave and removed chrome.remote.require; this report shows both measures were insufficient, since shortcut drops still reach the origin and chrome.remote.getBuiltin still exposes Electron modules.
Variants to test
- Drop a
.desktopshortcut on Linux, or a.weblocon macOS, pointing atchrome://brave/<path>. A positive result is the privileged origin rendering the target path. - Point a dropped shortcut at other privileged or internal origins and see whether the same navigation bypass applies. A positive result is attacker HTML or a local file rendering under that origin.
- From HTML in the privileged origin, call
chrome.remote.getBuiltinwith module names such asautoUpdater,Trayandprotocol. A positive result is a usable module object coming back. - Use the
protocolmodule'sregister*methods to install a handler or scheme. A positive result is a persistent change that survives a restart. - Combine a downloaded
.terminalfile withchrome.remote.shell.openExternal. A positive result is the commands in the file executing. - Repeat the MITM setup with HTTPSE both on and off, against
chrome://braveandfile://. A positive result is the attacker's content loading in either case.
Attachments
The report attaches a screencast, brave-dnd-shortcut-chrome-brave-origin.mp4.
Glossary
- API: a set of functions a program offers so other code can use its features.
- Absolute path: the full location of a file on a disk, starting from the root.
- autoUpdater: an Electron module that handles application updates.
- Binding: the internal code that connects a page's JavaScript to the application's native features.
- Brave: a web browser; the affected product here.
- chrome://brave: a privileged internal address in Brave, whose pages can use private APIs.
- Chromium: the open-source browser engine that many browsers, including Brave, are built on.
- CVSS: a standard scoring system for the severity of a security flaw, from 0 to 10.
- .desktop: a shortcut file format on Linux that points at a command or address.
- Electron: a toolkit for building desktop applications with web technology.
- file://: the URL scheme for files on the local computer.
- HTTPSE (HTTPS Everywhere): a browser extension that rewrites
http://addresses to encryptedhttps://. - httpd: the built-in web server on macOS.
- HTML: the language web pages are written in.
- HTML import: an older web feature that pulls another document into a page, using
rel="import". - innerHTML: the text of everything inside an HTML element.
- IPC: inter-process communication; messages passed between separate parts of an application.
- ipcMain: the Electron side that receives IPC messages in the main process.
- ipcRenderer: the Electron side that sends IPC messages from a page.
- JavaScript: the programming language web pages use.
- libchromiumcontent: the bundled Chromium engine in an Electron-based app.
- Loopback address:
[redacted], which always means the local computer. - Main process: the part of an Electron application with full access to the operating system.
- MITM (man in the middle): an attacker positioned between the victim and a service, able to read or change traffic.
- Module: a packaged piece of functionality that code can load and use.
- Muon: the Electron-derived framework Brave's desktop browser was built on at the time.
- Node.js: a runtime that runs JavaScript outside a browser.
- Origin: the combination of scheme, host and port that a page belongs to; pages from the same origin share privileges.
- Persistence: an attacker's changes surviving a restart, keeping a foothold.
- protocol: an Electron module for handling URL schemes and address handlers.
- querySelector: a standard way to find an element in a document by a CSS selector.
- RCE (remote code execution): an attacker making the victim's machine run code of the attacker's choosing.
- Reflected XSS: cross-site scripting where the malicious script is bounced back in a response, for example through a link.
- Scheme: the part of a URL before the colon, such as
httporfile. - Service worker: a script a browser runs in the background for a site, often to handle requests.
- Shortcut file: a small file containing an address or command, such as
.weblocon macOS or.desktopon Linux. - sudo: a command that runs another command with administrator rights.
- Synchronous: code that waits for a reply before continuing.
- Tray: an Electron module that controls the icon in the system tray or menu bar.
- UXSS (universal cross-site scripting): a scripting flaw that affects every site the browser visits.
- URL spoofing: showing a fake address in the address bar so the user believes they are somewhere they are not.
- V8: the JavaScript engine inside Chromium-based browsers.
- .webloc: a shortcut file format on macOS that points at a web address.
- webview: an HTML tag that embeds another web page inside the current one.
- XSS (cross-site scripting): a way of getting a website to run JavaScript that the attacker wrote.