Closed Bug 2055697 (CVE-2026-74967) Opened 4 months ago Closed 3 months ago

Cross-origin HTTP status line disclosure via HTMLMediaElement error.message when the media load traverses a same-origin redirect [@ HTMLMediaElement::NoSupportedMediaSourceError]

Categories

(Core :: Audio/Video: Playback, defect)

defect

Tracking

()

RESOLVED FIXED
155 Branch
Tracking Status
firefox-esr115 --- unaffected
firefox-esr140 154+ fixed
firefox-esr153 154+ fixed
firefox153 --- wontfix
firefox154 + fixed
firefox155 + fixed

People

(Reporter: bugmon, Assigned: alwu)

References

(Blocks 1 open bug)

Details

(5 keywords, Whiteboard: [adv-main154+][adv-esr153.1+][adv-esr140.14+])

Attachments

(7 files, 5 external files)

Ordinary web content can read the HTTP status code and server reason phrase of an arbitrary cross-origin resource through HTMLMediaElement.error.message by loading the victim URL behind a same-origin 30x redirector.

When a media load fails with a non-success HTTP status, MediaLoadListener::OnStartRequest builds an error detail string "%u: %s" from the FINAL (post-redirect) channel's GetResponseStatus/GetResponseStatusText and forwards it via NotifyLoadError to HTMLMediaElement::NoSupportedMediaSourceError. That function contains a redaction gate that is explicitly intended to prevent leaking HTTP status codes for third-party resources: it replaces the detailed message with the generic "Failed to open media" when the load is cross-origin. However, the gate decides same-origin-ness with mSrcAttrTriggeringPrincipal->IsSameOrigin(mLoadingSrc), and mLoadingSrc is the PRE-redirect src-attribute URI; it is set only in SelectResource/LoadFromSourceChildren and is never refreshed on redirect — HTMLMediaElement::OnChannelRedirect -> ChannelLoader::Redirect only swaps mChannel and forwards the Range header. Consequently, a same-origin URL that 302-redirects to a cross-origin victim takes the detailed (same-origin) branch, and MediaError::GetMessage returns the victim's status line to content JS (unless privacy.resistFingerprinting is enabled).

Because media element loads are credentialed no-cors requests, this is a cross-origin information disclosure and XS-Leak oracle: it reveals login state and resource existence via status codes (200/403/404/302-chain results) and additionally discloses server-chosen reason-phrase text — data that no web-exposed API returns for cross-origin no-cors loads (opaque responses deliberately hide it). The victim response must reach the media stack (pass ORB for a media destination); empirically a 403 with Content-Type: audio/mpeg and a non-media body passes. Verified against the current tree with an unmodified ASAN build and default prefs: the leak reproduces via the redirect, while a direct cross-origin load of the identical victim URL is correctly redacted, proving the bypass is redirect-specific. Note the gate also fails open when the principal comparison is unavailable (rv failure or null mSrcAttrTriggeringPrincipal takes the detailed branch).

Build Info

Affected Code

File: dom/media/mediaelement/HTMLMediaElement.cpp, line 1563-1575

  nsCOMPtr<nsIHttpChannel> hc = do_QueryInterface(aRequest);
  bool succeeded;
  if (hc && NS_SUCCEEDED(hc->GetRequestSucceeded(&succeeded)) && !succeeded) {
    uint32_t responseStatus = 0;
    (void)hc->GetResponseStatus(&responseStatus);       // <-- FINAL (post-redirect) channel
    nsAutoCString statusText;
    (void)hc->GetResponseStatusText(statusText);        // <-- server-chosen reason phrase
    // we need status text for resist fingerprinting mode's message allowlist
    if (statusText.IsEmpty()) {
      net_GetDefaultStatusTextForCode(responseStatus, statusText);
    }
    element->NotifyLoadError(
        nsPrintfCString("%u: %s", responseStatus, statusText.get()));

File: dom/media/mediaelement/HTMLMediaElement.cpp, line 2697-2715

  bool isSameOriginLoad = false;
  nsresult rv = NS_ERROR_NOT_AVAILABLE;
  if (mSrcAttrTriggeringPrincipal && mLoadingSrc) {
    rv = mSrcAttrTriggeringPrincipal->IsSameOrigin(mLoadingSrc,   // <-- mLoadingSrc is the PRE-redirect URI
                                                   &isSameOriginLoad);
  }

  if (NS_SUCCEEDED(rv) && !isSameOriginLoad) {
    // aErrorDetails can include sensitive details like MimeType or HTTP Status
    // Code. In case we're loading a 3rd party resource we should not leak this
    // and pass a Generic Error Message
    mErrorSink->SetError(MEDIA_ERR_SRC_NOT_SUPPORTED,
                         Some(MediaResult{NS_ERROR_DOM_MEDIA_NOT_SUPPORTED_ERR,
                                          "Failed to open media"_ns}));
  } else {
    mErrorSink->SetError(                                        // <-- detailed branch: leaks status line
        MEDIA_ERR_SRC_NOT_SUPPORTED,
        Some(MediaResult{NS_ERROR_DOM_MEDIA_NOT_SUPPORTED_ERR, aErrorDetails}));
  }

File: dom/media/mediaelement/HTMLMediaElement.cpp, line 2101-2124

  nsresult Redirect(nsIChannel* aChannel, nsIChannel* aNewChannel,
                    uint32_t aFlags) {
    NS_ASSERTION(aChannel == mChannel, "Channels should match!");
    mChannel = aNewChannel;   // <-- only swaps the channel; mLoadingSrc is never refreshed

    // Handle forwarding of Range header so that the intial detection
    // of seeking support (via result code 206) works across redirects.
    nsCOMPtr<nsIHttpChannel> http = do_QueryInterface(aChannel);
    NS_ENSURE_STATE(http);
    ...
    return NS_OK;
  }

File: dom/media/mediaelement/HTMLMediaElement.cpp, line 2930-2936

      RemoveMediaElementFromURITable();
      if (!mSrcMediaSource) {
        mLoadingSrc = uri;    // <-- set from the src attribute (pre-redirect), the only update path
      } else {
        mLoadingSrc = nullptr;
      }
      mLoadingSrcTriggeringPrincipal = mSrcAttrTriggeringPrincipal;

File: dom/media/MediaError.cpp, line 31-83

void MediaError::GetMessage(nsAString& aResult) const {
  ...
    if (!nsContentUtils::IsCallerChrome() &&
        ownerDoc->ShouldResistFingerprinting(RFPTarget::MediaError)) {
      aResult.Truncate();   // <-- only redacted under resistFingerprinting
      return;
    }
  }

  CopyUTF8toUTF16(mMessage, aResult);   // <-- detailed message returned to content JS by default
}

The error detail is minted from the final post-redirect channel, but the redaction gate keys on the pre-redirect mLoadingSrc, which the redirect hook never updates.

Exploit Chain

  1. Attacker page at https://attacker.example creates a <video> element with src set to a same-origin URL /redirect (attacker-controlled, or any open redirector on the attacker's origin).
  2. /redirect answers 302 with Location: https://victim.example/secret-resource; the media load follows the redirect as a credentialed no-cors request (victim cookies attached).
  3. The victim responds with an error status (e.g. 403 Forbidden-SECRET-42) and a media Content-Type (or otherwise passes ORB for a media destination), so the response reaches the media stack.
  4. MediaLoadListener::OnStartRequest sees GetRequestSucceeded()==false on the FINAL channel and calls NotifyLoadError("403: Forbidden-SECRET-42") built from the victim's status line (HTMLMediaElement.cpp:1563-1575).
  5. NotifyLoadError -> NoSupportedMediaSourceError: the redaction gate computes IsSameOrigin(page principal, mLoadingSrc) where mLoadingSrc is still the PRE-redirect same-origin /redirect URI, so isSameOriginLoad==true and the detailed (unredacted) branch is taken (HTMLMediaElement.cpp:2697-2715).
  6. The video element fires the error event; attacker JS reads video.error.message == "403: Forbidden-SECRET-42" via MediaError::GetMessage — the cross-origin victim's HTTP status code and server-chosen reason phrase.
  7. Attacker repeats the probe against arbitrary victim URLs to build an XS-Leak oracle (login state, resource existence, per-user status differences) and to harvest reason-phrase text that no-cors/opaque responses deliberately hide.

