Closed Bug 2089369 Opened 14 days ago Closed 6 days ago

[wpt-sync] Sync PR 64409 - Prevent net/ from requesting invalid hostnames.

Categories

(Core :: DOM: Core & HTML, task, P4)

task

Tracking

()

RESOLVED FIXED
162 Branch
Tracking Status
firefox162 --- fixed

People

(Reporter: wpt-sync, Unassigned)

References

()

Details

(Whiteboard: [wptsync downstream])

Sync web-platform-tests PR 64409 into mozilla-central (this bug is closed when the sync is complete).

PR: https://github.com/web-platform-tests/wpt/pull/64409
Details from upstream follow.

Matt Menke <mmenke@chromium.org> wrote:

Prevent net/ from requesting invalid hostnames.

The URL spec allows invalid hostnames to appear in URLs. When a webpage
requests such a URL, they're passed to net/. net/ will typically fail
such requests as the DNS layer, but if the requests end up not going
over DNS (e.g., in the case of proxies), we can end up actually trying
to send an over-the-wire request.

HSTS considers, e.g., http://a!b.c.com not to be a child of
http://c.com, but the cookie code does, which is problematic. While
sites should be using secure cookies, and not relying on HSTS to protect
cookies (which has its own lifetimes, max database size, and expiration
times), sites could even then use this to write cookies. So the current
logic is not very safe.

This CL fixes the issue by checking for hostname validity in
URLRequestHttpJob, and failing requests with ERR_INVALID_URL if the host
is not valid. This does mean that some domain names that once may have
worked in niche conditions (like proxies that do weird things) will now
fail, so this change is guarded by an enabled-by-default base::Feature.

It looks to me like the cookie spec says domain matching should fail on
these domains, so we should additionally change that, but rejecting
invalid HTTP URLs, instead of sending them to proxies that might not
know how to deal with URLs with invalid hostnames, is also a good idea,
and is a much simpler fix.

This CL also updates a couple of tests that now have failing navigations
as a result of this change.

Fixed: 579450551
Change-Id: I155448b3522625df7b869e225b260429fcb938a7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8680296
Reviewed-by: Tom Sepez \<tsepez@chromium.org>
Reviewed-by: Adam Rice \<ricea@chromium.org>
Commit-Queue: mmenke \<mmenke@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1731887}

Whiteboard: [wptsync downstream] → [wptsync downstream error]
Component: web-platform-tests → DOM: Core & HTML
Product: Testing → Core
Whiteboard: [wptsync downstream error] → [wptsync downstream]

CI Results

Ran 9 Firefox configurations based on mozilla-central, and Firefox, Chrome, and Safari on GitHub CI

Total 5 tests and 5 subtests

Status Summary

Firefox

OK : 1[GitHub] 5[Gecko-android-em-14-x86_64-debug-geckoview, Gecko-android-em-14-x86_64-lite-opt-geckoview, Gecko-android-em-14-x86_64-opt-geckoview, Gecko-linux2404-64-debug, Gecko-linux2404-64-opt, Gecko-windows11-32-25h2-debug, Gecko-windows11-32-25h2-opt, Gecko-windows11-64-25h2-debug, Gecko-windows11-64-25h2-opt]
PASS: 3[GitHub] 27[Gecko-android-em-14-x86_64-debug-geckoview, Gecko-android-em-14-x86_64-lite-opt-geckoview, Gecko-android-em-14-x86_64-opt-geckoview, Gecko-linux2404-64-debug, Gecko-linux2404-64-opt, Gecko-windows11-32-25h2-debug, Gecko-windows11-32-25h2-opt, Gecko-windows11-64-25h2-debug, Gecko-windows11-64-25h2-opt]

Chrome

OK : 1
PASS: 3

Safari

OK : 1
PASS: 3

Links

Gecko CI (Treeherder)
GitHub PR Head
GitHub PR Base

Status: NEW → RESOLVED
Closed: 6 days ago
Resolution: --- → FIXED
Target Milestone: --- → 162 Branch
You need to log in before you can comment on or make changes to this bug.