Skip to content

Commit d8be2ad

Browse files
authored
The server-name segment of MXC URIs is sanitised differently from the media-id segment (#2217)
Fixes: #1990 Signed-off-by: Johannes Marbach <n0-0ne+github@mailbox.org>
1 parent 21109b4 commit d8be2ad

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The `server-name` segment of MXC URIs is sanitised differently from the `media-id` segment.

content/client-server-api/modules/content_repo.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,14 @@ entity isn't in the room.
134134
`mxc://` URIs are vulnerable to directory traversal attacks such as
135135
`mxc://127.0.0.1/../../../some_service/etc/passwd`. This would cause the
136136
target homeserver to try to access and return this file. As such,
137-
homeservers MUST sanitise `mxc://` URIs by allowing only alphanumeric
138-
(`A-Za-z0-9`), `_` and `-` characters in the `server-name` and
139-
`media-id` values. This set of whitelisted characters allows URL-safe
137+
homeservers MUST sanitise `mxc://` URIs by:
138+
139+
- restricting the `server-name` segment to valid
140+
[server names](/appendices/#server-name)
141+
- allowing only alphanumeric (`A-Za-z0-9`), `_` and `-` characters in
142+
the `media-id` segment
143+
144+
The resulting set of whitelisted characters allows URL-safe
140145
base64 encodings specified in RFC 4648. Applying this character
141146
whitelist is preferable to blacklisting `.` and `/` as there are
142147
techniques around blacklisted characters (percent-encoded characters,

0 commit comments

Comments
 (0)