Matrix: no .well-known discovery, and port 8448 talks to the wrong API #59

Closed
opened 2026-09-02 00:04:06 -04:00 by Salastil · 1 comment
Owner

The homeserver URL typed into the account form is used verbatim in every endpoint. grep -rn "8448\|well.known" over both trees returns nothing — there is no .well-known/matrix/client resolution and no URL normalisation.

Three consequences:

  • Delegation is unsupported. For a server where the MXID domain differs from the client API host (@user:example.com served at matrix.example.com), you must know and type the real base URL. Entering the MXID domain gets a 404 from /_matrix/client/v3/login.
  • 8448 is the federation port, not the client one. It does not serve /_matrix/client/v3/*, so pointing at it fails with a raw 404 and no hint why. The reconnect loop never gives up, so it fails forever, visibly, with a message that explains nothing.
  • No scheme defaulting or trimming. A pasted matrix.org produces a reqwest builder error surfaced only as a backoff banner.

Media has the same base, so a wrong URL also breaks avatars and attachments — and only the authenticated /_matrix/client/v1/media/download/... endpoint is used, with no fallback to the legacy /_matrix/media/v3/download for older homeservers.

Where: backend/matrix/auth.rs:29, mod.rs:278, :300, :844, :913, :1022, :1303, crypto.rs:155, backup.rs:101, moderation.rs:78-119 all build format!("{}/_matrix/...", homeserver_url). Entry point mod.rs:1582 try_login.

Done looks like: resolve .well-known/matrix/client before the first login call, default a missing scheme, warn specifically on :8448, and persist the resolved base URL rather than the typed string.

The homeserver URL typed into the account form is used verbatim in every endpoint. `grep -rn "8448\|well.known"` over both trees returns nothing — there is no `.well-known/matrix/client` resolution and no URL normalisation. Three consequences: - **Delegation is unsupported.** For a server where the MXID domain differs from the client API host (`@user:example.com` served at `matrix.example.com`), you must know and type the real base URL. Entering the MXID domain gets a 404 from `/_matrix/client/v3/login`. - **8448 is the federation port, not the client one.** It does not serve `/_matrix/client/v3/*`, so pointing at it fails with a raw 404 and no hint why. The reconnect loop never gives up, so it fails forever, visibly, with a message that explains nothing. - **No scheme defaulting or trimming.** A pasted `matrix.org` produces a reqwest builder error surfaced only as a backoff banner. Media has the same base, so a wrong URL also breaks avatars and attachments — and only the authenticated `/_matrix/client/v1/media/download/...` endpoint is used, with no fallback to the legacy `/_matrix/media/v3/download` for older homeservers. **Where:** `backend/matrix/auth.rs:29`, `mod.rs:278`, `:300`, `:844`, `:913`, `:1022`, `:1303`, `crypto.rs:155`, `backup.rs:101`, `moderation.rs:78-119` all build `format!("{}/_matrix/...", homeserver_url)`. Entry point `mod.rs:1582` `try_login`. **Done looks like:** resolve `.well-known/matrix/client` before the first login call, default a missing scheme, warn specifically on `:8448`, and persist the *resolved* base URL rather than the typed string.
Author
Owner

Finished — https://git.salastil.com/Salastil/nobilis/commit/78019ca and https://git.salastil.com/Salastil/moho/commit/a02a0bd

The typed address went verbatim into every request, which broke three ways that all present as a wrong password.

Delegation. A homeserver is named by the domain in a user id, and that domain need not be where the client API lives — @you:example.com is commonly served from matrix.example.com. Servers publish where at /.well-known/matrix/client, and a client that never asks has to be told by hand. Confirmed live while building it: matrix.org delegates to matrix-client.matrix.org, and matrix.poast.org correctly resolves to itself.

Port 8448 is the federation port and does not serve /_matrix/client/v3/* at all, so it fails with a bare 404 and a reconnect loop that retries forever. It is now named in the error rather than silently rewritten — guessing at 443 would be right most of the time and wrong on a server genuinely running the client API elsewhere, and that is the wrong kind of helpful.

A missing scheme. matrix.org is not a URL, and reqwest refuses it with a builder error visible only as a backoff banner. Assumed https, since a homeserver that is not https is not one to send a password to.

Resolved once at sign-in, and the resolved address is what gets stored — so a delegated server is asked where it lives once rather than on every request forever, and an account that works keeps working if the well-known later goes away. A server publishing nothing keeps the address as given, and a well-known naming something that is not a URL is ignored rather than believed, since that would replace a working address with a broken one.

The account form now says both of these up front, because the failure otherwise looks identical to a bad password.

Finished — https://git.salastil.com/Salastil/nobilis/commit/78019ca and https://git.salastil.com/Salastil/moho/commit/a02a0bd The typed address went verbatim into every request, which broke three ways that all present as a wrong password. **Delegation.** A homeserver is named by the domain in a user id, and that domain need not be where the client API lives — `@you:example.com` is commonly served from `matrix.example.com`. Servers publish where at `/.well-known/matrix/client`, and a client that never asks has to be told by hand. Confirmed live while building it: `matrix.org` delegates to `matrix-client.matrix.org`, and `matrix.poast.org` correctly resolves to itself. **Port 8448** is the federation port and does not serve `/_matrix/client/v3/*` at all, so it fails with a bare 404 and a reconnect loop that retries forever. It is now named in the error rather than silently rewritten — guessing at 443 would be right most of the time and wrong on a server genuinely running the client API elsewhere, and that is the wrong kind of helpful. **A missing scheme.** `matrix.org` is not a URL, and reqwest refuses it with a builder error visible only as a backoff banner. Assumed https, since a homeserver that is not https is not one to send a password to. Resolved once at sign-in, and the **resolved** address is what gets stored — so a delegated server is asked where it lives once rather than on every request forever, and an account that works keeps working if the well-known later goes away. A server publishing nothing keeps the address as given, and a well-known naming something that is not a URL is ignored rather than believed, since that would replace a working address with a broken one. The account form now says both of these up front, because the failure otherwise looks identical to a bad password.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Salastil/moho#59