Closed Bug 2018004 Opened 9 months ago Closed 9 months ago

Assertion failure: !partitionedPrincipalOriginAttributes.mPartitionKey.IsEmpty(), at /builds/worker/checkouts/gecko/netwerk/cookie/CookieService.cpp:621

Categories

(Core :: Networking: Cookies, defect)

defect

Tracking

()

VERIFIED FIXED
150 Branch
Tracking Status
firefox-esr140 --- unaffected
firefox148 --- unaffected
firefox149 --- verified
firefox150 --- verified

People

(Reporter: tsmith, Assigned: timhuang)

References

(Blocks 1 open bug, )

Details

(Keywords: assertion, pernosco)

Attachments

(6 external files)

Found with m-c 20260219-f9082c931991 (--enable-debug)

This was found by visiting a live website with a debug build. A Pernosco session is available here: https://pernos.co/debug/vDAR1OUhFAdng5jhZK6aEg/index.html

STR:

  • Launch browser and visit site

This issue was triggered by visiting http://mail.ru/.

Assertion failure: !partitionedPrincipalOriginAttributes.mPartitionKey.IsEmpty(), at /builds/worker/checkouts/gecko/netwerk/cookie/CookieService.cpp:621

0|0|libxul.so|mozilla::net::CookieService::SetCookieStringFromHttp(nsIURI*, nsTSubstring<char> const&, nsIChannel*)|git:github.com/mozilla-firefox/firefox:netwerk/cookie/CookieService.cpp:0fce12de99c5e7d74536d8f93cf9778ce6199a1f|620|0x12c1
0|1|libxul.so|mozilla::net::HttpBaseChannel::SetCookieHeaders(nsTArray<nsTString<char> > const&)|git:github.com/mozilla-firefox/firefox:netwerk/protocol/http/HttpBaseChannel.cpp:0fce12de99c5e7d74536d8f93cf9778ce6199a1f|3750|0xe7
0|2|libxul.so|mozilla::net::nsHttpChannel::ContinueProcessResponse1(mozilla::net::nsHttpConnectionInfo*)|git:github.com/mozilla-firefox/firefox:netwerk/protocol/http/nsHttpChannel.cpp:0fce12de99c5e7d74536d8f93cf9778ce6199a1f|3146|0x20d
0|3|libxul.so|mozilla::net::nsHttpChannel::ProcessResponse(mozilla::net::nsHttpConnectionInfo*)|git:github.com/mozilla-firefox/firefox:netwerk/protocol/http/nsHttpChannel.cpp:0fce12de99c5e7d74536d8f93cf9778ce6199a1f|3085|0x3d0
0|4|libxul.so|mozilla::net::nsHttpChannel::OnStartRequest(nsIRequest*)|git:github.com/mozilla-firefox/firefox:netwerk/protocol/http/nsHttpChannel.cpp:0fce12de99c5e7d74536d8f93cf9778ce6199a1f|9272|0xd71
0|5|libxul.so|nsInputStreamPump::OnStateStart()|git:github.com/mozilla-firefox/firefox:netwerk/base/nsInputStreamPump.cpp:0fce12de99c5e7d74536d8f93cf9778ce6199a1f|535|0x154
0|6|libxul.so|nsInputStreamPump::OnInputStreamReady(nsIAsyncInputStream*)|git:github.com/mozilla-firefox/firefox:netwerk/base/nsInputStreamPump.cpp:0fce12de99c5e7d74536d8f93cf9778ce6199a1f|437|0x110
0|7|libxul.so|{virtual override thunk({offset(-24)}, nsInputStreamPump::OnInputStreamReady(nsIAsyncInputStream*))}|git:github.com/mozilla-firefox/firefox:netwerk/base/nsInputStreamPump.cpp:0fce12de99c5e7d74536d8f93cf9778ce6199a1f||0xc
0|8|libxul.so|PipeCallbackRunnable::Run()|git:github.com/mozilla-firefox/firefox:xpcom/io/nsPipe3.cpp:0fce12de99c5e7d74536d8f93cf9778ce6199a1f|76|0x17
0|9|libxul.so|mozilla::RunnableTask::Run()|git:github.com/mozilla-firefox/firefox:xpcom/threads/TaskController.cpp:0fce12de99c5e7d74536d8f93cf9778ce6199a1f|721|0x17
0|10|libxul.so|mozilla::TaskController::DoExecuteNextTaskOnlyMainThreadInternal(mozilla::detail::BaseAutoLock<mozilla::Mutex&> const&)|git:github.com/mozilla-firefox/firefox:xpcom/threads/TaskController.cpp:0fce12de99c5e7d74536d8f93cf9778ce6199a1f|1342|0x5b4
0|11|libxul.so|mozilla::TaskController::ExecuteNextTaskOnlyMainThreadInternal(mozilla::detail::BaseAutoLock<mozilla::Mutex&> const&)|git:github.com/mozilla-firefox/firefox:xpcom/threads/TaskController.cpp:0fce12de99c5e7d74536d8f93cf9778ce6199a1f|1165|0x57
0|12|libxul.so|mozilla::TaskController::ProcessPendingMTTask(bool)|git:github.com/mozilla-firefox/firefox:xpcom/threads/TaskController.cpp:0fce12de99c5e7d74536d8f93cf9778ce6199a1f|657|0x65
0|13|libxul.so|mozilla::detail::RunnableFunction<mozilla::TaskController::TaskController()::$_1>::Run()|git:github.com/mozilla-firefox/firefox:xpcom/threads/nsThreadUtils.h:0fce12de99c5e7d74536d8f93cf9778ce6199a1f|549|0x19
0|14|libxul.so|nsThread::ProcessNextEvent(bool, bool*)|git:github.com/mozilla-firefox/firefox:xpcom/threads/nsThread.cpp:0fce12de99c5e7d74536d8f93cf9778ce6199a1f|1169|0x5ba
0|15|libxul.so|NS_ProcessNextEvent(nsIThread*, bool)|git:github.com/mozilla-firefox/firefox:xpcom/threads/nsThreadUtils.cpp:0fce12de99c5e7d74536d8f93cf9778ce6199a1f|467|0x4f
0|16|libxul.so|mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*)|git:github.com/mozilla-firefox/firefox:ipc/glue/MessagePump.cpp:0fce12de99c5e7d74536d8f93cf9778ce6199a1f|107|0x125
0|17|libxul.so|MessageLoop::Run()|git:github.com/mozilla-firefox/firefox:ipc/chromium/src/base/message_loop.cc:0fce12de99c5e7d74536d8f93cf9778ce6199a1f|348|0x61
0|18|libxul.so|nsBaseAppShell::Run()|git:github.com/mozilla-firefox/firefox:widget/nsBaseAppShell.cpp:0fce12de99c5e7d74536d8f93cf9778ce6199a1f|152|0x28
0|19|libxul.so|nsAppShell::Run()|git:github.com/mozilla-firefox/firefox:widget/gtk/nsAppShell.cpp:0fce12de99c5e7d74536d8f93cf9778ce6199a1f|555|0x114
0|20|libxul.so|nsAppStartup::Run()|git:github.com/mozilla-firefox/firefox:toolkit/components/startup/nsAppStartup.cpp:0fce12de99c5e7d74536d8f93cf9778ce6199a1f|290|0x64
0|21|libxul.so|XREMain::XRE_mainRun()|git:github.com/mozilla-firefox/firefox:toolkit/xre/nsAppRunner.cpp:0fce12de99c5e7d74536d8f93cf9778ce6199a1f|5931|0x10bd
0|22|libxul.so|XREMain::XRE_main(int, char**, mozilla::BootstrapConfig const&)|git:github.com/mozilla-firefox/firefox:toolkit/xre/nsAppRunner.cpp:0fce12de99c5e7d74536d8f93cf9778ce6199a1f|6186|0x5b5
0|23|libxul.so|XRE_main(int, char**, mozilla::BootstrapConfig const&)|git:github.com/mozilla-firefox/firefox:toolkit/xre/nsAppRunner.cpp:0fce12de99c5e7d74536d8f93cf9778ce6199a1f|6259|0x118
0|24|firefox-bin|main|git:github.com/mozilla-firefox/firefox:browser/app/nsBrowserApp.cpp:0fce12de99c5e7d74536d8f93cf9778ce6199a1f|534|0x444

