Closed Bug 2084500 Opened 1 month ago Closed 1 month ago

Missing principal validation in ContentParent::RecvBlobURLDataRequest lets a compromised content process read any origin's (including revoked) blob URL contents through the parent

Categories

(Core :: DOM: Content Processes, defect)

defect

Tracking

()

RESOLVED DUPLICATE of bug 2014103

People

(Reporter: kietbuile2001, Unassigned)

Details

(Keywords: reporter-external, Whiteboard: [client-bounty-form][b-noted])

Attachments

(1 file)

19.64 KB, application/x-zip-compressed
Details
Attached file f1-poc-package.zip —

Product/Component: Core / DOM: Content Processes
Version: Nightly 160.0a1 (platformBuildID 20261020195026). Introduced in
Firefox 81 (absent in FIREFOX_80_0_RELEASE; present and unvalidated in
FIREFOX_81_0_RELEASE and on current beta, release, esr153, esr140, and esr128
tips). Also confirmed at runtime on a stock Firefox 140.0.2 install.
Environment: Windows 11 x64 (10.0.26200) and a second machine on Windows 10
22H2 (10.0.19045) — fresh throwaway profiles on both, tested in both normal
mode and Troubleshoot Mode (-safe-mode).

STEPS TO REPRODUCE:

We provide two verification layers: Layer 1 runs on unmodified official Firefox
binaries to verify the parent-side GetDataEntry behavior, and Layer 2 exercises
the full child->parent PBlobURLDataRequest IPC path from a real content process.

Layer 1 — Unmodified official binaries (f1-run.py, f1-safemode-run.py,
f1-run-release140.py):

  1. Serve f1-victim.html at http://127.0.0.1:8765 and f1-attacker.html at
    http://127.0.0.1:8766 (two different origins).
  2. The victim page creates Blob("window.__PWNED_BY_F1 = '<random>'",
    {type: "text/javascript"}) and generates a blob: URL via
    URL.createObjectURL().
  3. Control check: the attacker page attempts to load the victim's blob: URL
    via <script src>. The load fails and the script does not execute, confirming
    that origin isolation holds when loading/triggering principals are honest.
  4. Using Marionette in chrome context (Marionette:SetContext("chrome")), the
    runner calls fetch(blobURL) in the parent process with the system principal.
    This exercises BlobURLProtocolHandler::GetDataEntry with the exact parameter
    set a compromised content process can send over PBlobURLDataRequest
    (loadingPrincipal = system, triggeringPrincipal = system, empty
    OriginAttributes, empty partitionKey). Result: HTTP 200 and the victim's
    blob body is returned.
  5. The runner calls URL.revokeObjectURL() in the victim page and immediately
    repeats step 4: the parent still returns HTTP 200 with the victim's blob
    body because GetDataEntry is called with aAlsoIfRevoked = true (the 5-second
    revocation grace window).

Layer 2 — Full child->parent IPC chain on a local build (f1-instrumentation.patch,
f1-build-run.py, f1-build-results-off.json, f1-build-results-on.json):
To simulate a compromised content process without touching any parent-side
code, f1-instrumentation.patch adds an off-by-default preference
(f1.poc.forge-system-principal) that modifies three child-side call sites only:

  • BlobURLInputStream.cpp substitutes the system principal for both
    triggeringPrincipal and loadingPrincipal, along with empty OriginAttributes
    and an empty partitionKey, right before calling SendBlobURLDataRequest().
  • nsScriptSecurityManager.cpp skips the child-side CheckLoadURIWithPrincipal
    gate for blob: URIs.
  • BlobURLChannel.cpp skips the child-side unknown/revoked channel gate.
    ContentParent.cpp and BlobURLProtocolHandler.cpp are completely unmodified
    (byte-identical to mozilla-central @ 3171262319bd).
  1. Serve f1-victim.html at http://127.0.0.2:8765 and f1-attacker.html at
    http://127.0.0.1:8766 (two different sites -> two separate content
    processes).
  2. With f1.poc.forge-system-principal = false (stock behavior), the attacker
    page at http://127.0.0.1:8766 is blocked from loading both the live and
    revoked cross-site blob URLs (loaded: false, pwned: null).
  3. With f1.poc.forge-system-principal = true, the attacker content process
    sends the forged PBlobURLDataRequest message to the unmodified parent,
    receives the victim's blob stream, and executes the victim's JavaScript
    inside the attacker's cross-site page (window.__PWNED_BY_F1 is set to the
    victim's secret marker) for both the live blob and the revoked blob.
    Child console trace:
    "[f1-poc] forging PBlobURLDataRequest params (system principals)"
    "[f1-poc] sending PBlobURLDataRequest (forge=1) for blob:http://127.0.0.2:8765/..."

EXPECTED RESULTS:
ContentParent::RecvBlobURLDataRequest should validate the child-supplied
principals (and verify context/origin ownership) before looking up the blob
entry, rejecting forged system principals or cross-origin requests from a
content process—consistent with its sibling blob URL handlers in
ContentParent.cpp.

ACTUAL RESULTS:
ContentParent::RecvBlobURLDataRequest passes the deserialized principals,
OriginAttributes, and partition key straight from the IPC message into
BlobURLProtocolHandler::GetDataEntry(..., /* aAlsoIfRevoked = */ true) without
validation. Presenting a system principal and an empty partition key bypasses
all isolation checks in GetDataEntry, allowing a compromised content process to
read any registered blob URL across origins, containers, and private-browsing
windows, including recently revoked blobs.

ROOT CAUSE ANALYSIS:

  • dom/ipc/ContentParent.cpp:7542-7569 (ContentParent::RecvBlobURLDataRequest):
    forwards aTriggeringPrincipal, aLoadingPrincipal, aOriginAttributes, and
    aPartitionKey directly from the IPC message into
    BlobURLProtocolHandler::GetDataEntry(..., true) with no ValidatePrincipal()
    call and no null or ownership check. By contrast, its sibling handlers
    RecvStoreAndBroadcastBlobURLRegistration (:5888) and
    RecvUnstoreAndBroadcastBlobURLUnregistration (:5914) both call
    ValidatePrincipal().
  • dom/file/uri/BlobURLProtocolHandler.cpp:806-834
    (BlobURLProtocolHandler::GetDataEntry):
    • Lines 806-812 skip the OriginAttributes comparison when
      aLoadingPrincipal->IsSystemPrincipal() is true.
    • Line 814 checks aTriggeringPrincipal->Subsumes(entry->mPrincipal), which
      always succeeds for a system principal.
    • Lines 818-820 enforce the partition key only when
      !entry->mPartitionKey.IsEmpty() && !aPartitionKey.IsEmpty(), so passing an
      empty aPartitionKey bypasses partition isolation.
    • Passing aAlsoIfRevoked = true allows reading blobs for up to 5 seconds
      after URL.revokeObjectURL() has been called.
  • ipc/glue/BackgroundUtils.cpp:50-56 (PrincipalInfoToPrincipal):
    TSystemPrincipalInfo deserializes into the real system principal regardless
    of which process sent the message, relying on individual parent IPC handlers
    to call ValidatePrincipal().

SECURITY IMPACT:
After a content process compromise, the parent process is the trust anchor
enforcing site isolation. Because RecvBlobURLDataRequest performs no principal
or ownership validation, a compromised renderer can pull the raw contents of any
blob URL known to the parent—crossing site origins, container tabs, and private
browsing contexts (via the OriginAttributes and partitionKey bypasses), as well
as reading blobs shortly after revocation. Blobs commonly hold sensitive
application data in memory (files staged for upload or download, decrypted
attachments, generated documents/exports, and media buffers).

SUGGESTED FIX:

  • In ContentParent::RecvBlobURLDataRequest (dom/ipc/ContentParent.cpp:7542):
    null-check and validate both aLoadingPrincipal and aTriggeringPrincipal via
    ValidatePrincipal() (matching :5888 and :5914), and do not allow a content
    child to assert the system principal for blob data requests. Additionally,
    verify that the requesting child process is permitted to load for the
    supplied context/principal.
  • Defense in depth in BlobURLProtocolHandler::GetDataEntry: require partition
    key equality whenever entry->mPartitionKey is non-empty (even if the caller's
    aPartitionKey is empty).

Attachments (in f1-poc-package.zip):

  • f1-victim.html, f1-attacker.html (test pages)
  • layer1/f1-run.py, f1-safemode-run.py, f1-run-release140.py +
    f1-results-{nightly,safemode-nightly,release140}.json
  • layer2/f1-instrumentation.patch, f1-build-run.py, f1-diag.py +
    f1-build-results-{off,on}.json
  • second-machine/guest-results.json, guest-ver.txt (reproduction on Windows 10
    22H2)
  • environment/support-info-host.txt, support-info-guest.txt

See Also: bug 2020805 (covers IPC handlers where ValidatePrincipal() is present
but non-fatal in Release builds; in contrast, RecvBlobURLDataRequest has no
ValidatePrincipal() call at all).

Note on AI assistance: AI tools assisted with static code auditing and drafting
the local Marionette test harness; all source spans and both PoC layers were
verified manually by the reporter.

Flags: sec-bounty?
Group: firefox-core-security
Status: UNCONFIRMED → RESOLVED
Closed: 1 month ago
Component: Security → DOM: Content Processes
Duplicate of bug: 2014103
Product: Firefox → Core
Resolution: --- → DUPLICATE
Flags: sec-bounty? → sec-bounty-
Whiteboard: [client-bounty-form] → [client-bounty-form][b-noted]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: