PCookieStore GetRequest lacks parent-side authorization, allowing compromised content processes to read cross-origin and cross-container cookies
Categories
(Core :: Networking: Cookies, defect)
Tracking
()
People
(Reporter: lop123thcs, Unassigned)
References
(Blocks 1 open bug)
Details
(Keywords: csectype-site-isolation, reporter-external)
Attachments
(1 file)
|
5.90 KB,
application/zip
|
Details |
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36
Steps to reproduce:
I tested a local Firefox Nightly/debug build to simulate the standard browser-security threat model of a compromised content process.
-
I inspected
dom/cookiestore/CookieStoreParent.cppand observed thatRecvSetRequest/RecvDeleteRequestobtain the sender process handle and eventually enforceCheckContentProcessSecurity(...), butRecvGetRequestdoes not perform the equivalent parent-side authorization check. -
I modified the content-side CookieStore path only to simulate a compromised renderer forging a raw
PCookieStore::GetRequestIPC payload. The local patch does not create the parent-side bug; it only bypasses the renderer/WebIDL checks that a compromised content process would not be bound by. -
I populated the real Firefox cookie database with distinct non-HttpOnly cookies for
https://www.example.com/:container_secret=FROM_CONTAINER_1in Multi-Account ContaineruserContextId = 1normal_secret=FROM_DEFAULTin the default contextuserContextId = 0
-
From an attacker-controlled page running in the default context, I invoked the CookieStore API path. The compromised renderer simulation forged the IPC request so that:
aCookieURI = https://www.example.com/aOriginAttributes.mUserContextId = 1
-
This caused
CookieStoreParent::RecvGetRequestto dispatch the attacker-controlled URI andOriginAttributestoGetRequestOnMainThread, which then queried the cookie service using those child-supplied values.
Actual results:
The parent process accepted the forged PCookieStore::GetRequest without verifying that the sending content process was authorized to access www.example.com or the supplied userContextId.
The attacker page, running in the default container and not same-origin with https://www.example.com/, received the victim container cookie from the real Firefox cookie database:
Leaked: [{"name":"container_secret","value":"FROM_CONTAINER_1"}]
This demonstrates both:
- a cross-origin non-HttpOnly cookie read, because the attacker origin could read cookies for
https://www.example.com/; and - a cross-container cookie read, because the attacker default context could forge
OriginAttributes.mUserContextId = 1and receive a cookie from that container.
The WebIDL / renderer-side CookieStore checks are not sufficient here because a compromised content process can bypass them and send a forged PCookieStore IPC message directly. The parent-side RecvGetRequest path currently trusts the child-supplied aCookieURI and OriginAttributes.
Expected results:
CookieStoreParent::RecvGetRequest should not trust aCookieURI or OriginAttributes supplied by the child process.
The parent process should mirror the authorization model already used by the CookieStore mutation paths (Set and Delete):
- retrieve the sender's content process handle with
BackgroundParent::GetContentParentHandle(Manager()); - derive the requested base domain from
aCookieURI; - call
CheckContentProcessSecurity(...)before querying the cookie service; and - validate the supplied
OriginAttributes, includinguserContextId/ container identity and any partitioning-related attributes, against the sender's allowed cookie-access state.
If the sending content process is not authorized for the requested domain and origin attributes, the request should be rejected, fail the IPC operation, or return no cookies.
A compromised content process should not be able to use PCookieStore::GetRequest to read non-HttpOnly cookies across origins or across Firefox Multi-Account Container boundaries.
Updated•5 months ago
|
| Reporter | ||
Comment 2•5 months ago
|
||
Yes, I believe the container aspect is the new part.
The same missing parent-side authorization in RecvGetRequest allows the child to supply both the target URI and OriginAttributes. In my test, a compromised default-context content process could set mUserContextId = 1 and read a non-HttpOnly cookie from that container, so this bypasses Multi-Account Container cookie isolation in addition to the cross-origin read.
| Reporter | ||
Comment 3•5 months ago
|
||
Update: While developing a more complete PoC for the previously reported authorization gap, I analyzed the downstream effects of missing validation in the parent-side CookieStore IPC handlers.
I found that the same missing-validation pattern appears to affect RecvSubscribeOrUnsubscribeRequest as well. In addition to the direct GetRequest cookie-read path, a compromised content process can forge the PrincipalInfo and OriginAttributes used by PCookieStore::SubscribeOrUnsubscribeRequest.
This gives the compromised child process a second attack vector: instead of directly pulling cookies with GetRequest, it can register an unauthorized cookie-change subscription and have the parent later push cookie values to an attacker-controlled ServiceWorker.
Vector 1: Cross-Origin / Cross-Container Cookie Event Hijacking
If the attacker sends a structurally valid but unauthorized ContentPrincipalInfo, for example with a forged baseDomain and forged OriginAttributes, the parent process accepts and persists the subscription.
When a cookie changes on the victim domain, the parent checks the cookie's OriginAttributes against the forged subscription. If they match, the parent dispatches a cookiechange event containing the actual non-HttpOnly cookie name and value to the attacker-controlled ServiceWorker scope. The ServiceWorker can then forward the data to the attacker-controlled page via postMessage.
Confirmed security impact:
- Cross-origin cookie-change subscription: an attacker-controlled ServiceWorker scope can be registered for cookie-change events associated with a different victim domain.
- Cross-container impact: by forging
mUserContextIdin the suppliedOriginAttributes, a compromised process can target a different Multi-Account Container cookie jar. - Practicality when the container id is unknown: in my local PoC, I was able to spray several small
mUserContextIdvalues. The parent accepted the subscriptions, and only the subscription whose forged attributes matched the changed cookie triggered the event dispatch. This makes the attack practical even when the attacker does not know the exact target container id in advance. - Non-HttpOnly cookie value exfiltration: while HttpOnly cookies are filtered, the event still exposes non-HttpOnly cookie names and values. Depending on the target site, these may include application-managed tokens, CSRF-related state, custom auth/session-adjacent tokens, or other sensitive client-readable cookie state.
Exfiltrated data observed from my local attacker-controlled page:
{
"changed": [
{
"name": "session_token",
"value": "HIJACKED_VALUE_123"
}
],
"deleted": []
}
Runtime evidence of spray attack success:
[PoC] SPRAY ATTACK: Forging subscription with mUserContextId=0
[PoC] SPRAY ATTACK: Forging subscription with mUserContextId=1
[PoC] SPRAY ATTACK: Forging subscription with mUserContextId=2
[PoC] SPRAY ATTACK: Forging subscription with mUserContextId=3
[PoC] PARENT RECEIVED SUBSCRIPTION REQUEST
...
[PoC] Observe: Checking registration for scope http://localhost:8080/,
forged baseDomain: example.com,
cookie baseDomain: example.com
[PoC] Observe: MATCH! Calling swm->SendCookieChangeEvent
[PoC] Observe: swm->SendCookieChangeEvent SUCCESS
[PoC] Observe: attrs mismatch <-- other sprayed subscriptions ignored
Additional observation: parent-process crash with unexpected PrincipalInfo variant
While testing malformed subscription inputs, I also observed that sending an unexpected PrincipalInfo variant, such as NullPrincipalInfo, can crash the parent process.
The subscription code later appears to assume that the stored principal is a ContentPrincipalInfo. When an unexpected variant is processed, the parent terminates.
Runtime evidence:
[PoC] FORGING NULL PRINCIPAL INFO TO PARENT
[PoC] PARENT RECEIVED SUBSCRIPTION REQUEST
[PoC] CookieStoreSubscriptionService::Subscribe CALLED
...
Exiting due to channel error. (Parent Process terminated abruptly)
I have not fully characterized this crash as a memory-safety issue, so I am treating it as a parent-process DoS / robustness issue for now.
Root-cause hypothesis
The common issue appears to be that parent-side CookieStore IPC handlers accept child-supplied security metadata for sensitive cookie operations. For GetRequest, this includes the target URI and OriginAttributes. For SubscribeOrUnsubscribeRequest, this includes PrincipalInfo and OriginAttributes.
The parent should derive or validate the requested domain, principal, and origin attributes against the sending content process before performing cookie reads or persisting cookie-change subscriptions.
I have some questions : would you prefer that I file the SubscribeOrUnsubscribeRequest subscription-hijacking vector as a separate security bug, or should this bug be expanded to track both affected PCookieStore IPC paths? Also, should the unexpected-PrincipalInfo parent-process crash be tracked separately as a DoS/robustness issue?
I have minimized, reproducible Python/Marionette PoCs available for the GetRequest path, the subscription-hijacking path, and the crash case.
Comment 4•5 months ago
|
||
I don't think the container aspect is meaningfully different? The originAttributes are part of the origin and part of the fission isolation by "site", and either we are validating origins or not. But I suppose it's possible.
I have some questions : would you prefer that I file the SubscribeOrUnsubscribeRequest subscription-hijacking vector as a separate security
We think we just fixed SubscribeOrUnsubscribeRequest issue in bug 2031768. Please re-test in a build after that first. If it's still a problem please file a separate bug. In the new bug be sure to mention bug 2031768 and that you tested that fix, otherwise there's a good chance someone will just assume it's a duplicate without testing.
Speaking of testing, your text says things like "Confirmed security impact", "runtime evidence ..." followed by what looks like console output, and other such things that imply tests, but there are no actual tests here. Bugs without tests get deprioritized by human nature: an engineer can jump right in and start fixing things in a bug with a test. A testless bug like this one means an engineer would first have to pull all the pieces together and construct a test before they could get to work. Even if it should be straightforward, that required extra effort creates a barrier that pushes developers to work on other bugs first; the fact that so many bugs that look like this in the past few months turn out to have hallucinated the testcases also contributes to this subtle push towards working on other bugs first.
Also, should the unexpected-PrincipalInfo parent-process crash be tracked separately as a DoS/robustness issue?
Absolutely! ALWAYS separate bugs. https://bugzilla.mozilla.org/page.cgi?id=bug-writing.html#:~:text=Open%20a%20new%20bug%20report%20for%20each%20issue
I have minimized, reproducible Python/Marionette PoCs available for the GetRequest path, the subscription-hijacking path, and the crash case.
That's great! Why aren't they here? 😀
Comment 5•5 months ago
|
||
The commit for bug 2031768 is https://hg-edge.mozilla.org/mozilla-central/rev/9b5074e8849b
| Reporter | ||
Comment 6•5 months ago
|
||
(In reply to Daniel Veditz [:dveditz] from comment #5)
The commit for bug 2031768 is https://hg-edge.mozilla.org/mozilla-central/rev/9b5074e8849b
Got it — I’ll add the GetRequest PoC here and split the other cases out. Thanks for the commit pointer.
| Reporter | ||
Comment 7•5 months ago
|
||
I’ve attached the minimized GetRequest repro package as GetRequest.zip.
It contains:
- README-getrequest-repro.md
- exploit_getrequest.py
- poc_getrequest.html
- poc_getrequest_content_forge.diff
- getrequest_success.log
The content-side patch is only used to simulate a compromised content process forging the GetRequest IPC parameters. It does not introduce the parent-side issue.
The parent-side issue is that RecvGetRequest accepts the child-supplied cookie URI and OriginAttributes, then performs the cookie lookup without validating them against the sending process.
The attached log shows a localhost attacker page receiving the real www.example.com cookie from userContextId=1.
Comment 8•5 months ago
|
||
What version of firefox source are you testing? We think the PCookieStore GetRequest issue from comment 0 was fixed in bug 2016923 in Firefox 150.
https://hg-edge.mozilla.org/releases/mozilla-beta/rev/4fbdf8e8bd3b
| Reporter | ||
Comment 9•5 months ago
|
||
Thanks for the pointer.
For this GetRequest issue, I originally tested against an older local gecko-dev build, before realizing that bug 2016923 / 4fbdf8e8bd3b had already changed this path.
Based on the current source after that fix, RecvGetRequest now appears to perform the relevant parent-side cookie-access authorization check before querying cookies, so the GetRequest issue from comment 0 appears to be fixed by bug 2016923.
I’ve split the remaining SubscribeOrUnsubscribeRequest issue into bug 2046331, where I retested on a build containing the bug 2031768 fix and attached the minimized repro package and logs.
Comment 10•5 months ago
|
||
If this was fixed in bug 2016923 and everything else is now split to bug 2046331, let's close this out as a dupe.
Updated•2 months ago
|
Description
•