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

(Attempt to) Fix event authorization rules to allow first Power Levels events to be injected in the room #1052

Closed
wants to merge 3 commits into from
Closed

(Attempt to) Fix event authorization rules to allow first Power Levels events to be injected in the room #1052

wants to merge 3 commits into from

Conversation

maxidorius
Copy link
Contributor

I believe this is the intended meaning of the sentence.

I just tripped over this as my initial implementation checked against default calculated PLs when injecting the very first m.room.power_levels, in which case it failed.

If you ignore keys which were not set previously, then the rules allow you to create a room and its initial state.

@matrixbot
Copy link
Member

Can one of the admins verify this patch?

@richvdh
Copy link
Member

richvdh commented Nov 4, 2017

Oh gods. It's certainly true that the rules as currently specified are insufficient to create the first power_levels event. However, I don't think that this is the correct interpretation: all of these fields have default values, which are used in this algorithm if no explicit value is given in the power_levels event.

However, the first power_levels event turns out to be special-cased in two separate ways:

  • Firstly, until there is a power_levels event in the room, the room creator has a power level of 100 (and everybody else 0), as per this code. (Which raises the question of "why is state_default special-cased when there is no power_levels event" (as per here. This seems redundant.)
  • Secondly the first power_levels event can do whatever it wants anyway. It doesn't even have to come from the room creator, afaict.

@richvdh
Copy link
Member

richvdh commented Nov 4, 2017

I'm currently undecided as to whether we should spec both of those special-cases, or change synapse in some way. I'll probably have to poll @erikjohnston on the subject.

@maxidorius
Copy link
Contributor Author

Yes, I assumed either synapse gave PL 100 to the creator, or the intended meaning of the rules had to be "for those existing before". I didn't check synapse code on purpose :)
So I did find a real issue :D

@maxidorius
Copy link
Contributor Author

@richvdh if you were to change the rules/wording as per my PR, would it actually behave any different than the current behaviour? I'm not a Math/algo person, so I might have missed a case here...

@richvdh
Copy link
Member

richvdh commented Nov 4, 2017

For example, suppose I have PL 50 (allowing me to send state_events), and you have no PL assigned. Under your wording, I can give you PL 1000 and we can take over the room.

@maxidorius
Copy link
Contributor Author

you're right, that doesn't work then. thanks for the example!

@maxidorius maxidorius changed the title Clarify that only entries of existing PLs in current state are checked (Attempt to) Fix event authorization rules to allow first Power Levels events to be injected in the room Nov 5, 2017
@@ -569,14 +569,14 @@ the state of the room.
``state_default``, ``ban``, ``redact``, ``kick``, ``invite``, as well as
each entry being changed under the ``events`` or ``users`` keys:

i. If the current value is higher than the ``sender``'s current power level,
reject.
i. If the prior existing current value is higher than the ``sender``'s
Copy link
Member

Choose a reason for hiding this comment

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

again, no. Even if the current value is not specified explicitly (so is inferred from the defaults), it may be higher than the sender's level, in which case it should be rejected.

Copy link
Contributor Author

@maxidorius maxidorius Nov 5, 2017

Choose a reason for hiding this comment

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

That extra commit wasn't for review, I wanted to share with someone else and since the branch is in the PR, everything shows :(
There is no fixing the logic without handling it as a special case, for sure.

@maxidorius
Copy link
Contributor Author

@richvdh What should be done with this PR? and the actual logic behind about rules?

@richvdh
Copy link
Member

richvdh commented Nov 15, 2017

I'm currently undecided as to whether we should spec both of those special-cases, or change synapse in some way. I'll probably have to poll @erikjohnston on the subject.

Conclusion was that changes in this area really need to wait for auth rules v2, so we should just make sure that all the existing special-cases are specced.

@maxidorius
Copy link
Contributor Author

This will be split in two PRs as described here. Leaving it open not to forget to do it.

@maxidorius
Copy link
Contributor Author

Split done in #1080 & #1081

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants