-
Notifications
You must be signed in to change notification settings - Fork 385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MSC2314: A Method to Backfill Room State #2314
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
615f91a
initial
hawkowl 5cd0a60
rename to msc id
hawkowl ae147a6
fix
hawkowl 1253584
Update to be a backwards-compatible change to the v1 API
hawkowl 7d88e56
wrap, add updates
hawkowl ec68e33
Minor clarifications
richvdh 610f5e3
Update proposals/2314-backfill-current-state.md
richvdh 9558b3a
make `room_version` mandatory
richvdh f50c3c5
clarification
richvdh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# MSC2314: Backfilling Current State | ||
|
||
If a server experiences data loss, it is difficult for it to recover membership | ||
in federation without having a user be reinvited, as backfill alone can not | ||
easily retrieve the data that is required to operate in a room (namely the | ||
current state and auth chain). | ||
|
||
This MSC introduces S2S APIs to provide a given room's auth chain and current | ||
state events, provided the requesting server is in the room specified. | ||
|
||
## Existing APIs | ||
|
||
If one knows the room ID and an event ID, | ||
[`/_matrix/federation/v1/state/{roomId}?event_id={eventId}`](https://spec.matrix.org/v1.2/server-server-api/#get_matrixfederationv1stateroomid) can be used to | ||
retrieve the auth chain and current state events for that given event. However, | ||
this requires knowing an event ID (which cannot be assumed), as well as the | ||
version of the room (which can be assumed to be contained within the current | ||
state delivered). If an event arrives for a room that a Matrix server does not | ||
know about, the event ID could be used to backfill the state, but this is | ||
impractical for rooms which may be low-traffic yet valuable to the end-user | ||
(such as direct messages). | ||
|
||
## Proposal | ||
|
||
Make the `eventId` parameter to [`/v1/state/{roomId}`](https://spec.matrix.org/v1.2/server-server-api/#get_matrixfederationv1stateroomid) | ||
optional. If the `eventId` parameter | ||
is not given, the receiving server is to return what it considers the | ||
room's current state. | ||
|
||
In addition, `room_version` is added as a mandatory response field (giving the | ||
version of the room), irrespective of whether `eventId` is specified. | ||
|
||
``` | ||
GET /_matrix/federation/v1/state/{roomId} | ||
|
||
{ | ||
"room_version": "3", | ||
"auth_chain": [ | ||
{ | ||
"type": "m.room.minimal_pdu", | ||
"room_id": "!somewhere:example.org", | ||
"content": { | ||
"see_room_version_spec": "The event format changes depending on the room version." | ||
} | ||
} | ||
], | ||
"pdus": [ | ||
{ | ||
"type": "m.room.minimal_pdu", | ||
"room_id": "!somewhere:example.org", | ||
"content": { | ||
"see_room_version_spec": "The event format changes depending on the room version." | ||
} | ||
} | ||
] | ||
} | ||
``` | ||
|
||
## Potential issues | ||
|
||
Although the creating server is part of the room ID, a server using this API as | ||
a client may find that the target server does not presently know about the room | ||
(for example, it has been shut down or deleted). Finding servers that will | ||
successfully return results from this API is outside of the scope of this MSC. | ||
|
||
Users may not know the room ID for a given room, only a room alias. Translating | ||
this alias into a room ID is outside of the scope of this MSC. Users of this API | ||
may want to use it in conjunction with [`/_matrix/federation/v1/query/directory`](https://spec.matrix.org/v1.2/server-server-api/#get_matrixfederationv1querydirectory) | ||
to resolve aliases to room IDs as part of an end-user focused API. | ||
|
||
Excessively large rooms may cause performance problems for servers implementing | ||
this API (including in its v1 incarnation). Discretionary rate limiting of this | ||
API may be required. | ||
|
||
## Security considerations | ||
richvdh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
1. Requesting servers should be resilient to the `room_version` field in the response not | ||
matching that in the `m.room.create` event in `pdus`: a malicious or buggy server | ||
could return conflicting data. | ||
|
||
2. In the case of a domain-name hijack, this may make recovering rooms that the | ||
domain name was in easier. However, since a domain name hijack will lead to | ||
other servers potentially sending PDUs with the required event IDs to allow | ||
backfill and state querying, this does not constitute a meaningful increase in | ||
attack surface. Proposals such as MSC1228 are expected to mitigate. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
servers might also have to worry about malicious attempts to get the server to join rooms. A server that really wants you to join a room could send the server an event over
/send
, therefore confusing the server into thinking it might be in the room. The victim server would then use this new API, find out some information about the room (possibly a falsified join event) and push the room through as joined. In theory at some point a signature check would fail, but another workaround could be to ask a couple servers in the room (if possible) to verify the state returned by a server.