Open Bug 2099493 Opened 2 days ago Updated 4 hours ago

TRR keeps starting new HTTP/3 attempts to the DoH server when UDP 443 is blocked (Http3First path has no HTTP/3 failure memory)

Categories

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

Firefox 161
defect

Tracking

()

Tracking Status
firefox-esr153 --- disabled
firefox161 --- wontfix
firefox162 --- wontfix
firefox163 --- affected

People

(Reporter: kunala, Unassigned)

References

(Blocks 1 open bug, Regression)

Details

(Keywords: regression, Whiteboard: [necko-triaged])

Summary

When outbound UDP 443 is blocked or reset, Firefox marks HTTP/3 as broken for ordinary origins after a failed attempt or two and stays on TCP. For the DoH server it does not: TRR starts a new QUIC connection attempt on nearly every lookup, indefinitely, for as long as the session lasts.

Blocking QUIC so that browsers fall back to HTTP/2 is common on enterprise networks and with endpoint web-filtering software, so this should affect any user with default DoH (Cloudflare) in those environments.

This looks like a side effect of bug 2013475 (per-server HTTP/3-first configuration for TRR, Firefox 149).

Steps to reproduce

Note: these steps are derived from field logs and from reading the source. I have not yet run them on a clean profile.

  1. Firefox 161 release, new profile, DoH enabled with the default provider (mozilla.cloudflare-dns.com). Leave network.trr.allow_default_http3_first at its default (true).
  2. Block or reset outbound UDP 443 (firewall rule, or a local network filter that aborts the flow).
  3. Browse normally for a few minutes.
  4. Watch UDP 443 connection attempts to the DoH server addresses, or capture a log with MOZ_LOG=nsHttp:5,nsHostResolver:5.

Expected

After the first failed QUIC handshake to the DoH server, TRR uses HTTP/2 until a network change or restart, the same as for ordinary origins.

Actual

A new QUIC attempt to the DoH server accompanies almost every DoH lookup.

Field data from one affected macOS machine (Firefox 161.0) over one working day, with a transparent proxy (NETransparentProxyProvider) that accepts every UDP 443 flow and immediately closes it with an error:

  • about 2,200 QUIC attempts to the four addresses of mozilla.cloudflare-dns.com (two IPv4, two IPv6), roughly 550 per address
  • the attempts track page loads: 58% fall within 1s of a new page connection, against 6% at random times
  • over the same period, QUIC to 162 other addresses saw a median of 2 attempts each, so the normal exclusion is working
  • DoH itself kept working over TCP throughout

Cause (from reading the source)

All references are to FIREFOX_161_0_RELEASE.

  1. TRRServiceChannel.cpp:419-424 calls GetAltServiceMapping with aForceHttp3First set when network.trr.force_http3_first || (network.trr.allow_default_http3_first && GetHttp3FirstForServer(host)). TRRServiceBase::CreateConnInfoHelper (TRRServiceBase.cpp:226-231) does the same.
  2. network.trr.allow_default_http3_first defaults to true, and the doh-providers remote settings collection currently sets http3First: true for mozilla.cloudflare-dns.com (DoHConfig.sys.mjs:404-416 applies it via setHttp3FirstForServer).
  3. In AltSvcCache::GetAltServiceMapping (AlternateServices.cpp:951-957), the aForceHttp3First branch returns a newly constructed Http3FirstAltSvcMapping straight away. It never reaches LookupMapping.
  4. LookupMapping (AlternateServices.cpp:771-781) is where a cached HTTP/3 mapping is dropped if gHttpHandler->IsHttp3Excluded() is true. The Http3First branch has no equivalent check.
  5. A failed handshake does add the host to mExcludedHttp3Origins (for example Http3Session::Shutdown, Http3Session.cpp:369-377, calling gHttpHandler->ExcludeHttp3()). The only readers of that list are Alt-Svc header processing (AlternateServices.cpp:190), LookupMapping (AlternateServices.cpp:774), HTTPS RR selection (HTTPSSVC.cpp:338) and the HTTPS RR retry path in nsHttpTransaction.cpp:1317. None of them is consulted when the Http3First mapping is built, and nsHttpTransaction::DisableHttp3() only changes the one transaction.

