Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Brave should not intercept non-navigation .torrent file requests #5361

Closed
feross opened this issue Jul 23, 2019 · 5 comments · Fixed by brave/brave-core#3035
Closed

Brave should not intercept non-navigation .torrent file requests #5361

feross opened this issue Jul 23, 2019 · 5 comments · Fixed by brave/brave-core#3035

Comments

@feross
Copy link

feross commented Jul 23, 2019

Description

If a web page embeds the WebTorrent client-side JS library and attempts to load a .torrent file using an XHR request or fetch, Brave will intercept the .torrent file load and replace it with the chrome-extension HTML, breaking the site. This is true not just for the WebTorrent JS library but for any request to fetch a .torrent file.

There's a CodePen that demonstrates this here: https://codepen.io/yciabaud/pen/XdOeWM

Steps to Reproduce

  1. Visit https://codepen.io/yciabaud/pen/XdOeWM
  2. The torrent demo should fail with an error in the console.
  3. Now, disable the WebTorrent extension in Brave settings.
  4. The demo now works.

Actual result:

Uncaught Error: Error downloading torrent: XHR error
    at VM37 webtorrent.min.js:5
    at t.exports.<anonymous> (VM37 webtorrent.min.js:7)
    at t.exports.t (VM37 webtorrent.min.js:5)
    at t.exports.r.emit (VM37 webtorrent.min.js:4)
    at XMLHttpRequest.c.onerror (VM37 webtorrent.min.js:7)

Expected result:

Brave should not intercept requests for .torrent files unless they are top-level navigation requests.

Reproduces how often:

Easily reproduced

Brave version (brave://version info)

Version 0.66.101 Chromium: 75.0.3770.142 (Official Build) (64-bit)

Version/Channel Information:

  • Can you reproduce this issue with the current release? Yes
  • Can you reproduce this issue with the beta channel?
  • Can you reproduce this issue with the dev channel?
  • Can you reproduce this issue with the nightly channel?

Other Additional Information:

  • Does the issue resolve itself when disabling Brave Shields?
  • Does the issue resolve itself when disabling Brave Rewards?
  • Is the issue reproducible on the latest version of Chrome?

Miscellaneous Information:

@feross
Copy link
Author

feross commented Jul 23, 2019

WebTorrent users reporting the issue here: webtorrent/webtorrent#1649

@feross feross added the bug label Jul 24, 2019
feross added a commit to brave/brave-core that referenced this issue Jul 26, 2019
If a web page embeds the WebTorrent client-side JS library and attempts to
load a .torrent file using an XHR request or fetch, Brave will intercept the
.torrent file load and replace it with the chrome-extension HTML, breaking the
site. This is true not just for the WebTorrent JS library but for any request
to fetch a .torrent file.

Fixes: brave/brave-browser#5361
Fixes: brave/brave-browser#3164
Fixes: brave/brave-browser#1436
@kjozwiak kjozwiak added this to the 0.70.x - Nightly milestone Jul 27, 2019
@feross
Copy link
Author

feross commented Jul 30, 2019

This also fixes this old issue: brave/browser-laptop#10672

@kjozwiak
Copy link
Member

@feross just a quick double check. When opening https://codepen.io/yciabaud/pen/XdOeWM while WebTorrent is enabled, it looks like the client-side JS library loads the .torrent and starts downloading it as per:

Screen Shot 2019-09-18 at 1 40 29 AM

Is the above the expected behaviour? When you have WebTorrent either enabled or disabled, you'll get the above and Brave will start loading the .torrent.

@feross
Copy link
Author

feross commented Sep 18, 2019

@kjozwiak Yep, this is expected behavior. This is JavaScript code running on the website itself and has nothing to do with the built-in WebTorrent implementation in Brave. It's supposed to work in both cases -- when the WebTorrent extension is enabled or disabled.

@kjozwiak
Copy link
Member

kjozwiak commented Sep 18, 2019

Verification PASSED on macOS 10.14.6 x64 using the following build:

Brave 0.69.126 Chromium: 77.0.3865.65 (Official Build) (64-bit)
Revision 87a331a3169cab563505fb44011058b904011ba1-refs/branch-heads/3865@{#726}
OS macOS Version 10.14.6 (Build 18G95)

Verification passed on

Brave 0.69.127 Chromium: 77.0.3865.75 (Official Build) (64-bit)
Revision 201e747d032611c5f2785cae06e894cf85be7f8a-refs/branch-heads/3865@{#776}
OS Ubuntu 18.04 LTS

Verification passed on

Brave 0.69.128 Chromium: 77.0.3865.75 (Official Build) (64-bit)
Revision 201e747d032611c5f2785cae06e894cf85be7f8a-refs/branch-heads/3865@{#776}
OS Windows 10 OS Version 1803 (Build 17134.1006)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment