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

Re-clarify the auth rules around invite->knock transitions #1710

Closed
kegsay opened this issue Jan 16, 2024 · 6 comments
Closed

Re-clarify the auth rules around invite->knock transitions #1710

kegsay opened this issue Jan 16, 2024 · 6 comments
Labels
clarification An area where the expected behaviour is understood, but the spec could do with being more explicit

Comments

@kegsay
Copy link
Member

kegsay commented Jan 16, 2024

This is a mess so strap yourself in.

Background

Knocking was introduced in MSC2403 and got merged in March 2021. It introduced a new membership state "knock" along with a set of membership transitions to and from it. A puzzling question revolved around the transition from "invite" to "knock". Generally, this makes no sense. A user knocks on a room to receive an invite. If the inviting user wishes to disinvite the user, there is an existing transition from "invite" to "leave" to reflect this. Adding extra transitions increases complexity of the already complex membership state transition diagram. Extra complexity increases the risk of implementation errors or protocol errors.

Timeline

MSC2043, at the point it is accepted in March 2021, does not permit a transition from invite to knock in the auth rules: https://github.com/matrix-org/matrix-spec-proposals/blob/8f304ca9e567ca5b5630992025453b9a21a81b60/proposals/2403-knock.md#auth-rules.

Likewise, the April 2021 spec PR which adopted MSC2043 into the spec, forbade invite->knock transitions in both the auth rules and the state transition table.

The Synapse implementation also did not allow this transition.

Now, this is what happened next..

Current situation

Now Dendrite is looking to implement this, and I see this transition and think this is silly. I look for the rationale why this was allowed and uncover a series of unfortunate events:

The end result is that we have a specification which was clarified incorrectly, meanwhile the Synapse implementation has always disallowed the transition since the MSC was merged.

Next steps

The immediate issue is to urgently clarify the clarification to disallow the state transition before more of the ecosystem allows it. Broad consensus is that is "silly" and really not needed, so we should let sanity prevail and not allow the transition.

There are core underlying issues here though which need to be mentioned. A critical part of the specification was changed (event auth rules) without [adequately] checking what the original implementation did, but yet the implementation was used as a rationale for the change in the first place. Clearly this should never have been permitted and the spec process should have caught this. We need more oversight on this. Accidents happen, and we should not be relying on human memory for critical parts of the specification. In this particular case, multiple people incorrectly claimed the transition was allowed in the implementation. I propose any change to event auth rules, or other access-control-like sections of the specification MUST have external validation in code, to prove out any changes. In practice, I would propose this means having Complement tests (or some other server-agnostic test suite) whenever we wish to change the specification due to the implementation having a certain behaviour.

@kegsay kegsay added the clarification An area where the expected behaviour is understood, but the spec could do with being more explicit label Jan 16, 2024
@kegsay
Copy link
Member Author

kegsay commented Jan 16, 2024

To that end: matrix-org/complement#702

@Mikaela
Copy link

Mikaela commented Jan 16, 2024

#1709 seems related too

@Xiretza
Copy link

Xiretza commented Jan 16, 2024

Regardless of the outcome of this, there's an internal inconsistency that needs to be fixed: https://github.com/matrix-org/matrix-spec/blob/v1.9/content/client-server-api/_index.md?plain=1#L2347

@turt2live
Copy link
Member

Thanks for putting together a comprehensive timeline on this issue. I'm struggling to pull insights from internal context for what happened to cause the different changes, but if I find any I'll raise them here.

In the meantime, I think the action is to revert #1175 and matrix-org/matrix-spec-proposals#3850 ? If so, a PR to that effect is very welcome.

An MSC to discuss the requiring Complement tests process change would also be appreciated, as issues are not the best venue for discussion in this area.

@kegsay
Copy link
Member Author

kegsay commented Jan 23, 2024

@zecakeh
Copy link
Contributor

zecakeh commented Apr 7, 2024

This can be closed now that the PR has been merged? Or is this kept open for the MSC about tests?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clarification An area where the expected behaviour is understood, but the spec could do with being more explicit
Projects
None yet
Development

No branches or pull requests

6 participants