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

Decode invalid Matrix user IDs #46

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open

Conversation

BramvdnHeuvel
Copy link
Collaborator

As referenced in an issue on the Synapse repository, Synapse servers do not sanitize sender fields and hence allow invalid users to exist. Examples are @:example.org and @🐈:example.org. As a result, Synapse servers cannot send valid initial sync requests to any user that is a member of any one room where an unsanitized invalid user ID has sent at least one state event.

Given that an outright majority of users resides on Synapse and similar servers that permit unsanitized user IDs over federation, this pull request adapts by decoding events individually, and then filtering the ones that contain invalid contents.

The events currently do not show diagnosis for events that went wrong - this is something that should be improved later.
)
localpart
isHistorical ({ localpart } as u) =
String.all validHistoricalLocalpartChar localpart && not (isModern u)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Given that most user IDs are modern in the Matrix ecosystem, this might compute slightly faster if the second option is computed first.



localpartParser : Parser String
localpartParser =
P.chompIf validHistoricalUsernameChar
-- Yes, some illegal users have a zero-length localpart
P.chompWhile (\c -> c /= ':')
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Given that the parser is multiplied, make sure that this passes the tests.

invite.events
}
if UserId.isIllegal event.sender then
invite
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Obsolete: illegal users can no longer appear beyond JSON coders.

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.

1 participant