Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Fixed torrent viewer CSP rule blocks <iframe> content #7243

Closed
feross opened this issue Feb 14, 2017 · 8 comments · Fixed by #7366
Closed

Fixed torrent viewer CSP rule blocks <iframe> content #7243

feross opened this issue Feb 14, 2017 · 8 comments · Fixed by #7366

Comments

@feross
Copy link
Contributor

feross commented Feb 14, 2017

Test Plan:

  1. Load the WIRED CD torrent from https://codepen.io/ferossity/full/qaezaB/
  2. Start the torrent
  3. Click on a non-media file like poster.jpg or README.md to view it in Brave.
  4. It should load and display correctly.

Original issue description

  • Did you search for similar issues before submitting this one? Yes

  • Describe the issue you encountered:

Sometimes torrent content is rendered in an <iframe> instead of a <video> or <audio> tag. It's unclear why. When this occurs, CSP prevents the iframe from loading content from the webtorrent server at http://localhost:port

  • Platform (Win7, 8, 10? macOS? Linux distro?): macOS Sierra

  • Brave Version (revision SHA): master @ 6cf4f1b

  • Steps to reproduce:

    1. Happens to one of the torrents here, can't remember which off the top of my head https://codepen.io/ferossity/full/qaezaB/
    2. Start the torrent
    3. Click on a file in the torrent to view it in Brave
  • Actual result: File content fails to load

  • Expected result: File content should load

  • Will the steps above reproduce in a fresh profile? If not what other info can be added? Yes

  • Is this an issue in the currently released version? Yes

  • Can this issue be consistently reproduced? Yes

@feross
Copy link
Contributor Author

feross commented Feb 14, 2017

I can tackle this issue.

@feross feross self-assigned this Feb 23, 2017
@feross
Copy link
Contributor Author

feross commented Feb 23, 2017

Sometimes torrent content is rendered in an <iframe> instead of a <video> or <audio> tag. It's unclear why.

Torrent content is rendered into <iframe> when it's not video or audio content. For example, a .jpg or a .pdf file. This is because we're using a viewer page that includes the content; we're not returning the content directly.

This is because the torrent may not be active and in that case, we show the "Start Download?" page.

When this occurs, CSP prevents the iframe from loading content from the webtorrent server at http://localhost:port

This is because we only make a CSP exception for media elements, not iframe elements. This is an easy fix.

feross added a commit that referenced this issue Feb 23, 2017
Torrent content is rendered into <iframe> when it's not video or audio
content. For example, a .jpg or a .pdf file. This is because we're
using a viewer page that includes the content; we're not returning the
content directly.

This is because the torrent may not be active and in that case, we show
the "Start Download?" page.

When this occurs, CSP prevents the iframe from loading content from the
webtorrent server at http://localhost:port

This is because we only make a CSP exception for media elements, not
iframe elements. This is an easy fix.

Fixes: #7243
@feross feross added this to the 0.13.5 milestone Feb 23, 2017
@bbondy bbondy modified the milestones: 0.13.5, 0.13.6 Feb 28, 2017
@alexwykoff alexwykoff mentioned this issue Mar 14, 2017
44 tasks
@bsclifton
Copy link
Member

Moving to 0.14.1

@bsclifton bsclifton modified the milestones: 0.14.1, 0.14.0 Mar 15, 2017
@luixxiul
Copy link
Contributor

Moving back to 0.14.0?

@feross
Copy link
Contributor Author

feross commented Mar 17, 2017

Oh, sorry if I merged too soon.

@luixxiul
Copy link
Contributor

By following the test plan I get this error.

clipboard01

@luixxiul luixxiul added the needs-investigation A bug not 100% confirmed/fixed that needs QA to better audit. label Mar 17, 2017
@srirambv
Copy link
Collaborator

When torrent is opened within the the page, the file is not shown but opening the magnet link in a new tab it shows the file. Is this expected?
7243

No errors in console, on Windows 10 x64, like @luixxiul mentioned

@feross
Copy link
Contributor Author

feross commented Mar 17, 2017

@srirambv @luixxiul All this behavior is expected.

CodePen switched to https and that prevents us framing the magnet: link viewer, since magnet links are considered insecure content. Insecure content can't be framed in a secure context; that's "mixed content" and is prevented by the browser.

I'll add target='_blank' to all the links in the CodePen to make it easier to open links in a new tab, without the framing that CodePen is doing.

The console error spew is normal and harmless. Working as expected, though I'm working on preventing the spew in this PR: #7351

@luixxiul luixxiul removed the needs-investigation A bug not 100% confirmed/fixed that needs QA to better audit. label Mar 18, 2017
@alexwykoff alexwykoff changed the title Torrent Viewer CSP rule blocks <iframe> content Fixed torrent viewer CSP rule blocks <iframe> content Mar 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.