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

Unclear IP address syntax requirements #2090

Open
CobaltCause opened this issue Mar 5, 2025 · 3 comments
Open

Unclear IP address syntax requirements #2090

CobaltCause opened this issue Mar 5, 2025 · 3 comments
Labels
clarification An area where the expected behaviour is understood, but the spec could do with being more explicit

Comments

@CobaltCause
Copy link

Problem area: https://spec.matrix.org/v1.13/appendices/#server-name

Issues

IPv6

It's unclear how equivalent IPv6 addresses, like :: and 0:0:0:0:0:0:0:0 for example, should be treated. Should they be normalized or not? Should they compare equal or not? I assume the answer to both of these questions is "no", similar to how DNS names must be treated case-sensitively.

IPv4

The requirements on the format of IPv4 addresses given are:

IPv4address = 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT

— the grammar

IPv4 literals must be a sequence of four decimal numbers in the range 0 to 255, separated by ..

— some prose below the grammar

Does this mean IPv4 addresses with leading zeros, like 000.000.000.000 for example, should be accepted? The grammar permits it, and the prose doesn't really say. If so, this raises the same pair of questions as above (and I assume their answers would be the same).

(At least the possibility of leading zeros indicating the rest of the number should be interpreted as octal is eliminated by the prose. Also, for example, the Rust standard library refuses to parse IPv4 addresses with leading zeros, citing RFC 6943.)

Solutions

  1. Add clarifications to the spec clear up the ambiguities.
  2. Remove the source of the ambiguities: MSC4045: Deprecating the use of IP addresses in server names matrix-spec-proposals#4045
@CobaltCause CobaltCause added the clarification An area where the expected behaviour is understood, but the spec could do with being more explicit label Mar 5, 2025
@CobaltCause
Copy link
Author

Also, above the grammar, some prose says

All valid server names are included by the following grammar

which I suppose is technically correct. It would be more useful and less confusing if the grammar also excluded all invalid server names.

@richvdh
Copy link
Member

richvdh commented Mar 5, 2025

The answer to your first question is "yes, @user:[::] is a different person from @user:[0:0:0:0:0:0:0:0]". Contributions to the spec clarifying this would be welcome.

The answer to the second part is less clear, but since Python and Rust both reject leading zeros in IPv4 literals, I think it's fair to conclude that they are not permitted in a valid server name. Again, contributions to clarify this welcome.

@CobaltCause
Copy link
Author

CobaltCause commented Mar 5, 2025

I think it's fair to conclude that they are not permitted in a valid server name.

To be clear, is 000.000.000.000 an invalid server name, or an invalid IPv4 literal server name? I would assume that a server name like 000.000.000.000 must be treated as a valid DNS name server name.

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

2 participants