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

Torrent Viewer CSP rule blocks <iframe> content #7366

Merged
merged 1 commit into from Mar 17, 2017
Merged

Torrent Viewer CSP rule blocks <iframe> content #7366

merged 1 commit into from Mar 17, 2017

Conversation

feross
Copy link
Contributor

@feross feross commented Feb 23, 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.

Description

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

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Ran git rebase -i to squash commits (if needed).

Since this touches CSP, I'd appreciate if @diracdeltas could take a look 🔐 ✅

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
'connect-src': '\'self\' https://example.com',
'media-src': '\'self\' http://localhost:*',
'form-action': '\'none\'',
'referrer': 'no-referrer',
'style-src': '\'self\' \'unsafe-inline\'',
'frame-src': '\'self\''
'frame-src': '\'self\' http://localhost:*'
}

if (process.env.NODE_ENV === 'development') {
// allow access to webpack dev server resources
let devServer = 'localhost:' + process.env.npm_package_config_port
Copy link
Contributor Author

@feross feross Feb 23, 2017

Choose a reason for hiding this comment

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

None of the changes below this line should be substantive. They just remove repetition that might accidentally allow the dev and prod versions of the CSP to diverge.

@feross
Copy link
Contributor Author

feross commented Mar 17, 2017

This has been here for a while, going to go ahead and land it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fixed torrent viewer CSP rule blocks <iframe> content
3 participants