Steps to Reproduce

  1. Build Firefox from a clean tree with the ASAN fuzzing mozconfig (mozconfig.linux.asan.fuzzing); no source modifications are required.
  2. Start the dual-origin test server: python3 leaksrv.py & — it serves the attacker origin http://127.0.0.1:38742 (attacker.html, /redirect which 302s to the victim) and the victim origin http://localhost:38742 (/victim.mp3 answering 403 Forbidden-SECRET-42 with Content-Type: audio/mpeg). 127.0.0.1 and localhost are distinct web origins, standing in for attacker.example -> victim.example.
  3. Run test.html via browser_evaluator with prefs {"network.proxy.type": 0} (only needed to bypass the test harness's PAC proxy; this restores the shipping default). test.html top-level-navigates to http://127.0.0.1:38742/attacker.html.
  4. attacker.html probes three loads and logs the results. Observe in the console log: RESULT-REDIRECT-LEAK: [403: Forbidden-SECRET-42] (cross-origin victim's status line read by attacker JS via the same-origin redirector), RESULT-CONTROL-DIRECT-CROSSORIGIN: [Failed to open media] (identical victim URL loaded directly is correctly redacted), and RESULT-CONTROL-SAMEORIGIN: [403: Forbidden-SECRET-42] (same-origin baseline).

Security Impact

  • Severity: Moderate
  • Attacker capability: Any web page can read the HTTP status code and server reason phrase of arbitrary cross-origin resources (that pass ORB for a media destination) fetched with the victim's credentials, by loading them behind a same-origin redirect and reading HTMLMediaElement.error.message. This yields a cross-origin XS-Leak oracle (login-state detection, resource-existence probing, per-user status differences) and direct disclosure of server-chosen reason-phrase text — information that opaque no-cors responses deliberately withhold and that Firefox's own redaction gate is designed to hide for third-party loads.
  • Preconditions: Default prefs, ordinary web content, no user interaction. The attacker needs a same-origin URL redirecting to the victim (trivially their own site or any open redirector). The victim response must reach the media stack (pass ORB for a media destination) — empirically an error status with a media Content-Type passes; privacy.resistFingerprinting must be off (default).

ASAN Report

No memory-safety crash — verified cross-origin information disclosure (logic/privilege violation) with observable-effect evidence. browser_evaluator log from the verifier's independent run (pristine ASAN build of a clean tree, default prefs + network.proxy.type=0 to bypass the harness PAC proxy):

[Child 9186: Main Thread]: W/PageMessages [JavaScript Warning: "HTTP load failed with status 403. Load of media resource http://127.0.0.1:38742/redirect failed." {file: "http://127.0.0.1:38742/attacker.html" line: 0}]
[Child 9186: Main Thread]: W/PageMessages [JavaScript Warning: "This error message will be blank when privacy.resistFingerprinting = true.  If it is really necessary, please add it to the whitelist in MediaError::GetMessage: 403: Forbidden-SECRET-42" {file: "http://127.0.0.1:38742/attacker.html" line: 9}]
[Child 9186: Main Thread]: I/console log: "RESULT-REDIRECT-LEAK: [403: Forbidden-SECRET-42]"
[Child 9186: Main Thread]: W/PageMessages [JavaScript Warning: "HTTP load failed with status 403. Load of media resource http://localhost:38742/victim.mp3 failed." {file: "http://127.0.0.1:38742/attacker.html" line: 0}]
[Child 9186: Main Thread]: I/console log: "RESULT-CONTROL-DIRECT-CROSSORIGIN: [Failed to open media]"
[Child 9186: Main Thread]: I/console log: "RESULT-CONTROL-SAMEORIGIN: [403: Forbidden-SECRET-42]"
[Child 9186: Main Thread]: I/console log: "RESULTS-DONE"

Interpretation: attacker JS at origin http://127.0.0.1:38742 read video.error.message == "403: Forbidden-SECRET-42" — the status line (including a server-chosen secret reason phrase) of the cross-origin resource http://localhost:38742/victim.mp3 — via a same-origin 302 redirector. The direct cross-origin control load of the identical victim URL returned the redacted "Failed to open media", proving the NoSupportedMediaSourceError redaction gate works for direct loads and is bypassed specifically by the redirect.
Attached file adversarial.md —
Attached file test.html —
Attached file prefs.json —
Attached file leaksrv.py —
Attached patch fix.patch — — Splinter Review
Attached file crash_stack.txt —
Attached file README.md —
Attached file prefs.js —
Group: core-security → media-core-security
Assignee: nobody → alwu
Attached file (secure) —
Attached file (secure) —

:alwu, please update all release status flags to reflect the affected/unaffected/disabled state correctly. Which branches (beta, release, and/or ESR) are affected by this flaw?

Flags: needinfo?(alwu)
Whiteboard: [reminder-test 2026-08-20]
Attached file (secure) —
Attachment #9621349 - Flags: approval-mozilla-beta?

firefox-beta Uplift Approval Request

  • User impact if declined/Reason for urgency: Sec bug
  • Code covered by automated testing?: yes
  • Fix verified in Nightly?: yes
  • Needs manual QE testing?: no
  • Steps to reproduce for manual QE testing:
  • Risk associated with taking this patch: low
  • Explanation of risk level: It's about adding proper principle check No new feature or behavior change.
  • String changes made/needed?: No
  • Is Android affected?: yes
Attached file (secure) —
Attachment #9621350 - Flags: approval-mozilla-esr153?

firefox-esr153 Uplift Approval Request

  • User impact if declined/Reason for urgency: Sec bug
  • Code covered by automated testing?: yes
  • Fix verified in Nightly?: yes
  • Needs manual QE testing?: no
  • Steps to reproduce for manual QE testing:
  • Risk associated with taking this patch: low
  • Explanation of risk level: It's about adding proper principle check No new feature or behavior change.
  • String changes made/needed?: No
  • Is Android affected?: yes
Attached file (secure) —
Attachment #9621355 - Flags: approval-mozilla-esr140?

firefox-esr140 Uplift Approval Request

  • User impact if declined/Reason for urgency: Sec bug
  • Code covered by automated testing?: yes
  • Fix verified in Nightly?: yes
  • Needs manual QE testing?: no
  • Steps to reproduce for manual QE testing:
  • Risk associated with taking this patch: low
  • Explanation of risk level: It's about adding proper principle check No new feature or behavior change.
  • String changes made/needed?: No
  • Is Android affected?: yes
Pushed by alwu@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/9389b9ac9cef https://hg.mozilla.org/integration/autoland/rev/06b6b2feb049 Base media load-error message redaction on the final loaded resource. r=media-playback-reviewers,azebrowski
Group: media-core-security → core-security-release
Status: UNCONFIRMED → RESOLVED
Closed: 3 months ago
Resolution: --- → FIXED
Target Milestone: --- → 155 Branch
Attachment #9621349 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Attachment #9621350 - Flags: approval-mozilla-esr153? → approval-mozilla-esr153+
Attachment #9621355 - Flags: approval-mozilla-esr140? → approval-mozilla-esr140+
QA Whiteboard: [sec] [uplift] [qa-triage-done-c155/b154]
Whiteboard: [reminder-test 2026-08-20] → [reminder-test 2026-08-20][adv-main154+r][adv-esr53.1+r][adv-esr140.14+r]
Whiteboard: [reminder-test 2026-08-20][adv-main154+r][adv-esr53.1+r][adv-esr140.14+r] → [reminder-test 2026-08-20][adv-main154+r][adv-esr153.1+r][adv-esr140.14+r]
Blocks: xs-leaks
Keywords: csectype-sop
Whiteboard: [reminder-test 2026-08-20][adv-main154+r][adv-esr153.1+r][adv-esr140.14+r] → [reminder-test 2026-08-20][adv-main154+][adv-esr153.1+][adv-esr140.14+]
Alias: CVE-2026-74967

a month ago, alwu placed a reminder on the bug using the whiteboard tag [reminder-test 2026-08-20] .

alwu, please refer to the original comment to better understand the reason for the reminder.

Flags: needinfo?(alwu)
Whiteboard: [reminder-test 2026-08-20][adv-main154+][adv-esr153.1+][adv-esr140.14+] → [adv-main154+][adv-esr153.1+][adv-esr140.14+]
Pushed by alwu@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/02d5cff4efae https://hg.mozilla.org/integration/autoland/rev/481369427ce6 Add test for media load-error message redaction across a redirect. r=media-playback-reviewers,azebrowski
Flags: needinfo?(alwu)
Group: core-security-release
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: