synapse
synapse copied to clipboard
Be stricter when parsing MXC URIs (SYN-393)
We should implement the restrictions on media-ids added in ~~SPEC-165~~ https://github.com/matrix-org/matrix-doc/pull/103
(Imported from https://matrix.org/jira/browse/SYN-393)
(Reported by @Kegsay)
Jira watchers: @Kegsay @NegativeMjark
Related, Synapse 1.47.1
- https://github.com/matrix-org/synapse/commit/91f2bd090
- https://github.com/matrix-org/synapse/blob/develop/docs/changelogs/CHANGES-2021.md#security-advisory
The restrictions in question now live at https://spec.matrix.org/v1.4/client-server-api/#security-considerations-5:
As such, homeservers MUST sanitise MXC URIs by allowing only alphanumeric (
A-Za-z0-9),_and-characters in theserver-nameandmedia-idvalues. This set of whitelisted characters allows URL-safe base64 encodings specified in RFC 4648. Applying this character whitelist is preferable to blacklisting.and/as there are techniques around blacklisted characters (percent-encoded characters, UTF-8 encoded traversals, etc).
https://github.com/matrix-org/synapse/commit/91f2bd090 added some validation to the server name, but still allows characters (in both the server name and media id) not allowed by the above.