Skip to content
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

MSC1693: Specify how to handle rejected events in new state res #1693

Merged
merged 24 commits into from
Dec 23, 2018
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3d3b77e
Specify how to handle rejected events in new state res
erikjohnston Oct 8, 2018
4790432
Update rejected events discussion
erikjohnston Oct 9, 2018
4df346a
Add metadata about update
erikjohnston Oct 30, 2018
40d943f
Clarify 'auth difference' definition
erikjohnston Oct 30, 2018
25fb09b
Fix up formatting
erikjohnston Oct 30, 2018
1f1ba28
ACTUALLY! Let's just accept rejected events, because what's the worst…
erikjohnston Oct 31, 2018
a6aab37
Typo
erikjohnston Oct 31, 2018
b8a8d13
Note why convergence is desirable
erikjohnston Nov 1, 2018
a80ff2f
Don't use rejected auth events
erikjohnston Nov 5, 2018
6c9a433
Add example of rejected events getting into state
erikjohnston Dec 10, 2018
eaaf36e
Update proposals/1442-state-resolution.md
richvdh Dec 11, 2018
c581c61
Update proposals/1442-state-resolution.md
richvdh Dec 11, 2018
539ca4c
Update proposals/1442-state-resolution.md
richvdh Dec 11, 2018
f064554
Update proposals/1442-state-resolution.md
richvdh Dec 11, 2018
612d8a6
Update proposals/1442-state-resolution.md
richvdh Dec 11, 2018
7782781
Update wording to be betterer
richvdh Dec 11, 2018
8a3e7b7
Add missing apostrophe
erikjohnston Dec 11, 2018
a8bd2f3
Update example
erikjohnston Dec 11, 2018
bc9d205
Make lines bold
erikjohnston Dec 13, 2018
b695eb0
Clarify example
erikjohnston Dec 13, 2018
463c71a
Add a note about the examples
erikjohnston Dec 13, 2018
48d271e
Clarifications
erikjohnston Dec 14, 2018
39f7c77
Add dot for image file
erikjohnston Dec 14, 2018
8fb2bd2
Fix typo
erikjohnston Dec 18, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 69 additions & 4 deletions proposals/1442-state-resolution.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# State Resolution: Reloaded
- **Author**: Erik Johnston
- **Created**: 2018-07-20
- **Updated**:
- #1693: Clarify how to handle rejected events ─ Erik Johnston, 2018-10-30



# State Resolution: Reloaded

Thoughts on the next iteration of the state resolution algorithm that aims to
mitigate currently known attacks
Expand Down Expand Up @@ -47,7 +53,7 @@ which can be summarized into two separate cases:

1. Moderation evasion ─ where an attacker can avoid e.g. bans by forking and
joining the room DAG in particular ways.
1. State resets ─ where a server (often innocently) sends an event that points
2. State resets ─ where a server (often innocently) sends an event that points
to disparate parts of the graph, causing state resolution to pick old state
rather than later versions.

Expand Down Expand Up @@ -279,8 +285,8 @@ First we define:
events, the auth check algorithm is applied to each event in turn. The state
events used to auth are built up from previous events that passed the auth
checks, starting from a base set of state. If a required auth key doesn't
exist in the state, then the one in the event's auth_events is used. (See
_Variations_ and _Attack Vectors_ below).
exist in the state, then the one in the event's auth_events is used if the
auth event is not rejected. (See _Variations_ and _Attack Vectors_ below).

The algorithm proceeds as follows:

Expand Down Expand Up @@ -436,6 +442,42 @@ a separate auth chain, and the difficulties that entails (like having to
reapply the unconflicted state at the end).


### Rejected Events
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i still think it would be useful to have the summary of:

There are basically four levels of your server going "ewwwwwwwww" at an event, in order of severity:
1. hashes/signatures don't match
2. event doesn't pass auth based on their auth events
3. event doesn't pass auth based on the state at the event
4. event doesn't pass auth based on the current state of the room

in here somehow, to make it clear what the bigger picture for rejections is.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally that would be in the section of the spec which talks about how to handle rejections, not sure if it makes sense to duplicate it here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it actually exist in that bit of the spec, though? i still think it's key to understanding this part of the world, and it needs to be spelt out clearly int he spec.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll go and add it to the spec then and block this MSC on that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


Events that have been rejected due to failing auth based on the state at the
event (rather than based on their auth chain) are handled as usual by the
algorithm, unless otherwise specified.

Note that no events rejected due to failure to auth against their auth chain
should appear in the process, as they should not appear in state (and the
algorithm only uses events in one of the state sets or their auth events).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm failing to parse "or their auth events". it's unclear if 'their' refers to the rejected events, or the events in one of the state sets. i assume it's meant to be:

(and the algorithm only uses events (or their auth events) in that exist in one of the state sets)

perhaps?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've rejigged it a bit, but I meant the latter. Hope its clearer now


This helps ensure that different servers' view of state is more likely to
converge, since rejection state of an event may be different. This can happen if
a third server gives an incorrect version of the state when a server joins a
room via it (either due to being faulty or malicious). Convergence of state is a
desirable property as it ensures that all users in the room have a (mostly)
consistent view of the state of the room. If the view of the state on different
servers diverges it can lead to bifurcation of the room due to e.g. servers
disagreeing on who is in the room.

Intuitively using rejected events feels dangerous, however:
erikjohnston marked this conversation as resolved.
Show resolved Hide resolved

1. Servers cannot arbitrarily make up state, since they still need to pass the
auth checks based on the event's auth chain (e.g. they can't grant themselves
power levels if they didn't have them before).
2. For a previously rejected event to pass auth there must be a set of state
that allows said event. A malicious server could therefore produce a
fork where it claims the state is that particular set of state, duplicate the
rejected event to point to that fork, and send the event. The
duplicated event would then pass the auth checks. Ignoring rejected events would therefore not
eliminate any potential attack vectors.

Rejected auth events are deliberately excluded from use in the iterative auth checks, as
auth events aren't re-authed during the iterative auth checks (although non-auth events are.)
list.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's something with the end of this sentence. Probably, it should've been "auth events arent' re-authed (although non-auth events are) during the iterative auth checks"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ta, will have a look

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like list is lingering from a past version/idea?



### Attack Vectors

The main potential attack vector that needs to be considered is in the
Expand All @@ -446,6 +488,12 @@ event.

# Appendix

The following are some worked examples to illustrate some of the mechanisms in
the algorithm. In each we're interested in what happens to the topic.


## Example 1 - Mainline

The following is an example room DAG, where time flows down the page. We shall
work through resolving the state at both _Message 2_ and _Message 3_.

Expand Down Expand Up @@ -501,6 +549,23 @@ auth checks, and so the last topic, _Topic 4_, is chosen.
This gives the resolved state at _Message 3_ to be _Topic 4_.


## Example 2 - Rejected Events

The following is an example room DAG, where time flows down the page. The event
`D` is initially rejected by the server (due to not passing auth against the
state), but does pass auth against its auth chain.

![state-res-rejected.png](images/state-res-rejected.png)
erikjohnston marked this conversation as resolved.
Show resolved Hide resolved

(Note that the blue lines are the power levels pointed to in the event's auth
events)

At `F` we first resolve the power levels, which results in `E`. When we then go
to resolve the topics against the partially resolved state, Bob has ops and so
the resolved state includes the topic change `D`, even though it was initially
rejected.


## Notes

[^1]: In the current room protocol these are: the create event, power levels,
Expand Down
Binary file added proposals/images/state-res-rejected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.