Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

added "media-src: 'self'" to CSP for resources #3578

Merged
merged 6 commits into from
Sep 25, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions changelog.d/3578.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Synapse doesn’t allow for media resources to be played directly from
remjey marked this conversation as resolved.
Show resolved Hide resolved
Chrome. It is a problem for users on other networks (e.g. IRC)
communicating with Matrix users through a gateway. The gateway sends
them the raw URL for the resource when a Matrix user uploads a video
and the video cannot be played directly in Chrome using that URL.

Chrome argues it is not authorized to play the video because of the
Content Security Policy. Chrome checks for the "media-src" policy which
is missing, and defauts to the "default-src" policy which is "none".

As Synapse already sends "object-src: 'self'" I thought it wouldn’t be
a problem to add "media-src: 'self'" to the CSP to fix this problem.

Contributed by Jérémy Farnaud
1 change: 1 addition & 0 deletions synapse/rest/media/v1/download_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def _async_render_GET(self, request):
" script-src 'none';"
" plugin-types application/pdf;"
" style-src 'unsafe-inline';"
" media-src 'self';"
" object-src 'self';"
)
server_name, media_id, name = parse_media_id(request)
Expand Down