Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Federation uses incorrect Host: header when SRV record is present #2525

Closed
WGH- opened this issue Oct 10, 2017 · 4 comments
Closed

Federation uses incorrect Host: header when SRV record is present #2525

WGH- opened this issue Oct 10, 2017 · 4 comments

Comments

@WGH-
Copy link
Contributor

WGH- commented Oct 10, 2017

Consider:

  • A Matrix homeserver example.org
  • DNS record _matrix._tcp.example.org has SRV record 1 1 443 matrix.example.org.

Synapse sends federation requests to https://matrix.example.org, which is correct, but it uses wrong hostname (example.org instead of matrix.example.org) and also doesn't use SNI (which is a known issue, though, #1491).

The problem is here:

headers_dict[b"Host"] = [destination]

MatrixFederationHttpClient uses original server name, before DNS resolution.

@richvdh
Copy link
Member

richvdh commented Oct 11, 2017

I'm failing to understand why this isn't a dup of #1491

@WGH-
Copy link
Contributor Author

WGH- commented Oct 11, 2017

Ooops, it indeed is. The comments of that issue mostly discussed SNI, and I failed to read the original post carefully.

@WGH- WGH- closed this as completed Oct 11, 2017
@richvdh
Copy link
Member

richvdh commented Oct 16, 2017

This specific point was discussed in the context of dendrite today; the conclusion was that the current behaviour is actually correct.

Here are our reasons:

  • SRV records are in some way analogous to CNAMEs; in the case of CNAMEs, we base the Host: header on the original host, not the CNAME target.
  • DNS is insecure. Mallory could spoof a DNS response to Alice who's trying to contact Bob telling her to contact Mallory instead. if the SNI was based on the DNS response, Alice would then verify she's talking to Mallory, not Bob, leaving a gaping hole in the protocol.
    • We can draw a parallel with DANE, which has an RFC (7673) which happens to describe how to verify TLS when SRV is insecure and there's no TLSA records (i.e. DANE isn't being used) - which is our situation here. The recommendation is to verify the server_name part (the "source address") and not what the SRV record points to.)
  • from a purely practical perspective, it seems easier to vhost based on the server name than the intermediate dns entry for whichever host the client happened to pick from the SRV records.

@army1349
Copy link

army1349 commented Mar 6, 2019

This decision is kind of security by obscurity. Use DNSSEC instead.

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

No branches or pull requests

3 participants