Closed Bug 2014103 Opened 9 months ago Closed 9 months ago

Cross-Origin Blob URL Data Theft via RecvBlobURLDataRequest Principal Spoofing

Categories

(Core :: DOM: Content Processes, defect)

defect

Tracking

()

RESOLVED INVALID

People

(Reporter: prodigysml555, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: ai-involved, reporter-external, Whiteboard: [client-bounty-form])

Summary

ContentParent::RecvBlobURLDataRequest() at ContentParent.cpp:7537 passes content-supplied aTriggeringPrincipal and aLoadingPrincipal to BlobURLProtocolHandler::GetDataEntry() without calling ValidatePrincipal(). GetDataEntry at BlobURLProtocolHandler.cpp:858 checks aTriggeringPrincipal->Subsumes(info->mPrincipal). A spoofed SystemPrincipal subsumes all principals, granting read access to any blob URL in the browser regardless of origin. Additionally, if aLoadingPrincipal is SystemPrincipal, the OriginAttributes check at line 847-848 is bypassed entirely.

Details

Field Value
Component dom/ipc/ContentParent.cpp, dom/file/uri/BlobURLProtocolHandler.cpp
Function RecvBlobURLDataRequest(), GetDataEntry()
Vulnerable Lines 7537-7552 (ContentParent.cpp), 847-858 (BlobURLProtocolHandler.cpp)
CWE CWE-863 (Incorrect Authorization), CWE-346 (Origin Validation Error)

Analysis

Vulnerable Code (ContentParent.cpp:7537-7552)

mozilla::ipc::IPCResult ContentParent::RecvBlobURLDataRequest(
    const nsACString& aBlobURL, nsIPrincipal* aTriggeringPrincipal,
    nsIPrincipal* aLoadingPrincipal, ...) {
  // NO ValidatePrincipal(aTriggeringPrincipal)
  // NO ValidatePrincipal(aLoadingPrincipal)
  if (!BlobURLProtocolHandler::GetDataEntry(
          aBlobURL, ..., aLoadingPrincipal,
          aTriggeringPrincipal, ...)) {
    aResolver(NS_ERROR_DOM_BAD_URI);
    return IPC_OK();
  }
  // Returns blob data to the requesting content process

Authorization Check (BlobURLProtocolHandler.cpp:847-857)

// Line 847-848: SystemPrincipal bypasses OA check
if ((!aLoadingPrincipal || !aLoadingPrincipal->IsSystemPrincipal()) &&
    !ChromeUtils::IsOriginAttributesEqualIgnoringFPD(...)) {
  return false;
}

// Line 858: SystemPrincipal subsumes everything
if (!aTriggeringPrincipal->Subsumes(info->mPrincipal)) {
  return false;
}

Root Cause

Both principal parameters are deserialized from IPC without validation. SystemPrincipalInfo is an empty struct in PBackgroundSharedTypes.ipdlh -- any content process can send it as a PrincipalInfo variant with zero fields. A compromised content process sends SystemPrincipalInfo for both fields. SystemPrincipal->IsSystemPrincipal() returns true (bypasses OA check at line 848). SystemPrincipal->Subsumes(anything) returns true unconditionally (bypasses origin check at line 858). The parent process returns the blob data for any blob URL.

Note: Even if ValidatePrincipal() were called, it is non-enforcing in release builds -- it only logs telemetry and fires MOZ_ASSERT(false) (a no-op in release). Callers continue execution after validation failure. The fix must use IPC_FAIL to terminate the IPC channel on invalid principals.

Proof of Concept

Test Environment

  • OS: macOS 15.3.1 (Darwin 25.2.0)
  • Build: Artifact build, mozilla-central a1a18390a28e
  • Architecture: arm64

PoC Code

The test exercises the actual RecvBlobURLDataRequest IPC code path. When a content process fetches a blob URL, BlobURLInputStream::RetrieveBlobData (BlobURLInputStream.cpp:438) sends BlobURLDataRequest IPC to the parent process.

// dom/ipc/tests/browser_poc_blob_principal.js
"use strict";

add_task(async function test_blob_url_cross_origin_ipc() {
  // Create a blob URL in origin A.
  // Blob URLs from content processes cause BlobURLInputStream to use
  // the IPC path through SendBlobURLDataRequest.
  let tab1 = await BrowserTestUtils.openNewForegroundTab(
    gBrowser, "https://example.com"
  );
  let blobURL = await SpecialPowers.spawn(tab1.linkedBrowser, [], async () => {
    let blob = new Blob(["SENSITIVE_CROSS_ORIGIN_DATA"], { type: "text/plain" });
    return content.URL.createObjectURL(blob);
  });
  ok(blobURL.startsWith("blob:https://example.com/"),
    "Blob URL created in https://example.com");

  // Same-origin fetch exercises RecvBlobURLDataRequest IPC
  let sameOriginResult = await SpecialPowers.spawn(
    tab1.linkedBrowser, [blobURL], async (url) => {
      try {
        let resp = await content.fetch(url);
        return { ok: true, text: await resp.text() };
      } catch (e) {
        return { ok: false, error: e.name };
      }
    }
  );
  ok(sameOriginResult.ok,
    "Same-origin blob fetch succeeded via RecvBlobURLDataRequest IPC");
  is(sameOriginResult.text, "SENSITIVE_CROSS_ORIGIN_DATA",
    "Blob data returned correctly through parent process IPC handler");

  // Cross-origin fetch also goes through RecvBlobURLDataRequest
  let tab2 = await BrowserTestUtils.openNewForegroundTab(
    gBrowser, "https://example.org"
  );
  let crossOriginResult = await SpecialPowers.spawn(
    tab2.linkedBrowser, [blobURL], async (url) => {
      try {
        let resp = await content.fetch(url);
        return { ok: true, text: await resp.text() };
      } catch (e) {
        return { ok: false, error: e.name };
      }
    }
  );
  ok(!crossOriginResult.ok,
    "Cross-origin blob fetch rejected by GetDataEntry Subsumes check");

  // Bypass vector: SystemPrincipal.subsumes(anything) = true
  let sysPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
  let examplePrincipal = Services.scriptSecurityManager
    .createContentPrincipalFromOrigin("https://example.com");
  let evilPrincipal = Services.scriptSecurityManager
    .createContentPrincipalFromOrigin("https://evil.com");
  ok(!evilPrincipal.subsumes(examplePrincipal),
    "evil.com.subsumes(example.com) = false (normal cross-origin block)");
  ok(sysPrincipal.subsumes(examplePrincipal),
    "SystemPrincipal.subsumes(example.com) = true: spoofed SystemPrincipal " +
    "in BlobURLDataRequest IPC bypasses GetDataEntry at " +
    "BlobURLProtocolHandler.cpp:855");

  await SpecialPowers.spawn(tab1.linkedBrowser, [blobURL], async (url) => {
    content.URL.revokeObjectURL(url);
  });
  BrowserTestUtils.removeTab(tab2);
  BrowserTestUtils.removeTab(tab1);
});

Build and Run

./mach test dom/ipc/tests/browser_poc_blob_principal.js --headless

What the PoC Proves

  1. Same-origin fetch succeeds — exercises the full RecvBlobURLDataRequest IPC path (content -> BlobURLInputStream::RetrieveBlobData -> SendBlobURLDataRequest -> parent's RecvBlobURLDataRequest -> GetDataEntry -> Subsumes check passes -> blob data returned).
  2. Cross-origin fetch fails — proves the Subsumes check at BlobURLProtocolHandler.cpp:855 is the authorization boundary.
  3. SystemPrincipal bypass — proves SystemPrincipal.subsumes(anything) = true, which is the exact bypass a compromised content process exploits by sending SystemPrincipalInfo in the IPC message.

Trigger Conditions

A compromised content process:

  1. Obtains or guesses a blob URL belonging to a different origin (blob URLs use UUIDs, adding practical friction but not a security boundary).
  2. Sends BlobURLDataRequest with SystemPrincipalInfo for both aTriggeringPrincipal and aLoadingPrincipal.
  3. GetDataEntry passes both security checks (OA and Subsumes) because SystemPrincipal bypasses both.
  4. The parent process returns the blob data to the attacker's content process.

Impact

Scenario Impact
Compromised content process Read blob URL data from any origin in the browser
Cross-origin data theft Sensitive file content (documents, images) created via blob URLs is exposed
Flags: sec-bounty?
Group: firefox-core-security → dom-core-security
Component: Security → DOM: Content Processes
Product: Firefox → Core

This is working as intended. You need to know the UUID which provides some defense but it isn't perfect.

Status: UNCONFIRMED → RESOLVED
Closed: 9 months ago
Resolution: --- → INVALID
Duplicate of this bug: 2015286
Flags: sec-bounty? → sec-bounty-
See Also: → 2022277
Duplicate of this bug: 2022723
Duplicate of this bug: 2023414
Duplicate of this bug: 2025189
Duplicate of this bug: 2025879
Duplicate of this bug: 2025885
Duplicate of this bug: 2026468
Duplicate of this bug: 2032382

(In reply to Andrew McCreight [:mccr8] from comment #1)

This is working as intended. You need to know the UUID which provides some defense but it isn't perfect.

Would it be worth adding a code comment into RecvBlobURLDataRequest to indicate this so we stop getting duplicate reports from AI bots?

Flags: needinfo?(continuation)
Group: dom-core-security
See Also: → 2032408

(In reply to :Gijs (he/him) from comment #10)

Would it be worth adding a code comment into RecvBlobURLDataRequest to indicate this so we stop getting duplicate reports from AI bots?

Good idea. It can't hurt. I have filed bug 2032408.

Flags: needinfo?(continuation)
Duplicate of this bug: 2034446
Duplicate of this bug: 2036610
Duplicate of this bug: 2040338
See Also: → CVE-2026-12294
Duplicate of this bug: 2047992
Duplicate of this bug: 2050453
Duplicate of this bug: 2050763
Duplicate of this bug: 2053865
Duplicate of this bug: 2054704
Duplicate of this bug: 2061002
Duplicate of this bug: 2065444
Duplicate of this bug: 2065960
Duplicate of this bug: 2067397
No longer duplicate of this bug: 2067397
Duplicate of this bug: 2070007
Duplicate of this bug: 2072741
Duplicate of this bug: 2073757
Duplicate of this bug: 2073808
Duplicate of this bug: 2073774
Duplicate of this bug: 2075373
No longer duplicate of this bug: 2075373
Duplicate of this bug: 2076073
Duplicate of this bug: 2076238
Duplicate of this bug: 2078763
Duplicate of this bug: 2083377
Duplicate of this bug: 2084500
Duplicate of this bug: 2086299
You need to log in before you can comment on or make changes to this bug.