Closed Bug 1886757 Opened 2 years ago Closed 2 years ago

network.dns.localdomains does not apply to FQDN

Categories

(Core :: Networking: DNS, defect, P2)

defect

Tracking

()

RESOLVED FIXED
127 Branch
Tracking Status
firefox127 --- fixed

People

(Reporter: valentin, Assigned: twisniewski)

Details

(Whiteboard: [necko-triaged][necko-priority-next])

Attachments

(1 file)

Thomas pointed out that while https://wpt.live/fetch/metadata/trailing-dot.https.sub.any.html seems to pass in the browser, https://wpt.fyi/results/fetch/metadata/trailing-dot.https.sub.any.html?label=experimental&label=master&aligned still shows some failures.

according to james: "So we're using network.dns.localdomains to bypass the DNS. If that test is doing something not supported by that codepath then that would explain what you're seeing. The simple test here would be to just add all the domains twice, once with a trailing dot. Or have necko preprocess the domain before we call https://searchfox.org/mozilla-central/source/netwerk/dns/nsDNSService2.cpp#999 (which I think is where we end up trying to decide if we should treat the domain as local)"

I think we should update this check:

https://searchfox.org/mozilla-central/rev/f63ca2952da98e0817bdae0ddf1314281a497106/netwerk/dns/nsDNSService2.cpp#999

localDomain = mLocalDomains.Contains(aHostname);

to be something like

localDomain = mLocalDomains.Contains(StringEndsWith(aHostname, "."_ns) ? Substring(aHostname, ...) : aHostname);

That way both example.com and example.com. would be covered by the pref.

Assignee: nobody → twisniewski
Status: NEW → ASSIGNED
Pushed by twisniewski@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/54c0b2c00687 Ignore a trailing dot in a hostname for the network.dns.localdomains pref; r=valentin,necko-reviewers

Backed out for causing xpcshell failures in test_pinning.js.

Flags: needinfo?(twisniewski)

Valentin, these are the tests which are hanging:

  // Check that using a FQDN doesn't bypass pinning.
  add_connection_test(
    "bad.include-subdomains.pinning.example.com.",
    MOZILLA_PKIX_ERROR_KEY_PINNING_FAILURE
  );
  // For some reason this is also navigable (see bug 1118522).
  add_connection_test(
    "bad.include-subdomains.pinning.example.com..",
    MOZILLA_PKIX_ERROR_KEY_PINNING_FAILURE
  );

I'm not at all sure how to deal with this. Did you have any tips?

Flags: needinfo?(twisniewski) → needinfo?(valentin.gosu)

I think it's because the test adds bad.include-subdomains.pinning.example.com. and bad.include-subdomains.pinning.example.com.. to the list, but when we check we remove the dot from the string we're checking.
If I change the code to be:

localDomain = mLocalDomains.Contains(aHostname);
    if (StringEndsWith(aHostname, "."_ns)) {
      localDomain = localDomain || mLocalDomains.Contains(
                            Substring(aHostname, 0, aHostname.Length() - 1));
    }

the test passes.

Also we check mLocalDomains in multiple places - I think it would be good to put this in a helper function instead, and call it where necessary.

Flags: needinfo?(valentin.gosu)
Pushed by twisniewski@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/01a84ae4d869 Ignore a trailing dot in a hostname for the network.dns.localdomains pref; r=valentin,necko-reviewers
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 127 Branch
Component: Networking → Networking: DNS
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: