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

WebTorrent: intercept only top-level frame requests for .torrent files #3035

Merged
merged 3 commits into from
Jul 27, 2019

Conversation

feross
Copy link
Contributor

@feross feross commented 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

(Rebased on top of this unmerged PR (#2990) to avoid merge conflicts later. So no need to review anything but the last commit)

Submitter Checklist:

Test Plan:

There are three test plans, see these issues:

Reviewer Checklist:

  • New files have MPL-2.0 license header.
  • Request a security/privacy review as needed.
  • Adequate test coverage exists to prevent regressions
  • Verify test plan is specified in PR before merging to source

After-merge Checklist:

  • The associated issue milestone is set to the smallest version that the
    changes has landed on.
  • All relevant documentation has been updated.

- `renderFileLink` is never called when `torrent` is null
- Remove duplicate props deconstruction
When the user clicks on a file in the torrent file list, a new tab opens which points to the .torrent file, but with a file fragment appended. For example, the torrent https://webtorrent.io/torrents/big-buck-bunny.torrent would have a link to https://webtorrent.io/torrents/big-buck-bunny.torrent#ix=1 for the 2nd file in the torrent.

Without this PR, this request passes the `IsWebtorrentInitiated(ctx)` condition and is therefore allowed to reach the network. Instead, we should confirm that the request is not for an individual file before letting it go to the network. That's what this commit does.

Fixes: brave/brave-browser#3966
@feross feross added the feature/webtorrent Label for webtorrent related issues label Jul 26, 2019
@feross feross added this to the 0.70.x - Nightly milestone Jul 26, 2019
@feross feross requested a review from yrliou July 26, 2019 23:39
@feross feross self-assigned this 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
Copy link
Member

@yrliou yrliou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with just one tiny nit

@feross feross merged commit f505510 into master Jul 27, 2019
@feross feross deleted the webtorrent-intercept branch July 27, 2019 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/webtorrent Label for webtorrent related issues
Projects
None yet
2 participants