Skip to content
RCE Disclosed report Intermediate

Command Execution because of extension handling

When Brave saves a webpage, it uses the website's name as the filename without forcing a safe extension, so a site named with a dangerous extension like .bat is saved as an executable file. An attacker could host a page with such a name and trick a user into saving and running it, leading to command execution.

paulos__ Follow

Originally disclosed on HackerOne

High 8.8 View original
  • Disclosed after 8 months

Summary:

Hello,

Using this bug an attacker can execute commands as the current user using brave & gain complete shell capabilities (and all possibilities associated)

Details:

The issue is in the way the application handles website TLDs. typically in windows, .com represents an application, much similar like .exe - when Brave saves a website (Ctrl+S) - it uses the name of the website.

For PoC purpose I used .bat TLDs because they are much easier to show a poc with instead of binary application garbage data.

So Assume a user visits http://paulos.bat with the contents of:

JavaScript
@echo off
calc

And saves the page, this will save the website as paulos.bat - which when executed - actually opens batch and executes calculator.

Bypassing Mitigations

In Windows, Microsoft warns users when they execute applications that are downloaded, this can simply be bypassed by sending filenames with words like Update or Setup... yeah, I can't believe this works too.

So say a user visits https://malicioussetup.com and saves the site - note this site changed its contents from whatever it was to binary-garbage & microsoft will allow executing it - eventually causing code execution.

This is clearly a chain of low priority issues that cause command execution. :) (POC

Products affected:

  • Tested in Latest Brave Windows (I suspect OSX, iOS & Android may also be affected)

Recommended Fix:

Add .html/htm to the index page (/index.html) to mitigate this easily

Supporting Material/References:

I think you should fix this ASAP! as anyone can register .com sites to abuse it.

Thanks, Paulos

Attachments

win7poc.JPG
win7poc.JPG From the original on HackerOne

The original report as published on HackerOne, by paulos__. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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 browser did not enforce a safe file extension when saving pages, allowing the website's name to dictate the saved file's extension.

Impact

An attacker could achieve command execution as the current user, though the user must save and then run the file, and Windows may show a warning that can be bypassed with certain filenames.

What the attacker needed

Brave on Windows; victim saves the page; victim runs the saved file

The fix

The browser should append a safe extension such as .html to saved pages.

How it was found

  1. Visit a website whose name ends with a dangerous extension such as .bat.
  2. Save the page using Ctrl+S.
  3. The saved file keeps the dangerous extension.
  4. Open the saved file, which executes commands.

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 save a web page, the browser usually picks a filename based on the site's address. Here, the browser did not add a safe ending like .html, so a site named something.bat was saved as a .bat file. On Windows, .bat files run commands when double-clicked, so opening the saved file could run code on your computer.

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 paulos__

View all

16 more disclosed reports, best first.

More from Brave Software

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.