So every new TRR channel is handed an HTTP/3 connection info again, which matches the one-QUIC-attempt-per-lookup pattern in the field data.

Suggested fix

In the aForceHttp3First branch of AltSvcCache::GetAltServiceMapping, skip the forced mapping when gHttpHandler->IsHttp3Excluded(host) is true and fall through to the normal lookup.

Two related observations, from reading the source only:

  • nsHttpHandler::ExcludeHttp2OrHttp3Internal (nsHttpHandler.cpp:2796-2799) returns early when the connection info has Happy Eyeballs enabled, and Http3FirstAltSvcMapping::GetConnectionInfo enables it when network.http.happy_eyeballs_enabled is set. On that configuration the host would not be added to the exclusion list at all, so the check above may not be enough there. I do not know whether the affected machine had Happy Eyeballs enabled.
  • The same branch also skips the nsHttpHandler::IsHttp3Enabled() check that LookupMapping makes (AlternateServices.cpp:772). I have not verified whether network.http.http3.enable = false stops the DoH QUIC attempts.

Possibly related

Bug 2098400 (macOS: closing blocked UDP 443 sockets stalls the Socket Thread for about a second each when a content filter is attached). It is a different trigger (Alt-Svc validation with Happy Eyeballs, DoH disabled), but if the same slow close applies here, a QUIC attempt per DoH lookup would multiply it. The affected machine did show whole-second stalls on Firefox TCP connections that no other application had; I have not confirmed they have the same cause.

Workaround

Set network.trr.allow_default_http3_first to false.

Reporter here, with a correction to comment 0 after re-checking it against the source and the live rollout configuration.

Happy Eyeballs is probably on, which changes the cause and the fix

Comment 0 was written as if Happy Eyeballs v3 were off on release and only mentioned it as a side observation. The pref default is Nightly-only in 161, but the Nimbus rollout happy-eyeballs-release-rollout appears to enable network.http.happy_eyeballs_enabled for release 157 and later at 100% since late September. So an ordinary 161 release profile most likely has it on. I still do not know the value on the affected machine (it may have studies/rollouts disabled by policy); I have asked for it.

If Happy Eyeballs is on, these parts of comment 0 are wrong:

  1. Cause, point 5. The failed handshake does not add the DoH host to mExcludedHttp3Origins. nsHttpHandler::ExcludeHttp2OrHttp3Internal returns early when ci->GetHappyEyeballsEnabled() (nsHttpHandler.cpp:2796-2799), and TRRServiceChannel sets that on the connection info (TRRServiceChannel.cpp:479-494).
  2. Suggested fix. Checking gHttpHandler->IsHttp3Excluded(host) in the aForceHttp3First branch would do nothing, because there is never an entry to find. The fix needs some record of the HTTP/3 failure that also works with Happy Eyeballs. The patch direction in bug 2098400 (exclude HTTP/3 after a failed validation) looks closer to what is needed, if it also covers the Http3First mapping.
  3. Actual / fallback timing. The 100 ms network.http.http3.backup_timer_delay fallback does not apply. nsHttpTransaction::MaybeStartHttp3BackupTimer skips the timer when NS_HTTP_USE_HAPPY_EYEBALLS is set (nsHttpTransaction.cpp:480-495), and the Happy Eyeballs attempt races h3 whenever nsHttpHandler::IsHttp3Enabled() && !(mCaps & NS_HTTP_DISALLOW_HTTP3) (HappyEyeballsConnectionAttempt.cpp:217-222). I found no reference to the exclusion list anywhere in the HappyEyeballs* sources.
  4. Second observation under "Suggested fix". On the Happy Eyeballs path network.http.http3.enable = false should stop the QUIC attempts, since that is the IsHttp3Enabled() check above. Not tested.

If Happy Eyeballs is off on that machine, comment 0 stands as written.

What is unchanged either way

The aForceHttp3First branch of AltSvcCache::GetAltServiceMapping (AlternateServices.cpp:951-957) hands every new TRR channel a fresh Http3FirstAltSvcMapping with no check of any earlier HTTP/3 failure, and network.trr.allow_default_http3_first = false is still the workaround.

The original title overstated the data

"On every lookup" was an inference. What the field data shows is about 2,200 QUIC attempts in a day across the four DoH addresses, in about 260 bursts (typically 4 attempts within 3 s), closely tracking page loads and never stopping, while ordinary origins stopped after a median of 2 attempts. It does not show one attempt per individual lookup. I have retitled the bug to match.

Still open

  • Not reproduced on a clean profile yet; everything above is from field logs plus reading FIREFOX_161_0_RELEASE.
  • That bug 2013475 introduced this is inferred from the code, not bisected.
  • With Happy Eyeballs likely on, the setup is closer to bug 2098400 than comment 0 suggested (macOS, UDP 443 killed by a network extension, whole-second stalls only in Firefox). One difference: here the UDP flow is closed with an error straight away rather than silently dropped, and I have not confirmed whether a content filter is also attached on that machine.
Summary: TRR retries HTTP/3 to the DoH server on every lookup when UDP 443 is blocked (Http3First path bypasses the HTTP/3 exclusion list) → TRR keeps starting new HTTP/3 attempts to the DoH server when UDP 443 is blocked (Http3First path has no HTTP/3 failure memory)

Thanks for the detailed analysis. One correction on attribution: the aForceHttp3First branch in AltSvcCache::GetAltServiceMapping that skips the IsHttp3Excluded check came from bug 2001117 (Firefox 149), and release users were only exposed once bug 2077283 enabled network.trr.allow_default_http3_first on all channels in Firefox 159. Before that the pref was Nightly-only, so ESR 153 is unaffected by default.

Kershaw, could you take a look? As comment 0 notes, with Happy Eyeballs enabled ExcludeHttp2OrHttp3Internal returns early, so adding an IsHttp3Excluded check to the Http3First branch alone may not be enough. This also looks closely related to bug 2098400.

Flags: needinfo?(kershaw)

Thanks, Ryan. Agreed on the attribution: the pref change in bug 2077283 is what exposed release, and it fits the field data (the affected machine is on 161).

I will ask the person who was impacted for the value of network.http.happy_eyeballs_enabled on that machine and post it here.

The bug has a release status flag that shows some version of Firefox is affected, thus it will be considered confirmed.

Status: UNCONFIRMED → NEW
Ever confirmed: true

Hi, My understanding is that the background HTTP/3 connection attempt shouldn’t have any user-visible impact. Is that right? If so, I’d lower this bug’s priority to P3.

Severity: -- → S4
Flags: needinfo?(kershaw)
Priority: -- → P3
Whiteboard: [necko-triaged]

The issues that it significantly increases page load time because every single time there’s a new DNS request, it’s gonna be waiting, if HTTP3 is being blocked by the firewall. I would rank it as a slightly higher priority because of that, will end up impacting silently all users that are using Firefox with this flag & their corporate firewalls blocking HTTP 3

:leggert, since you are the author of the regressor, bug 2077283, could you take a look?

For more information, please visit BugBot documentation.

Flags: needinfo?(leggert)

I'm not sure bug 2077283 is the regressor here, that change just let the pref flip ride the trains. Also, this only is an issue when H3 is blocked, correct? If an enterprise blocks H3 and deploys Firefox I'd expect them to flip the corresponding prefs, too.

Also, DoH is only the default in US, CA, UA, RU.

Flags: needinfo?(leggert)
Regressed by: 2001117

It’s difficult for most enterprises guarantee they would make the preference change so it would be much more preferable to fix the underlying issue

You need to log in before you can comment on or make changes to this bug.