Closed Bug 2032370 Opened 7 months ago Closed 3 months ago

PLockManager constructor accepts unchecked principal — content process can acquire/steal Web Locks for any origin

Categories

(Core :: DOM: Core & HTML, defect)

defect

Tracking

()

RESOLVED DUPLICATE of bug 2054671

People

(Reporter: pakhunov.anton.n, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: ai-involved, reporter-external, sec-want)

Summary

PLockManager is created via PBackground with a caller-supplied nsIPrincipal. The constructor in BackgroundParentImpl::RecvPLockManagerConstructor only blocks the system principal — any content process can forge a content principal for any origin and get a LockManagerParent keyed to that origin's lock namespace.

The check that exists (and what it misses)

// BackgroundParentImpl.cpp
IPCResult BackgroundParentImpl::RecvPLockManagerConstructor(
    PLockManagerParent* aActor, NotNull<nsIPrincipal*> aPrincipalInfo, ...) {
  if (aPrincipalInfo->IsSystemPrincipal() &&
      BackgroundParent::IsOtherProcessActor(this)) {
    return IPC_FAIL_NO_REASON(this);
  }
  return IPC_OK();
}

Blocked: system principal from content. Not blocked: any content principal, including one forged for bank.com while calling from evil.com's content process.

What you can do with the forged LockManager

sManagedLocksMap in LockManagerParent.cpp is a global map from PrincipalHashKey to ManagedLocks. A LockManagerParent with a forged bank.com principal shares the same ManagedLocks entry as the real bank.com lock manager.

RecvQuery — returns the full snapshot of held and pending locks for the forged origin:

held: [{name: "transaction-mutex", mode: "exclusive", clientId: "..."}]
pending: [...]

Lock names often encode internal application state.

RecvPLockRequestConstructor with steal: true — immediately evicts all currently held locks for the given resource name and grants the lock to the attacker:

if (aRequest.steal()) {
    mManagedLocks->mHeldLocks.RemoveElementsBy(
        [&aRequest](const RefPtr<LockRequestParent>& aHeld) {
            if (aHeld->Data().name() == aRequest.name()) {
                PLockRequestParent::Send__delete__(aHeld, true);  // releases real holder
                return true;
            }
        });
}

This lets the attacker release critical locks held by the victim origin — aborting in-progress database transactions, corrupting coordinated state, or causing the victim's tabs to lose their "only one tab" invariant if they use locks for that.

RecvPLockRequestConstructor with mode: "exclusive" — acquires an exclusive lock on any resource name in the victim's namespace, blocking all legitimate lock requests for that resource indefinitely.

Attack scenario

  1. Attacker's content process at evil.com sends PBackground::PLockManager(principal=bank.com, ...)
  2. Constructor passes — system principal check doesn't apply
  3. Attacker sends RecvQuery → gets list of all lock names bank.com is using
  4. Attacker sends PLockRequestConstructor(name="payment-lock", mode="exclusive", steal=true)
  5. Any bank.com tab holding "payment-lock" immediately loses it (lock is stolen)
  6. Attacker holds the exclusive lock — all bank.com tabs block trying to acquire it

Suggested fix

In RecvPLockManagerConstructor, validate that the supplied principal belongs to the calling process, similar to how CacheStorageParent and LocalStorageParent validate principal ownership. At minimum, reject any request from a content process where the origin doesn't match a document in that process.

Alternatively, look up the principal via the background actor's content parent rather than accepting it from the child.

Group: core-security → dom-core-security
Component: DOM: Security → DOM: Core & HTML
Severity: -- → S3
Duplicate of this bug: 2038595
Duplicate of this bug: 2044594
Duplicate of this bug: 2057376
Status: UNCONFIRMED → RESOLVED
Closed: 3 months ago
Duplicate of bug: 2054671
Resolution: --- → DUPLICATE
No longer duplicate of this bug: 2038595
No longer duplicate of this bug: 2044594
No longer duplicate of this bug: 2057376
Group: dom-core-security
You need to log in before you can comment on or make changes to this bug.