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

MSC4009: Expanding the Matrix ID grammar to enable E.164 IDs #4009

Merged
merged 7 commits into from
Jun 16, 2023
Merged
Changes from 4 commits
Commits
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
71 changes: 71 additions & 0 deletions proposals/4009-e.164-matrix-ids.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# MSC4009: E.164 Matrix IDs
clokep marked this conversation as resolved.
Show resolved Hide resolved
clokep marked this conversation as resolved.
Show resolved Hide resolved

[E.164](https://www.itu.int/rec/T-REC-E.164) is a set of international standards
for telephone numbering. This defines a phone number as a `+` followed by a country
code (e.g. `1` for the US, `44` for the UK) followed by a local phone number.
For example, a E.164 phone number would look like: `+15558675309`.

It is somewhat common[^1] for social networks or messaging applications to use phone
numbers as identifiers instead of relying on users remembering separate usernames
clokep marked this conversation as resolved.
Show resolved Hide resolved
(and needing to tell other users how to find them).

[Matrix user identifiers](https://spec.matrix.org/v1.6/appendices/#user-identifiers)
are *almost* compatible with E.164:

> The `localpart` of a user ID is an opaque identifier for that user. It MUST NOT
> be empty, and MUST contain only the characters `a-z`, `0-9`, `.`, `_`, `=`, `-`,
> and `/`.

## Proposal

Add `+` to the list of allowed characters in a Matrix user identifier. This would
allow a full E.164 phone number as the localpart of a Matrix ID: `@+15558675309:example.com`.
clokep marked this conversation as resolved.
Show resolved Hide resolved

It could additionally lower the impedance mismatch when bridging if the identifiers
use the full E.164 phone numbers as identifiers.

## Potential issues

Homeservers and clients must already be
[more tolerant of Matrix user IDs](https://spec.matrix.org/v1.6/appendices/#historical-user-ids):

> Older versions of this specification were more tolerant of the characters
> permitted in user ID localparts. [...] clients and servers MUST accept user IDs
> with localparts from the expanded character set:
>
> `extended_user_id_char = %x21-39 / %x3B-7E ; all ASCII printing chars except :`

Thus it is expected to not cause any issues, although clients will need to identify
that the `+` character is valid for a homeserver. This could be from the supported
Matrix versions which the homeserver advertises.

## Alternatives
clokep marked this conversation as resolved.
Show resolved Hide resolved

The `+` could continue to be disallowed and left off the beginning of the Matrix
IDs Note that Synapse reserves digit-only usernames for guest users, although this
clokep marked this conversation as resolved.
Show resolved Hide resolved
seems to be an implementation detail and not mandated by the specification.

Another option would be to [map from other character sets](https://spec.matrix.org/v1.6/appendices/#mapping-from-other-character-sets)
or prefix the Matrix ID with something (e.g. `msisdn`).
This would generate a Matrix ID like `@=2b15558675309:example.com` or
`@msisdn_5558675309:example.com`, which would dramatically impact usability
for the users on homeservers which use phone numbers as identifiers.

----

Although E.164 limits the `+` character to the initial character there seems to
be no reason to limit that for Matrix identifiers.
clokep marked this conversation as resolved.
Show resolved Hide resolved

## Security considerations
Copy link
Contributor

Choose a reason for hiding this comment

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

What's to prevent someone from creating a phone-number-based account manually of a number they don't own, impersonating the owner of that number?

What's to prevent someone from seizing the account or at least impersonating the former owner of some phone number?

Copy link
Member Author

Choose a reason for hiding this comment

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

Both of those sound like issues for a service operator to deal with, but I can include something about it in here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Although it does bring up whether services should not allow these by default unless they truly are phone numbers. It is easy enough to skip that check or something for spoofing though, so that's likely not very helpful.

clokep marked this conversation as resolved.
Show resolved Hide resolved

None noted.
clokep marked this conversation as resolved.
Show resolved Hide resolved

## Unstable prefix

N/A

## Dependencies

N/A

[^1]: E.g. Signal, WhatsApp, etc.