Closed Bug 1691658 Opened 5 years ago Closed 2 years ago

Block redirects to data: URLs

Categories

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

defect

Tracking

()

RESOLVED FIXED
114 Branch
Tracking Status
firefox114 --- fixed

People

(Reporter: annevk, Assigned: Gijs)

References

(Blocks 2 open bugs)

Details

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

Attachments

(1 file)

Severity: -- → S4
Priority: -- → P2
Whiteboard: [necko-triaged]
Blocks: fetch
Priority: P2 → P3
Priority: P3 → P2
See Also: → CVE-2023-34415

We should return an error here if we are redirecting to a data URI and nsILoadInfo.allowInsecureRedirectToDataURI is false.
Optionally we could also add a separate pref for it, in case there's major breakage.
Tests: https://wpt.fyi/results/fetch/redirects/data.window.html?label=experimental&label=master&aligned
https://searchfox.org/mozilla-central/rev/42747dfd314e4c939dc7c33a13e1a2fddf4926fc/testing/web-platform/meta/fetch/redirects/data.window.js.ini

Whiteboard: [necko-triaged] → [necko-triaged][necko-priority-queue]
Assignee: nobody → smayya

Turned out I had a patch for this that I thought didn't work but actually did? So stealing this per conversation on slack... sorry!

Assignee: smayya → gijskruitbosch+bugs

This also adds a network.allow_redirect_to_data pref in case we need to turn
this back on for compat reasons.

Will this break extensions that use data uri redirects to replace response bodies? (there's some more context in bug 1712096)

It checks nsILoadInfo.allowInsecureRedirectToDataURI - so presumably those should not be affected.

Attachment #9325780 - Attachment description: Bug 1691658 - block http redirects to data: protocol, r?sunil → Bug 1691658 - block http redirects to data: protocol, r?sunil,ckerschb!

(In reply to Gregory Pappas [:gregp] from comment #4)

Will this break extensions that use data uri redirects to replace response bodies? (there's some more context in bug 1712096)

The following comment from within WebRequest.jsm says it should not affect web extensions:

// Web Extensions using the WebRequest API are allowed
// to redirect a channel to a data: URI, hence we mark
// the channel to let the redirect blocker know. Please
// note that this marking needs to happen after the
// channel.redirectTo is called because the channel's
// RedirectTo() implementation explicitly drops the flag
// to avoid additional redirects not caused by the
// Web Extension.

Pushed by gijskruitbosch@gmail.com: https://hg.mozilla.org/integration/autoland/rev/736be753a5cf block http redirects to data: protocol, r=necko-reviewers,ckerschb,valentin

(In reply to Cristina Horotan [:chorotan] from comment #8)

test_ext_webidl_api_event_callback.js and test_ext_webidl_api.js

These don't show up on try, so seem more likely to be related to a different push, e.g. bug 1822763

Flags: needinfo?(gijskruitbosch+bugs)
Pushed by gijskruitbosch@gmail.com: https://hg.mozilla.org/integration/autoland/rev/8bab888ea4d4 block http redirects to data: protocol, r=necko-reviewers,ckerschb,valentin
Regressions: 1826455
Regressions: 1826456

Backed out for causing xpcshell failures in test_redirect_different-protocol_wrap.js.

Flags: needinfo?(gijskruitbosch+bugs)

Maybe set the pref here and here instead of in the test?

(In reply to Valentin Gosu [:valentin] (he/him) from comment #12)

Maybe set the pref here and here instead of in the test?

That seems reasonable, yes, and I'll update the patch for that.

Really though, what I would like to know is why the android xpcshell nofis jobs were green on try, and was green on autoland for a little while before then being orange. Like, I am fine fixing the patch but it's not great for sheriffs or for me if I'm playing "how about now" with autoland, given that try apparently doesn't reliably answer "does this pass tests". Do the android xpcshell tests not always run the same tests? Because that feels like a footgun.

FWIW, using test filtering for netwerk/test/unit_ipc/ removes most xpcshell jobs on this autoland filtered result set, and all of the ones on my trypush. But all the android xpcshell jobs that treeherder's chooser offered me were run on that trypush. So where/when do the other tests get run?

Flags: needinfo?(gijskruitbosch+bugs) → needinfo?(aryx.bugmail)
No longer regressions: 1826456
No longer regressions: 1826455

autoland only aims to run all test manifest every 10th or 20th push and that might not apply if that push is a backout or has DONTBUILD in the commit message to prevent more than a skeleton task set from running. All other pushes get less tasks and/or less test manifests in the tasks. netwerk/test/unit_ipc/. Identic task symbols on Treeherder do not represent identic test manifests in the task.

On Try, the push had been scheduled with ./mach try auto which queries the bugbug server for the tasks and tests to schedule: "test_manifest_loader": "bugbug". This did not schedule the mentioned folder. Marco knows how this works (he is out for this week).

Flags: needinfo?(aryx.bugmail)
Pushed by gijskruitbosch@gmail.com: https://hg.mozilla.org/integration/autoland/rev/ad22661fac08 block http redirects to data: protocol, r=necko-reviewers,ckerschb,valentin

Backed out for causing wpt failures on browser_datauri.js.

[task 2023-04-11T13:54:42.506Z] 13:54:42     INFO - TEST-START | toolkit/mozapps/extensions/test/xpinstall/browser_datauri.js
[task 2023-04-11T13:54:42.565Z] 13:54:42     INFO - GECKO(22659) | [Child 23467: Main Thread]: I/DocShellAndDOMWindowLeak ++DOCSHELL 7f448e332c00 == 1 [pid = 23467] [id = 0]
[task 2023-04-11T13:54:42.565Z] 13:54:42     INFO - GECKO(22659) | [Child 23467: Main Thread]: I/DocShellAndDOMWindowLeak ++DOMWINDOW == 1 (7f44934c0470) [pid = 23467] [serial = 1] [outer = 0]
[task 2023-04-11T13:54:42.568Z] 13:54:42     INFO - GECKO(22659) | [Child 23467: Main Thread]: I/DocShellAndDOMWindowLeak ++DOMWINDOW == 2 (7f448e333400) [pid = 23467] [serial = 2] [outer = 7f44934c0470]
[task 2023-04-11T13:54:42.749Z] 13:54:42     INFO - GECKO(22659) | [Child 22818: Main Thread]: I/DocShellAndDOMWindowLeak --DOMWINDOW == 7 (7f1972a3a800) [pid = 22818] [serial = 28] [outer = 0] [url = about:blank]
[task 2023-04-11T13:54:42.750Z] 13:54:42     INFO - GECKO(22659) | [Child 22818: Main Thread]: I/DocShellAndDOMWindowLeak --DOMWINDOW == 6 (7f1972a37800) [pid = 22818] [serial = 26] [outer = 0] [url = about:blank]
[task 2023-04-11T13:54:42.751Z] 13:54:42     INFO - GECKO(22659) | [Child 22818: Main Thread]: I/DocShellAndDOMWindowLeak --DOCSHELL 7f1972a37000 == 2 [pid = 22818] [id = 14] [url = about:blank]
[task 2023-04-11T13:54:42.751Z] 13:54:42     INFO - GECKO(22659) | [Child 22818: Main Thread]: I/DocShellAndDOMWindowLeak --DOCSHELL 7f1972a39800 == 1 [pid = 22818] [id = 15] [url = about:blank]
[task 2023-04-11T13:54:42.835Z] 13:54:42     INFO - GECKO(22659) | [Child 22818: Main Thread]: I/DocShellAndDOMWindowLeak --DOMWINDOW == 5 (7f1977b59a40) [pid = 22818] [serial = 31] [outer = 0] [url = about:blank]
[task 2023-04-11T13:54:42.836Z] 13:54:42     INFO - GECKO(22659) | [Child 22818: Main Thread]: I/DocShellAndDOMWindowLeak --DOMWINDOW == 4 (7f1977b59470) [pid = 22818] [serial = 29] [outer = 0] [url = about:blank]
[task 2023-04-11T13:54:42.893Z] 13:54:42     INFO - GECKO(22659) | [Child 23467: Main Thread]: I/DocShellAndDOMWindowLeak ++DOMWINDOW == 3 (7f448e335000) [pid = 23467] [serial = 3] [outer = 7f44934c0470]
[task 2023-04-11T13:54:42.923Z] 13:54:42     INFO - GECKO(22659) | [Child 22749: Main Thread]: I/DocShellAndDOMWindowLeak --DOMWINDOW == 7 (7f6b0da20c00) [pid = 22749] [serial = 33] [outer = 0] [url = about:blank]
[task 2023-04-11T13:54:42.927Z] 13:54:42     INFO - GECKO(22659) | [Child 22749: Main Thread]: I/DocShellAndDOMWindowLeak --DOMWINDOW == 6 (7f6b0da1fc00) [pid = 22749] [serial = 35] [outer = 0] [url = about:blank]
[task 2023-04-11T13:54:42.929Z] 13:54:42     INFO - GECKO(22659) | [Child 22749: Main Thread]: I/DocShellAndDOMWindowLeak --DOCSHELL 7f6b0da21c00 == 2 [pid = 22749] [id = 16] [url = about:blank]
[task 2023-04-11T13:54:42.931Z] 13:54:42     INFO - GECKO(22659) | [Child 22749: Main Thread]: I/DocShellAndDOMWindowLeak --DOCSHELL 7f6b0da20800 == 1 [pid = 22749] [id = 18] [url = about:blank]
[task 2023-04-11T13:54:42.933Z] 13:54:42     INFO - GECKO(22659) | [Child 22749: Main Thread]: I/DocShellAndDOMWindowLeak --DOCSHELL 7f6b0da1dc00 == 0 [pid = 22749] [id = 17] [url = about:blank]
[task 2023-04-11T13:54:42.999Z] 13:54:42     INFO - GECKO(22659) | [Child 23467, Main Thread] WARNING: NS_ENSURE_SUCCESS(rv, NS_ERROR_INVALID_ARG) failed with result 0x80520012 (NS_ERROR_FILE_NOT_FOUND): file /builds/worker/checkouts/gecko/intl/l10n/L10nRegistry.cpp:385
[task 2023-04-11T13:54:43.003Z] 13:54:43     INFO - GECKO(22659) | [Child 23467, Main Thread] WARNING: NS_ENSURE_SUCCESS(rv, NS_ERROR_INVALID_ARG) failed with result 0x80520012 (NS_ERROR_FILE_NOT_FOUND): file /builds/worker/checkouts/gecko/intl/l10n/L10nRegistry.cpp:385
[task 2023-04-11T13:54:43.124Z] 13:54:43     INFO - GECKO(22659) | [Child 22749: Main Thread]: I/DocShellAndDOMWindowLeak --DOMWINDOW == 5 (7f6b12c69e20) [pid = 22749] [serial = 36] [outer = 0] [url = about:blank]
[task 2023-04-11T13:54:43.127Z] 13:54:43     INFO - GECKO(22659) | [Child 22749: Main Thread]: I/DocShellAndDOMWindowLeak --DOMWINDOW == 4 (7f6b12c69090) [pid = 22749] [serial = 38] [outer = 0] [url = about:blank]
[task 2023-04-11T13:54:43.128Z] 13:54:43     INFO - GECKO(22659) | [Child 22749: Main Thread]: I/DocShellAndDOMWindowLeak --DOMWINDOW == 3 (7f6b12c69a40) [pid = 22749] [serial = 40] [outer = 0] [url = about:blank]
[task 2023-04-11T13:54:43.148Z] 13:54:43     INFO - GECKO(22659) | [Child 23467, Main Thread] WARNING: '!tsi', file /builds/worker/checkouts/gecko/dom/base/Document.cpp:1656
[task 2023-04-11T13:54:43.617Z] 13:54:43     INFO - GECKO(22659) | ### XPCOM_MEM_BLOAT_LOG defined -- logging bloat/leaks to /tmp/tmpsk5zx8p_.mozrunner/runtests_leaks_tab_pid23543.log
[task 2023-04-11T13:54:43.621Z] 13:54:43     INFO - GECKO(22659) | [23543, Main Thread] WARNING: XPCOM_MEM_BLOAT_LOG is set, disabling native allocations.: file /builds/worker/checkouts/gecko/tools/profiler/core/platform.cpp:345
[task 2023-04-11T13:54:43.629Z] 13:54:43     INFO - GECKO(22659) | [Child 23543, Main Thread] WARNING: NS_ENSURE_SUCCESS(rv, rv) failed with result 0x80004005 (NS_ERROR_FAILURE): file /builds/worker/checkouts/gecko/toolkit/xre/nsXREDirProvider.cpp:475
[task 2023-04-11T13:54:43.639Z] 13:54:43     INFO - GECKO(22659) | [Parent 22659: Main Thread]: I/DocShellAndDOMWindowLeak --DOMWINDOW == 18 (7f053e491800) [pid = 22659] [serial = 30] [outer = 0] [url = about:blank]
[task 2023-04-11T13:54:43.643Z] 13:54:43     INFO - GECKO(22659) | [Parent 22659: Main Thread]: I/DocShellAndDOMWindowLeak --DOMWINDOW == 17 (7f053164d400) [pid = 22659] [serial = 35] [outer = 0] [url = about:blank]
[task 2023-04-11T13:54:43.645Z] 13:54:43     INFO - GECKO(22659) | [Parent 22659: Main Thread]: I/DocShellAndDOMWindowLeak --DOMWINDOW == 16 (7f0531646000) [pid = 22659] [serial = 40] [outer = 0] [url = chrome://global/content/commonDialog.xhtml]
[task 2023-04-11T13:54:43.647Z] 13:54:43     INFO - GECKO(22659) | [Parent 22659: Main Thread]: I/DocShellAndDOMWindowLeak --DOMWINDOW == 15 (7f0538deb000) [pid = 22659] [serial = 37] [outer = 0] [url = about:blank]
[task 2023-04-11T13:54:43.649Z] 13:54:43     INFO - GECKO(22659) | [Parent 22659: Main Thread]: I/DocShellAndDOMWindowLeak --DOMWINDOW == 14 (7f053164b800) [pid = 22659] [serial = 19] [outer = 0] [url = chrome://global/content/commonDialog.xhtml]
[task 2023-04-11T13:54:43.658Z] 13:54:43     INFO - GECKO(22659) | [Parent 22659: Main Thread]: I/DocShellAndDOMWindowLeak --DOMWINDOW == 13 (7f053164ec00) [pid = 22659] [serial = 33] [outer = 0] [url = chrome://global/content/commonDialog.xhtml]
[task 2023-04-11T13:54:43.658Z] 13:54:43     INFO - GECKO(22659) | [Child 23543, Main Thread] WARNING: could not set real-time limit in CubebUtils::InitLibrary: file /builds/worker/checkouts/gecko/dom/media/CubebUtils.cpp:655
[task 2023-04-11T13:54:43.670Z] 13:54:43     INFO - GECKO(22659) | [Child 23543, Main Thread] WARNING: NS_ENSURE_SUCCESS(rv, rv) failed with result 0x80004005 (NS_ERROR_FAILURE): file /builds/worker/checkouts/gecko/toolkit/xre/nsXREDirProvider.cpp:475
[task 2023-04-11T13:54:43.671Z] 13:54:43     INFO - GECKO(22659) | [Child 23543, Main Thread] WARNING: NS_ENSURE_SUCCESS(rv, rv) failed with result 0x80004005 (NS_ERROR_FAILURE): file /builds/worker/checkouts/gecko/toolkit/xre/nsXREDirProvider.cpp:475
[task 2023-04-11T13:54:43.675Z] 13:54:43     INFO - GECKO(22659) | [Parent 22659: Main Thread]: I/DocShellAndDOMWindowLeak --DOMWINDOW == 12 (7f053e499400) [pid = 22659] [serial = 32] [outer = 0] [url = about:blank]
[task 2023-04-11T13:54:43.676Z] 13:54:43     INFO - GECKO(22659) | [Parent 22659: Main Thread]: I/DocShellAndDOMWindowLeak --DOMWINDOW == 11 (7f053a34d800) [pid = 22659] [serial = 26] [outer = 0] [url = chrome://global/content/commonDialog.xhtml]
[task 2023-04-11T13:54:43.696Z] 13:54:43     INFO - GECKO(22659) | [Parent 22659: Main Thread]: I/DocShellAndDOMWindowLeak --DOMWINDOW == 10 (7f0538dea800) [pid = 22659] [serial = 39] [outer = 0] [url = about:blank]
[task 2023-04-11T13:54:43.707Z] 13:54:43     INFO - GECKO(22659) | [Child 23543, Main Thread] WARNING: NS_ENSURE_SUCCESS(rv, rv) failed with result 0x80004005 (NS_ERROR_FAILURE): file /builds/worker/checkouts/gecko/toolkit/xre/nsXREDirProvider.cpp:475
[task 2023-04-11T13:54:46.837Z] 13:54:46     INFO - GECKO(22659) | [Child 22818: Main Thread]: I/DocShellAndDOMWindowLeak --DOMWINDOW == 3 (7f1972a39c00) [pid = 22818] [serial = 32] [outer = 0] [url = about:blank]
[task 2023-04-11T13:54:46.838Z] 13:54:46     INFO - GECKO(22659) | [Child 22818: Main Thread]: I/DocShellAndDOMWindowLeak --DOMWINDOW == 2 (7f1972a38800) [pid = 22818] [serial = 30] [outer = 0] [url = about:blank]
[task 2023-04-11T13:54:47.001Z] 13:54:47     INFO - GECKO(22659) | [Child 22749: Main Thread]: I/DocShellAndDOMWindowLeak --DOMWINDOW == 2 (7f6b0da22000) [pid = 22749] [serial = 37] [outer = 0] [url = about:blank]
[task 2023-04-11T13:54:47.002Z] 13:54:47     INFO - GECKO(22659) | [Child 22749: Main Thread]: I/DocShellAndDOMWindowLeak --DOMWINDOW == 1 (7f6b0da21000) [pid = 22749] [serial = 41] [outer = 0] [url = about:blank]
[task 2023-04-11T13:54:47.003Z] 13:54:47     INFO - GECKO(22659) | [Child 22749: Main Thread]: I/DocShellAndDOMWindowLeak --DOMWINDOW == 0 (7f6b0da1e000) [pid = 22749] [serial = 39] [outer = 0] [url = about:blank]
[task 2023-04-11T13:54:56.977Z] 13:54:56     INFO - GECKO(22659) | [Child 23467: Main Thread]: I/DocShellAndDOMWindowLeak --DOMWINDOW == 2 (7f448e333400) [pid = 23467] [serial = 2] [outer = 0] [url = about:blank]
[task 2023-04-11T13:55:02.576Z] 13:55:02     INFO - GECKO(22659) | ALSA lib seq_hw.c:466:(snd_seq_hw_open) open /dev/snd/seq failed: No such file or directory
[task 2023-04-11T13:56:12.518Z] 13:56:12     INFO - TEST-INFO | started process screentopng
[task 2023-04-11T13:56:12.768Z] 13:56:12     INFO - TEST-INFO | screentopng: exit 0
[task 2023-04-11T13:56:12.768Z] 13:56:12     INFO - Buffered messages logged at 13:54:42
[task 2023-04-11T13:56:12.768Z] 13:56:12     INFO - Console message: [JavaScript Warning: "Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user’s experience. For more help http://xhr.spec.whatwg.org/" {file: "chrome://mochitests/content/browser/toolkit/mozapps/extensions/test/xpinstall/browser_datauri.js" line: 23}]
[task 2023-04-11T13:56:12.768Z] 13:56:12     INFO - Console message: [JavaScript Warning: "Redirecting to data: URI not allowed (Blocked loading of: “data:text/html,<script>window.location.href='http:...”)"]
[task 2023-04-11T13:56:12.768Z] 13:56:12     INFO - Buffered messages finished
[task 2023-04-11T13:56:12.768Z] 13:56:12     INFO - TEST-UNEXPECTED-FAIL | toolkit/mozapps/extensions/test/xpinstall/browser_datauri.js | Test timed out - 
[task 2023-04-11T13:56:12.772Z] 13:56:12     INFO - TEST-PASS | toolkit/mozapps/extensions/test/xpinstall/browser_datauri.js | Should be no active installs at the end of the test - 
[task 2023-04-11T13:56:12.772Z] 13:56:12     INFO - GECKO(22659) | MEMORY STAT | vsize 3171MB | residentFast 513MB | heapAllocated 240MB
[task 2023-04-11T13:56:12.772Z] 13:56:12     INFO - TEST-OK | toolkit/mozapps/extensions/test/xpinstall/browser_datauri.js | took 90040ms
[task 2023-04-11T13:56:12.772Z] 13:56:12     INFO - Not taking screenshot here: see the one that was previously logged
[task 2023-04-11T13:56:12.773Z] 13:56:12     INFO - TEST-UNEXPECTED-FAIL | toolkit/mozapps/extensions/test/xpinstall/browser_datauri.js | Found a tab after previous test timed out: http://example.com/browser/toolkit/mozapps/extensions/test/xpinstall/redirect.sjs?mode=redirect - 
[task 2023-04-11T13:56:12.773Z] 13:56:12     INFO - GECKO(22659) | [Child 22749: Main Thread]: I/DocShellAndDOMWindowLeak ++DOCSHELL 7f6b0da1dc00 == 1 [pid = 22749] [id = 19]
[task 2023-04-11T13:56:12.773Z] 13:56:12     INFO - GECKO(22659) | [Child 22749: Main Thread]: I/DocShellAndDOMWindowLeak ++DOMWINDOW == 1 (7f6b12c69090) [pid = 22749] [serial = 42] [outer = 0]
[task 2023-04-11T13:56:12.773Z] 13:56:12     INFO - GECKO(22659) | [Child 22749: Main Thread]: I/DocShellAndDOMWindowLeak ++DOMWINDOW == 2 (7f6b0da1e000) [pid = 22749] [serial = 43] [outer = 7f6b12c69090]
[task 2023-04-11T13:56:12.773Z] 13:56:12     INFO - checking window state
[task 2023-04-11T13:56:12.885Z] 13:56:12     INFO - TEST-START | toolkit/mozapps/extensions/test/xpinstall/browser_doorhanger_installs.js
Flags: needinfo?(gijskruitbosch+bugs)

Well, try is green, so here goes nothing...

Flags: needinfo?(gijskruitbosch+bugs)
Pushed by gijskruitbosch@gmail.com: https://hg.mozilla.org/integration/autoland/rev/4261c8e32fbe block http redirects to data: protocol, r=necko-reviewers,ckerschb,valentin
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 114 Branch
Blocks: 1730202
Duplicate of this bug: 786275
No longer duplicate of this bug: 786275
See Also: → 1670672
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: