@@ -68,17 +68,17 @@ Server names are resolved to an IP address and port to connect to, and
68
68
have various conditions affecting which certificates and ` Host ` headers
69
69
to send. The process overall is as follows:
70
70
71
- 1 . If the hostname is an IP literal, then that IP address should be
71
+ 1 . If the hostname is an IP literal, then that IP address should be
72
72
used, together with the given port number, or 8448 if no port is
73
73
given. The target server must present a valid certificate for the IP
74
74
address. The ` Host ` header in the request should be set to the
75
75
server name, including the port if the server name included one.
76
- 2 . If the hostname is not an IP literal, and the server name includes
76
+ 2 . If the hostname is not an IP literal, and the server name includes
77
77
an explicit port, resolve the IP address using AAAA or A records.
78
78
Requests are made to the resolved IP address and given port with a
79
79
` Host ` header of the original server name (with port). The target
80
80
server must present a valid certificate for the hostname.
81
- 3 . If the hostname is not an IP literal, a regular HTTPS request is
81
+ 3 . If the hostname is not an IP literal, a regular HTTPS request is
82
82
made to ` https://<hostname>/.well-known/matrix/server ` , expecting
83
83
the schema defined later in this section. 30x redirects should be
84
84
followed, however redirection loops should be avoided. Responses
@@ -95,40 +95,40 @@ to send. The process overall is as follows:
95
95
to step 4. If the response is valid, the ` m.server ` property is
96
96
parsed as ` <delegated_hostname>[:<delegated_port>] ` and processed as
97
97
follows:
98
- - If ` <delegated_hostname> ` is an IP literal, then that IP address
98
+ - If ` <delegated_hostname> ` is an IP literal, then that IP address
99
99
should be used together with the ` <delegated_port> ` or 8448 if
100
100
no port is provided. The target server must present a valid TLS
101
101
certificate for the IP address. Requests must be made with a
102
102
` Host ` header containing the IP address, including the port if
103
103
one was provided.
104
- - If ` <delegated_hostname> ` is not an IP literal, and
104
+ - If ` <delegated_hostname> ` is not an IP literal, and
105
105
` <delegated_port> ` is present, an IP address is discovered by
106
106
looking up an AAAA or A record for ` <delegated_hostname> ` . The
107
107
resulting IP address is used, alongside the ` <delegated_port> ` .
108
108
Requests must be made with a ` Host ` header of
109
109
` <delegated_hostname>:<delegated_port> ` . The target server must
110
110
present a valid certificate for ` <delegated_hostname> ` .
111
- - If ` <delegated_hostname> ` is not an IP literal and no
111
+ - If ` <delegated_hostname> ` is not an IP literal and no
112
112
` <delegated_port> ` is present, an SRV record is looked up for
113
113
` _matrix._tcp.<delegated_hostname> ` . This may result in another
114
114
hostname (to be resolved using AAAA or A records) and port.
115
115
Requests should be made to the resolved IP address and port with
116
116
a ` Host ` header containing the ` <delegated_hostname> ` . The
117
117
target server must present a valid certificate for
118
118
` <delegated_hostname> ` .
119
- - If no SRV record is found, an IP address is resolved using AAAA
119
+ - If no SRV record is found, an IP address is resolved using AAAA
120
120
or A records. Requests are then made to the resolve IP address
121
121
and a port of 8448, using a ` Host ` header of
122
122
` <delegated_hostname> ` . The target server must present a valid
123
123
certificate for ` <delegated_hostname> ` .
124
- 4 . If the ` /.well-known ` request resulted in an error response, a
124
+ 4 . If the ` /.well-known ` request resulted in an error response, a
125
125
server is found by resolving an SRV record for
126
126
` _matrix._tcp.<hostname> ` . This may result in a hostname (to be
127
127
resolved using AAAA or A records) and port. Requests are made to the
128
128
resolved IP address and port, using 8448 as a default port, with a
129
129
` Host ` header of ` <hostname> ` . The target server must present a
130
130
valid certificate for ` <hostname> ` .
131
- 5 . If the ` /.well-known ` request returned an error response, and the
131
+ 5 . If the ` /.well-known ` request returned an error response, and the
132
132
SRV record was not found, an IP address is resolved using AAAA and A
133
133
records. Requests are made to the resolved IP address using port
134
134
8448 and a ` Host ` header containing the ` <hostname> ` . The target
@@ -137,6 +137,7 @@ to send. The process overall is as follows:
137
137
{{% boxes/note %}}
138
138
The reasons we require ` <hostname> ` rather than ` <delegated_hostname> ` for SRV
139
139
delegation are:
140
+
140
141
1 . DNS is insecure (not all domains have DNSSEC), so the target of the delegation
141
142
must prove that it is a valid delegate for ` <hostname> ` via TLS.
142
143
2 . Consistency with the recommendations in [ RFC6125] ( https://datatracker.ietf.org/doc/html/rfc6125#section-6.2.1 )
@@ -356,17 +357,17 @@ specification](/rooms).
356
357
Whenever a server receives an event from a remote server, the receiving
357
358
server must ensure that the event:
358
359
359
- 1 . Is a valid event, otherwise it is dropped. For an event to be valid, it
360
+ 1 . Is a valid event, otherwise it is dropped. For an event to be valid, it
360
361
must contain a ` room_id ` , and it must comply with the event format of
361
362
that [ room version] ( /rooms ) .
362
- 2 . Passes signature checks, otherwise it is dropped.
363
- 3 . Passes hash checks, otherwise it is redacted before being processed
363
+ 2 . Passes signature checks, otherwise it is dropped.
364
+ 3 . Passes hash checks, otherwise it is redacted before being processed
364
365
further.
365
- 4 . Passes authorization rules based on the event's auth events,
366
+ 4 . Passes authorization rules based on the event's auth events,
366
367
otherwise it is rejected.
367
- 5 . Passes authorization rules based on the state before the event,
368
+ 5 . Passes authorization rules based on the state before the event,
368
369
otherwise it is rejected.
369
- 6 . Passes authorization rules based on the current state of the room,
370
+ 6 . Passes authorization rules based on the current state of the room,
370
371
otherwise it is "soft failed".
371
372
372
373
Further details of these checks, and how to handle failures, are
@@ -394,6 +395,25 @@ unspecified.
394
395
For an ` m.room.member ` state event, the user given by the ` state_key ` of
395
396
the event.
396
397
398
+ ** Historical String Power Levels** \
399
+
400
+ In order to maintain backwards compatibility with early implementations,
401
+ power levels can optionally be represented in string format instead of
402
+ integer format. A homeserver must be prepared to deal with this by parsing
403
+ the power level from a string. In these cases, the following formatting of the
404
+ power level string is allowed:
405
+
406
+ - a single Base10 integer, no float values or decimal points, optionally with leading zeroes;
407
+ - optionally with leading or trailing whitespace characters;
408
+ - optionally prefixed with a single ` - ` or ` + ` character before the integer but after leading whitespace padding.
409
+
410
+ {{% boxes/warning %}}
411
+ This behaviour is preserved strictly for backward compatibility only. A
412
+ homeserver should take reasonable precautions to prevent users from
413
+ sending new power level events with string values and must never
414
+ populate the default power levels in a room as string values.
415
+ {{% /boxes/warning %}}
416
+
397
417
#### Authorization rules
398
418
399
419
The rules governing whether an event is authorized depends on a set of
@@ -418,14 +438,14 @@ the following subset of the room state:
418
438
419
439
- If type is ` m.room.member ` :
420
440
421
- - The target's current ` m.room.member ` event, if any.
422
- - If ` membership ` is ` join ` or ` invite ` , the current
441
+ - The target's current ` m.room.member ` event, if any.
442
+ - If ` membership ` is ` join ` or ` invite ` , the current
423
443
` m.room.join_rules ` event, if any.
424
- - If membership is ` invite ` and ` content ` contains a
444
+ - If membership is ` invite ` and ` content ` contains a
425
445
` third_party_invite ` property, the current
426
446
` m.room.third_party_invite ` event with ` state_key ` matching
427
447
` content.third_party_invite.signed.token ` , if any.
428
- - If ` content.join_authorised_via_users_server ` is present,
448
+ - If ` content.join_authorised_via_users_server ` is present,
429
449
and the [ room version supports restricted rooms] ( /rooms/#feature-matrix ) ,
430
450
then the ` m.room.member ` event with ` state_key ` matching
431
451
` content.join_authorised_via_users_server ` .
@@ -1101,22 +1121,22 @@ of `M_FORBIDDEN`.
1101
1121
1102
1122
The following endpoint prefixes MUST be protected:
1103
1123
1104
- - ` /_matrix/federation/v1/send ` (on a per-PDU basis)
1105
- - ` /_matrix/federation/v1/make_join `
1106
- - ` /_matrix/federation/v1/make_leave `
1107
- - ` /_matrix/federation/v1/send_join `
1108
- - ` /_matrix/federation/v2/send_join `
1109
- - ` /_matrix/federation/v1/send_leave `
1110
- - ` /_matrix/federation/v2/send_leave `
1111
- - ` /_matrix/federation/v1/invite `
1112
- - ` /_matrix/federation/v2/invite `
1113
- - ` /_matrix/federation/v1/make_knock `
1114
- - ` /_matrix/federation/v1/send_knock `
1115
- - ` /_matrix/federation/v1/state `
1116
- - ` /_matrix/federation/v1/state_ids `
1117
- - ` /_matrix/federation/v1/backfill `
1118
- - ` /_matrix/federation/v1/event_auth `
1119
- - ` /_matrix/federation/v1/get_missing_events `
1124
+ - ` /_matrix/federation/v1/send ` (on a per-PDU basis)
1125
+ - ` /_matrix/federation/v1/make_join `
1126
+ - ` /_matrix/federation/v1/make_leave `
1127
+ - ` /_matrix/federation/v1/send_join `
1128
+ - ` /_matrix/federation/v2/send_join `
1129
+ - ` /_matrix/federation/v1/send_leave `
1130
+ - ` /_matrix/federation/v2/send_leave `
1131
+ - ` /_matrix/federation/v1/invite `
1132
+ - ` /_matrix/federation/v2/invite `
1133
+ - ` /_matrix/federation/v1/make_knock `
1134
+ - ` /_matrix/federation/v1/send_knock `
1135
+ - ` /_matrix/federation/v1/state `
1136
+ - ` /_matrix/federation/v1/state_ids `
1137
+ - ` /_matrix/federation/v1/backfill `
1138
+ - ` /_matrix/federation/v1/event_auth `
1139
+ - ` /_matrix/federation/v1/get_missing_events `
1120
1140
1121
1141
## Signing Events
1122
1142
@@ -1157,11 +1177,11 @@ redacted copy.
1157
1177
1158
1178
The signatures expected on an event are:
1159
1179
1160
- - The ` sender ` 's server, unless the invite was created as a result of
1180
+ - The ` sender ` 's server, unless the invite was created as a result of
1161
1181
3rd party invite. The sender must already match the 3rd party
1162
1182
invite, and the server which actually sends the event may be a
1163
1183
different server.
1164
- - For room versions 1 and 2, the server which created the ` event_id ` .
1184
+ - For room versions 1 and 2, the server which created the ` event_id ` .
1165
1185
Other room versions do not track the ` event_id ` over federation and
1166
1186
therefore do not need a signature from those servers.
1167
1187
@@ -1183,12 +1203,12 @@ some room versions. See the [room version
1183
1203
specification] ( /rooms ) for more information. It is
1184
1204
calculated as follows.
1185
1205
1186
- 1 . The event is put through the redaction algorithm.
1187
- 2 . The ` signatures ` , ` age_ts ` , and ` unsigned ` properties are removed
1206
+ 1 . The event is put through the redaction algorithm.
1207
+ 2 . The ` signatures ` , ` age_ts ` , and ` unsigned ` properties are removed
1188
1208
from the event, if present.
1189
- 3 . The event is converted into [ Canonical
1209
+ 3 . The event is converted into [ Canonical
1190
1210
JSON] ( /appendices#canonical-json ) .
1191
- 4 . A sha256 hash is calculated on the resulting JSON object.
1211
+ 4 . A sha256 hash is calculated on the resulting JSON object.
1192
1212
1193
1213
### Calculating the content hash for an event
1194
1214
0 commit comments