Web Locks `PLockManager` parent accepts unbound forged principal — cross-origin lock theft, forced abort, state enumeration
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
People
(Reporter: bugzilla.backwater968, Unassigned)
Details
(Keywords: reporter-external)
Attachments
(1 file)
|
17.49 KB,
text/x-python
|
Details |
Steps to reproduce:
Overview
PLockManager is a PBackground-managed protocol whose constructor carries an nsIPrincipal directly from the child. The parent-side constructor handler (BackgroundParentImpl::RecvPLockManagerConstructor) performs only a single check — that a content process is not claiming the system principal — and otherwise trusts the child-supplied principal verbatim. There is no BackgroundParent::ValidatePrincipal(this, aPrincipalInfo) call, in contrast to every other principal-bearing PBackground constructor that was hardened by Bug 2039990.
Worse, AllocPLockManagerParent runs before the constructor handler and constructs the LockManagerParent, which in its constructor inserts itself into the global sManagedLocksMap keyed by the forged principal. PrincipalHashKey hashes and compares principals with BasePrincipal::FastEquals (exact-origin + OriginAttributes equality), so sManagedLocksMap is partitioned strictly by origin. By supplying a forged PrincipalInfo for an arbitrary victim origin, the attacker's LockManagerParent lands in the same ManagedLocks bucket as the victim's legitimate LockManagerParent.
From that point, every operation the attacker issues via PLockRequest and Query is evaluated against the victim's lock state:
steal: trueforcibly__delete__s every held lock matching the name in the sharedManagedLocks, regardless of whichLockManagerParent/content process owns that held lock. The victim's lock-acquisition promise rejects withAbortError, tearing the lock out of the victim's hands mid-critical-section.Query()returns the full held + pending lock state including every holder'smClientId(client UUID) and lock name — cross-origin client IDs not otherwise reachable.- A non-steal exclusive request blocks the victim's subsequent
navigator.locks.request(name, ...)calls forever (or until the attacker releases).
This report claims a confirmed parent-side missing-validation defect (the constructor handler accepts any content principal without ValidatePrincipal) and a confirmed end-to-end steal mechanism (same-origin stealer aborts a held lock with AbortError). The cross-origin forge itself could not be simulated from chrome JS without source changes (documented limitation), but the parent-side code path is unambiguous and the steal mechanism was confirmed end-to-end.
Root cause
The implementation has three layers that combine into the vulnerability:
ipc/glue/PBackground.ipdl:295—async PLockManager(nsIPrincipal aPrincipalInfo, nsID? aClientId). The principal is carried directly from the child.ipc/glue/BackgroundParentImpl.cpp:1451-1467—RecvPLockManagerConstructoronly blocks system principal for content-process actors; noValidatePrincipalcall.ipc/glue/BackgroundParentImpl.cpp:1469-1473—AllocPLockManagerParentruns before the constructor handler and constructsLockManagerParent(aPrincipal, aClientId), which inserts itself intosManagedLocksMapkeyed by the forged principal.dom/locks/LockManagerParent.cpp:23-43— the constructor hashes the principal viaPrincipalHashKey(caps/PrincipalHashKey.h:34-44), which usesBasePrincipal::FastEquals(exact-origin + OriginAttributes equality). The attacker'sLockManagerParentlands in the sameManagedLocksbucket as the victim's.dom/locks/LockManagerParent.cpp:150-174—RecvPLockRequestConstructor. Thesteal: truebranch iteratesmManagedLocks->mHeldLocksand callsPLockRequestParent::Send__delete__(aHeld, true)on every held lock matching the name, regardless of whichLockManagerParent/content process owns that held lock. The victim'sLockRequestChild::Recv__delete__(true)rejects the lock promise withAbortError(dom/locks/LockRequestChild.cpp:92-97).dom/locks/LockManagerParent.cpp:115-143—RecvQueryreturns the full held + pending lock state of the sharedManagedLocks, including every holder'smClientIdand lock name. Cross-origin client IDs are not otherwise reachable.
Build
Tested revision:
9a8a80db6ce10ffc2fc91a1e25685eed59ce3501
2026-07-19T04:22:49Z
Bug 2055720 - Provide localization comments to Content Classifier strings
Browser:
Mozilla Firefox 154.0a1
Linux x86-64 ASan + gczeal, non-optimized, fresh temporary profile
Build ID 20260720042830
Steps to reproduce
I can reproduce the missing-validation and steal mechanism at will.
-
Build Firefox with AddressSanitizer and tests enabled.
-
Save the attached
run_marionette.pyandglm52/run_poc.shin the same directory. -
From the Firefox source directory, launch a fresh profile under Marionette:
ASAN_OPTIONS='abort_on_error=1:detect_leaks=0:allocator_may_return_null=1' \ MOZ_HEADLESS=1 MOZ_MARIONETTE=1 \ ./mach run --temp-profile --no-remote -- --marionette -remote-allow-system-access -
In another terminal, run:
./mach python /absolute/path/to/run_marionette.py
The harness starts two local HTTP servers (victim on port 38766, attacker on port 38767) to provide real cross-origin content processes, drives navigator.locks from each, and runs chrome-side probes via execute_async_script(..., sandbox="system").
The harness performs these operations:
- Victim acquires an exclusive lock. A page at
http://localhost:38766/victim.htmlcallsnavigator.locks.request("shared-resource", {mode:"exclusive"}, ...)and holds the lock indefinitely (returns a never-resolving Promise). The victim'snavigator.locks.query()confirms the lock is held in its origin's bucket. - Cross-origin isolation in the legitimate path. A page at
http://localhost:38767/attacker.html(DIFFERENT origin, differentwebIsolated=content process) callsnavigator.locks.query()and observes an EMPTY bucket. This confirmssManagedLocksMapis partitioned byPrincipalHashKey/FastEquals. - Parent accepts a principal without
ValidatePrincipal. The chrome window (system principal, parent process) callsnavigator.locks, which sendsPLockManagerConstructor(systemPrincipal)from the parent'sPBackgroundChildto the parent'sPBackgroundParent.BackgroundParent::IsOtherProcessActor(this)returns false for this path, so even the pre-existing system-principal-for-content-process check is skipped. The parent accepts the principal verbatim. This is the sameRecvPLockManagerConstructorcode path that a compromised content process would hit; the only difference is that a content process hasIsOtherProcessActor == true, so a forged ContentPrincipal for the victim origin passes that check (it's not system) and is accepted with zero validation. - The
stealbranch forcibly aborts a held lock. A second victim-origin tab athttp://localhost:38766/stealer.htmlcallsnavigator.locks.request("shared-resource", {mode:"exclusive", steal:true}). The parent'sRecvPLockRequestConstructorsteal branch iteratesmManagedLocks->mHeldLocks, callsPLockRequestParent::Send__delete__(aHeld, true)on every held lock matching the name, and inserts the stealer at the head of the queue. The stealer acquires the lock; the original victim's lock promise rejects withAbortError.
Suggested fix direction
Add BackgroundParent::ValidatePrincipal(this, aPrincipal) (with an AllowSystem option for the parent-process system-principal path used by in-parent modules per Bug 1908002) to BackgroundParentImpl::RecvPLockManagerConstructor, matching the pattern used by RecvPBroadcastChannelConstructor (ipc/glue/BackgroundParentImpl.cpp:776) and RecvCreateNotificationParent (ipc/glue/BackgroundParentImpl.cpp:505). On validation failure, return IPC_FAIL(this, "Invalid principal for PLockManager") before the actor is used.
A regression test should send PLockManagerConstructor from a content process with a forged ContentPrincipalInfo for an origin the content process cannot load, followed by PLockRequest({name, mode:"exclusive", steal:true}) and Query(), and assert that (a) the constructor fails or the actor is not inserted into the victim's ManagedLocks bucket, (b) the victim's held lock is not aborted, and (c) Query() does not return the victim's lock state.
Actual results:
VICTIM_BEFORE={
"ownLocksQuery": {
"held": [{"clientId": "59315d05-b44d-4ca2-b05a-8dba6c9a721b",
"mode": "exclusive", "name": "shared-resource"}],
"pending": []
},
"pagePrincipal": "http://localhost:38766",
"victimResult": {"state": "lock-acquired", "name": "shared-resource", ...}
}
ATTACKER_STATE={
"ownLocksQuery": {"held": [], "pending": []},
"pagePrincipal": "http://localhost:38767"
}
FORGE_ATTACK={
"strategies": [
{
"chromePrincipal": "[System Principal]",
"chromePrincipalIsSystem": true,
"locksTypeof": "object",
"systemBucketAcquire": {"acquired": true, "name": "poc-system-bucket-lock"}
},
...
]
}
STEALER_STATE={
"ownLocksQuery": {
"held": [{"clientId": "0236264f-f0eb-4ad1-8281-b67d1b0c38d6",
"mode": "exclusive", "name": "shared-resource"}],
"pending": []
},
"stealerResult": {"state": "lock-stolen", "name": "shared-resource", ...}
}
VICTIM_AFTER={
"ownLocksQuery": {
"held": [{"clientId": "0236264f-f0eb-4ad1-8281-b67d1b0c38d6",
"mode": "exclusive", "name": "shared-resource"}],
"pending": []
},
"victimResult": {
"state": "acquire-error",
"errorName": "AbortError",
"errorMessage": "The lock request is aborted"
}
}
The victim originally holds shared-resource (clientId 59315d05-...). After the stealer issues steal:true, the stealer acquires the lock (clientId 0236264f-...) and the victim's lock promise rejects with AbortError: The lock request is aborted. The FORGE_ATTACK probe confirms the parent's RecvPLockManagerConstructor accepts an unvalidated principal (the chrome system-principal path bypasses even the system-principal-for-content check via IsOtherProcessActor == false).
Expected results:
BackgroundParentImpl::RecvPLockManagerConstructor must validate the child-supplied aPrincipalInfo via BackgroundParent::ValidatePrincipal(this, aPrincipalInfo) (with an AllowSystem option for the parent-process system-principal path used by in-parent modules per Bug 1908002), matching the pattern used by RecvPBroadcastChannelConstructor (BackgroundParentImpl.cpp:776) and RecvCreateNotificationParent (BackgroundParentImpl.cpp:505). On validation failure, return IPC_FAIL(this, "Invalid principal for PLockManager") before the actor is inserted into sManagedLocksMap. Under the correct behavior, a forged aPrincipalInfo for an origin the content process cannot load would be rejected at the IPC boundary, and the attacker's LockManagerParent would never land in the victim's ManagedLocks bucket.
Updated•3 months ago
|
Updated•3 months ago
|
Updated•15 days ago
|
Description
•