Stored XSS in localhost:* via integrated torrent downloader
The filename of a downloaded torrent was not sanitised, so a crafted torrent could place a file whose name contained script into the browser's local download server. An attacker could then run arbitrary JavaScript on the localhost origin, which could steal data from any other service later started on the same port.
- Triaged in 2 days
- Fixed in 2 days
- Disclosed after 30 days
Summary by the researcher
The original PoC that I used in the report doesn't work anymore because my domain (exec.ga) is expired.
The report
Summary:
Due to filename of downloading torrent file isn't sanitized, an attacker is able to execute arbitrary JavaScript on localhost:* by abusing crafted torrent file.
Products affected:
- Brave 0.68.131 Chromium: 76.0.3809.100 (Official Build)
Steps To Reproduce:
- Open https://exec.ga/browser/brave/xss.torrent in Brave Browser.
- Click "Start Torrent" button
- Copy link address of "Save File" button.
- Paste it to URL bar with only hostname and port (e.g. http://localhost:8080).
- Alert will be popped up.
Note: Since it can be embedded with iframe (and it's possible to brute force port number), Steps after 2 won't be needed in real attack.
Video PoC
Impact
Attacker will be able to store arbitrary JavaScript on localhost:* with service worker, so if victim run any software on same port after attack, any information in the website that on same port can be stolen.
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 torrent filename was written into the local download page without sanitisation, allowing script to be stored and executed on the localhost origin.
Impact
An attacker could store script on the localhost origin with a service worker, so if the victim later runs software on the same port, information from that site could be stolen; the report notes the page can be framed and the port brute forced, so the later manual steps may not be needed.
What the attacker needed
Brave 0.68.131 on desktop; victim opens a crafted torrent link; victim starts the torrent download
How it was found
- Open the crafted torrent link in the Brave browser.
- Click the button to start the torrent.
- Copy the link address of the save-file button.
- Paste it into the URL bar keeping only the hostname and port.
- The script runs and an alert appears.
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 download a torrent, the browser serves a small local web page on localhost. This report found the torrent's filename was used there without cleaning, so a name containing code could run as a script. Because that page is on your own machine, the script could later read data from other programs using the same port.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.