PWindowGlobal::SetCookies bypasses ContentProcessHasCookie authorization check
The PWindowGlobal::SetCookies IPC handler in Firefox forwards child-supplied cookie data to the internal cookie service without the ContentProcessHasCookie authorization check that the PNecko path enforces. A compromised content process could therefore inject cookies for any domain, enabling session fixation, CSRF token override, or mass tracking.
Originally disclosed on Mozilla
- Fixed in 4 months
- Paid in 6 months
- Disclosed after 4 months
Created attachment 9551671 PoC.js
Summary
WindowGlobalParent::RecvSetCookies (dom/ipc/WindowGlobalParent.cpp:1812) forwards child-supplied baseDomain, originAttributes, host, and cookies directly to the internal CookieServiceParent::SetCookies function without any authorization check.
The same cookie-setting operation via PNecko requires passing ContentProcessHasCookie authorization (CookieServiceParent.cpp:314), which verifies the content process was previously sent cookie data for that domain — failing this check triggers IPC_FAIL and kills the content process. The PWindowGlobal path completely bypasses this check.
A compromised content process can send the SetCookies IPC message via PWindowGlobal to inject cookies for any domain.
Source-audit verified in mozilla-central 150.0a1 (6d8a5fa56a95). The authorization asymmetry between the two IPC paths has been confirmed by reading the source code. Runtime cookie injection has not been demonstrated because the Browser Console's XPCOM cookie APIs (nsICookieManager.add()) use a different code path than the IPC handler and do not store cookies from chrome-only contexts. The actual attack path (forged PWindowGlobal::SetCookies IPC from a compromised content process) reaches SetCookiesFromIPC through the internal CookieServiceParent::SetCookies (line 322), which is distinct from the XPCOM API path.
Root Cause
Safe path: PNecko → CookieServiceParent::RecvSetCookies
// netwerk/cookie/CookieServiceParent.cpp:310-320
IPCResult CookieServiceParent::RecvSetCookies(
const nsCString& aBaseDomain, const OriginAttributes& aOriginAttributes,
nsIURI* aHost, bool aFromHttp, bool aIsThirdParty,
const nsTArray<CookieStruct>& aCookies) {
if (!ContentProcessHasCookie(aBaseDomain, aOriginAttributes)) {
return IPC_FAIL(this, "Invalid set-cookie request from content process");
// Authorization failure → kill content process
}
return SetCookies(aBaseDomain, aOriginAttributes, aHost, aFromHttp,
aIsThirdParty, aCookies);
}
ContentProcessHasCookie checks mCookieKeysInContent, which tracks cookie domains the parent has previously sent to this content process. Returns false if the process was never given cookies for that domain.
Vulnerable path: PWindowGlobal → WindowGlobalParent::RecvSetCookies
// dom/ipc/WindowGlobalParent.cpp:1812-1831
IPCResult WindowGlobalParent::RecvSetCookies(
const nsCString& aBaseDomain, const OriginAttributes& aOriginAttributes,
nsIURI* aHost, bool aFromHttp, bool aIsThirdParty,
const nsTArray<CookieStruct>& aCookies) {
ContentParent* contentParent = GetContentParent();
NS_ENSURE_TRUE(contentParent, IPC_OK());
net::PNeckoParent* neckoParent = ...;
net::PCookieServiceParent* csParent = ...;
auto* cs = static_cast<net::CookieServiceParent*>(csParent);
// NO ContentProcessHasCookie check — calls internal function directly
return cs->SetCookies(aBaseDomain, aOriginAttributes, aHost, aFromHttp,
aIsThirdParty, aCookies, GetBrowsingContext());
}
CookieServiceParent::SetCookies (line 322) is the internal implementation that does not call ContentProcessHasCookie:
// netwerk/cookie/CookieServiceParent.cpp:322-352
IPCResult CookieServiceParent::SetCookies(
const nsCString& aBaseDomain, const OriginAttributes& aOriginAttributes,
nsIURI* aHost, bool aFromHttp, bool aIsThirdParty,
const nsTArray<CookieStruct>& aCookies,
dom::BrowsingContext* aBrowsingContext) {
// Only null check on aHost
// NO ContentProcessHasCookie check
nsICookieValidation::ValidationError error =
mCookieService->SetCookiesFromIPC(aBaseDomain, aOriginAttributes, aHost,
aFromHttp, aIsThirdParty, aCookies,
aBrowsingContext);
// SetCookiesFromIPC only validates cookie format, not sender authorization
return IPC_OK();
}
IPDL Definition
// dom/ipc/PWindowGlobal.ipdl:222-227
async SetCookies(nsCString baseDomain,
OriginAttributes attrs,
nullable nsIURI host,
bool fromHttp,
bool isThirdParty,
CookieStruct[] cookies);
All parameters (baseDomain, attrs, host, cookies) are child-supplied, and the parent only validates format consistency.
User-Facing Attack Scenarios
Scenario 1: Session Fixation via Cookie Injection
- Attacker exploits a renderer vulnerability (e.g., JS engine UAF) to gain code execution in a content process
- To bypass PNecko's authorization, uses PWindowGlobal::SetCookies IPC instead
- Injects a cookie with:
baseDomain = "bank.example.com"host = https://bank.example.com/cookies = [{name: "session_id", value: "attacker_known_value", host: ".bank.example.com", path: "/", isSecure: true, isHttpOnly: true}]
ContentProcessHasCookiecheck is bypassed; cookie is written toCookieService- When user visits bank.example.com, the attacker-injected
session_idis sent with requests - If the server starts a new session with this ID, the attacker — who knows the same
session_id— can share the session (session fixation)
Scenario 2: CSRF Token Override
- Compromised content process (evil.com) injects CSRF cookies for bank.com
- Overwrites CSRF tokens with attacker-controlled values
- Attacker uses the known CSRF token to execute unauthorized transactions in the victim's bank session
Scenario 3: Mass Tracking Cookie Injection
- Compromised content process injects tracking cookies for hundreds of domains
- Bypasses ETP/dFPI protections to establish persistent cross-site tracking
- Cookies persist across browser restarts
Comparison of the Two Paths
| PNecko path | PWindowGlobal path | |
|---|---|---|
| Handler | CookieServiceParent::RecvSetCookies (line 310) |
WindowGlobalParent::RecvSetCookies (line 1812) |
ContentProcessHasCookie |
Present (line 314) | Absent |
| Failure handling | IPC_FAIL → kill process |
N/A (check absent) |
SetCookiesFromIPC |
Present (format validation) | Present (format validation only) |
| Sender authorization | Verified via mCookieKeysInContent |
None |
Suggested Fix
IPCResult WindowGlobalParent::RecvSetCookies(
const nsCString& aBaseDomain, const OriginAttributes& aOriginAttributes,
nsIURI* aHost, bool aFromHttp, bool aIsThirdParty,
const nsTArray<CookieStruct>& aCookies) {
// ... (get CookieServiceParent)
auto* cs = static_cast<net::CookieServiceParent*>(csParent);
// Fix: add ContentProcessHasCookie check
if (!cs->ContentProcessHasCookie(aBaseDomain, aOriginAttributes)) {
return IPC_FAIL(this, "PWindowGlobal: Invalid set-cookie request");
}
return cs->SetCookies(aBaseDomain, aOriginAttributes, aHost, aFromHttp,
aIsThirdParty, aCookies, GetBrowsingContext());
}
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The PWindowGlobal::SetCookies handler calls the internal CookieServiceParent::SetCookies directly, omitting the ContentProcessHasCookie authorization check that the PNecko handler performs.
Impact
A compromised content process could inject cookies for arbitrary domains, potentially enabling session fixation, CSRF token override, or persistent cross-site tracking; runtime injection was not demonstrated, only source-audit verification.
What the attacker needed
Compromised content process; renderer code execution (e.g. JS engine UAF)
The fix
The PWindowGlobal::RecvSetCookies handler should call ContentProcessHasCookie and return IPC_FAIL when the check fails, matching the PNecko path.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A web browser splits itself into a privileged parent process and less-trusted child processes that render pages. When a child wants to set a cookie, the parent is supposed to check that the child is allowed to touch that domain first. Here, one of the two message routes skips that check, so a child that has already been taken over could write cookies for any site.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.