Open Bug 2022422 Opened 8 months ago Updated 4 months ago

Origin Spoofing in WebRTCParent/Child's unused PeerConnectionBlocker mechanism

Categories

(Core :: WebRTC, defect, P3)

defect

Tracking

()

People

(Reporter: define.ctf, Unassigned)

References

Details

(Keywords: ai-involved, good-first-bug, reporter-external)

SECURITY VULNERABILITY REPORT - ORIGIN SPOOFING

=== SUMMARY ===
WebRTCParent uses Object.assign() with trusted origin placed FIRST and child-controlled
data SECOND, allowing compromised renderers to overwrite the trusted origin field. This
bypasses all WebRTC policy blockers including enterprise policies and WebExtension
blocking rules.

=== COMPONENT ===
File: resource:///actors/WebRTCParent.sys.mjs
Lines: 40-56 (approximate)
Source: https://searchfox.org/mozilla-central/source/browser/actors/WebRTCParent.sys.mjs

=== AFFECTED VERSIONS ===
Firefox Desktop (all recent versions with WebRTC)
Platforms: Windows, macOS, Linux

=== VULNERABILITY DETAILS ===
The rtcpeer:Request handler incorrectly uses Object.assign():

case "rtcpeer:Request": {
  let params = Object.freeze(
    Object.assign(
      { origin: this.manager.documentPrincipal.origin },  // ⚠️ FIRST (trusted)
      aMessage.data   // ⚠️ SECOND (child-controlled) → OVERWRITES origin!
    )
  );
  
  for (let blocker of lazy.webrtcUI.peerConnectionBlockers) {
    let result = await blocker(params);  // ⚠️ Receives SPOOFED origin
  }
}

JavaScript Object.assign() Behavior:

  • Copies properties from right to left
  • Later properties OVERWRITE earlier ones
  • Child-controlled data overwrites trusted origin

Critical Issues:
❌ Trusted origin placed FIRST in Object.assign
❌ Child data placed SECOND (overwrites trusted data)
❌ No validation that origin matches documentPrincipal
❌ All peerConnectionBlockers receive spoofed origin
❌ Enterprise policies bypassed
❌ WebExtension blocking bypassed

=== ATTACK MECHANISM ===
Normal Flow (Safe):

  1. evil.com wants to use WebRTC
  2. Browser sends { origin: "https://evil.com" } to blockers
  3. Enterprise policy blocks evil.com
  4. WebRTC connection denied

Attack Flow (Spoofed):

  1. Compromised renderer on evil.com
  2. Sends rtcpeer:Request with: { origin: "https://accounts.google.com", callID: "...", secure: true }
  3. Object.assign overwrites trusted origin
  4. params = { origin: "https://accounts.google.com", ... }
  5. Blockers see accounts.google.com instead of evil.com
  6. WebRTC connection ALLOWED (bypass successful)

=== PROOF OF CONCEPT ===
From compromised content process:

// Normal WebRTC request (would be blocked)
// origin: evil.com → blocked by policy

// Malicious WebRTC request (spoofed origin)
const actor = windowGlobalChild.getActor("WebRTC");
actor.sendAsyncMe

This was originally filed as an open bug, rather than security sensitive.

Group: firefox-core-security
Summary: https://bugzilla.mozilla.org/enter_bug.cgi?product=Firefox → Origin Spoofing in WebRTCParent/Child

AFAICT nothing uses the blocker mechanism so this doesn't actually achieve anything. It looks like it was added in bug 1310355 for use by add-ons, but isn't exposed to add-ons in any meaningful way anymore.

Group: firefox-core-security → media-core-security
Component: Security → WebRTC
Product: Firefox → Core
Keywords: ai-involved

Feels like a front-end bug, I don't think the webrtc platform team works on this code. However, Jib r+'d that old patch, so I'm going to ni him for a look -

https://hg-edge.mozilla.org/mozilla-central/rev/eba5bc9fc212

Flags: needinfo?(jib)

As comment 2 suggests, this is not a sec bug. No parent resource is protected by this origin.

Long ago this mechanism was for add-ons to add additional permission prompts over and above those already present in Firefox.

It has been overtaken by architecture changes, and would need work to bring back as a feature.

Otherwise, it's a valid report that the code is careless. Instead of this:

        let params = Object.freeze(Object.assign({
          origin: aMessage.target.contentPrincipal.origin
        }, aMessage.data));

...the intent was likely to match this related use of freeze:

        let params = Object.freeze({
          origin: aMessage.target.contentPrincipal.origin,
          callID: aMessage.data
        });
Flags: needinfo?(jib)

Requesting re-triage per comment 4.

Flags: needinfo?(dveditz)
Group: media-core-security
Flags: needinfo?(dveditz)
Summary: Origin Spoofing in WebRTCParent/Child → Origin Spoofing in WebRTCParent/Child's unused PeerConnectionBlocker mechanism
Severity: -- → S3
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: good-first-bug
OS: Unspecified → All
Priority: -- → P3
Hardware: Unspecified → All
Version: unspecified → Trunk
Duplicate of this bug: 2057193
You need to log in before you can comment on or make changes to this bug.