This assert seems a bit more aggressive than the comment suggests it should be.
Seems like an edge case.
https://searchfox.org/firefox-main/rev/8ce9d585aca55919997d1a05506c69e309369167/netwerk/cookie/CookieService.cpp#619-621

Flags: needinfo?(tihuang)

For some reason, the cookieJarSettings of the channel doesn't contain a partitionKey, and the cookie has a partitioned attribute. Therefore, we cannot get the partitionedPrinicpal with the proper partitionKey, so triggering this assertion.

Flags: needinfo?(tihuang)

I can trigger this every time by doing the following:

The request was made by the reporting API. It looks like the implementation of the reporting API doesn't properly propagate the CookieJarSettings.

Assignee: nobody → tihuang
Status: NEW → ASSIGNED

Normally, a fetch request acquires its cookieJarSettings from the global
that triggers it (a window or a worker). However, the global may not
always have the correct cookieJarSettings. For example, the Reporting API
delivers reports using fetch from a global whose cookieJarSettings does
not match the originating content. In this case, the fallback creates a
default cookieJarSettings which can cause crashes when processing
Set-Cookie response headers (e.g. CHIPS cookies with the Partitioned
attribute).

This patch adds a ChromeOnly cookieJarSettings field to RequestInit and
a corresponding member on InternalRequest, allowing callers to explicitly
provide the correct cookieJarSettings. When set, it takes precedence
over the cookieJarSettings obtained from the global.

The Reporting API sends report delivery requests from a global that may
not carry the correct cookieJarSettings for the originating content.
This can cause crashes when the reporting endpoint responds with
Set-Cookie headers that require proper cookie jar context (e.g. CHIPS
cookies with the Partitioned attribute).

This patch propagates the cookieJarSettings through the reporting pipeline.
We store the cookieJarSettings in the GlobalReportingData when
initializing the reporting endpoints, obtained from the document or the
worker private. Then, we use the stored cookieJarSettings for the fetch
request for the report delivery.

Status: ASSIGNED → RESOLVED
Closed: 9 months ago
Resolution: --- → FIXED
Target Milestone: --- → 150 Branch

The patch landed in nightly and beta is affected.
:timhuang, is this bug important enough to require an uplift?

For more information, please visit BugBot documentation.

Flags: needinfo?(tihuang)
Flags: needinfo?(tihuang)

Normally, a fetch request acquires its cookieJarSettings from the global
that triggers it (a window or a worker). However, the global may not
always have the correct cookieJarSettings. For example, the Reporting API
delivers reports using fetch from a global whose cookieJarSettings does
not match the originating content. In this case, the fallback creates a
default cookieJarSettings which can cause crashes when processing
Set-Cookie response headers (e.g. CHIPS cookies with the Partitioned
attribute).

This patch adds a ChromeOnly cookieJarSettings field to RequestInit and
a corresponding member on InternalRequest, allowing callers to explicitly
provide the correct cookieJarSettings. When set, it takes precedence
over the cookieJarSettings obtained from the global.

Original Revision: https://phabricator.services.mozilla.com/D285021

Attachment #9549358 - Flags: approval-mozilla-beta?

The Reporting API sends report delivery requests from a global that may
not carry the correct cookieJarSettings for the originating content.
This can cause crashes when the reporting endpoint responds with
Set-Cookie headers that require proper cookie jar context (e.g. CHIPS
cookies with the Partitioned attribute).

This patch propagates the cookieJarSettings through the reporting pipeline.
We store the cookieJarSettings in the GlobalReportingData when
initializing the reporting endpoints, obtained from the document or the
worker private. Then, we use the stored cookieJarSettings for the fetch
request for the report delivery.

Original Revision: https://phabricator.services.mozilla.com/D285022

Attachment #9549359 - Flags: approval-mozilla-beta?

firefox-beta Uplift Approval Request

  • User impact if declined: The reporting API won't get protected by the Total Cookie Protection. This is a privacy leak.
  • Code covered by automated testing: yes
  • Fix verified in Nightly: yes
  • Needs manual QE test: no
  • Steps to reproduce for manual QE testing:
  • Risk associated with taking this patch: low
  • Explanation of risk level: The patch doesn't change any user behavior or functionalities.
  • String changes made/needed: None
  • Is Android affected?: yes
Attachment #9549361 - Flags: approval-mozilla-beta?
Attachment #9549361 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Attachment #9549359 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Attachment #9549358 - Flags: approval-mozilla-beta? → approval-mozilla-beta+

Verified on the latest Beta build (149.0b4) and on the latest Nightly build (150.0a1).

Tested page: http://mail.ru/

Tested device: Samsung Galaxy S25 Ultra (Android 16).

Marking the ticket as verified on 149 and 150.

Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: