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

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

merged 6 commits into from
Sep 25, 2018

Conversation

remjey
Copy link
Contributor

@remjey remjey commented Jul 23, 2018

Synapse doesn’t allow for media resources to be played directly from
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.

Synapse doesn’t allow for media resources to be played directly from
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.
@matrixbot
Copy link
Member

Can one of the admins verify this patch?

1 similar comment
@matrixbot
Copy link
Member

Can one of the admins verify this patch?

Signed-off-by: Jérémy Farnaud <[email protected]>
changelog.d/3578.bugfix Outdated Show resolved Hide resolved
@turt2live
Copy link
Member

Note: Whatever happens here, the official suggestion in the spec should be updated alongside it: https://matrix.org/docs/spec/client_server/r0.4.0.html#id112

@richvdh
Copy link
Member

richvdh commented Sep 19, 2018

Thanks. @dbkr can you comment on the sanity of the CSP change?

@richvdh richvdh requested a review from dbkr September 19, 2018 09:12
changelog.d/3578.bugfix Outdated Show resolved Hide resolved
@dbkr
Copy link
Member

dbkr commented Sep 19, 2018

This looks fine: it'll allow you to upload an html page with a

@richvdh
Copy link
Member

richvdh commented Sep 19, 2018

@dbkr: thanks. Do you think we should also update the spec as travis suggests?

@dbkr
Copy link
Member

dbkr commented Sep 25, 2018

Oh, yep, if it's in the spec too we should change it there.

@richvdh
Copy link
Member

richvdh commented Sep 25, 2018

Oh, yep, if it's in the spec too we should change it there.

https://github.com/matrix-org/matrix-doc/issues/1684

@richvdh
Copy link
Member

richvdh commented Sep 25, 2018

ugh now the tests are failing because the branch is out-of-date relative to sytest. merging anyway because bb5d380 passed.

@richvdh richvdh merged commit 6cf2619 into matrix-org:develop Sep 25, 2018
@remjey remjey deleted the resource-downloa-csp-fix branch April 11, 2019 01:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants