Skip to content
Info disclosure Disclosed report Advanced CVE-2026-3846

Cross-origin CSS rule disclosure and redirect URL leak via mOriginClean reset in StyleSheetInfo clone

A cross-origin stylesheet's origin-clean flag was not copied when Firefox cloned a shared stylesheet object, so the clone defaulted to being treated as same-origin. An attacker could then read the cross-origin CSS rules and, if the sheet was reached through a redirect, leak the redirect destination URL.

varde Follow

Originally disclosed on Mozilla

  • Fixed in 6 days
  • Paid in 12 days
  • Disclosed after 6 days

Created attachment 9546996 poc.html

Cross-origin CSS rule disclosure and redirect URL leak via mOriginClean reset in StyleSheetInfo clone

Summary

A cross-origin stylesheet's origin-clean flag can be reset by triggering StyleSheetInfo's copy constructor, which does not copy the mOriginClean field. When two <link> elements load the same cross-origin CSS URL, the SharedStyleSheetCache deduplicates them into a shared StyleSheetInfo inner. Modifying the sheet's MediaList (e.g. via sheet.media.appendMedium()) calls WillDirty() -> EnsureUniqueInner(), which clones the shared inner. The clone's mOriginClean defaults to true (the field initializer), bypassing the CSSOM origin-clean check. This allows reading cross-origin CSS rules and, when the stylesheet was loaded through a redirect, leaking the redirect destination URL via @import insertion.

This is a variant of CVE-2025-31205 (WebKit cross-site CSS rule and redirect URL disclosure, https://project-zero.issues.chromium.org/issues/408172161), affecting Firefox through a different mechanism but with overlapping impact.

Root Cause

StyleSheetInfo (layout/style/StyleSheetInfo.h) declares mOriginClean with a default member initializer of true:

bool mOriginClean = true;  // line 47

The copy constructor (layout/style/StyleSheet.cpp:349-367) copies mCORSMode, mIntegrity, mSourceMapURL, and mContents, but does NOT copy mOriginClean:

StyleSheetInfo::StyleSheetInfo(StyleSheetInfo& aCopy, StyleSheet* aPrimarySheet)
    : mCORSMode(aCopy.mCORSMode),
      mIntegrity(aCopy.mIntegrity),
      mSourceMapURL(aCopy.mSourceMapURL),
      mContents(Servo_StyleSheet_Clone(...).Consume())
{
  AddSheet(aPrimarySheet);
}

Since mOriginClean is absent from the initializer list, it takes its default value of true in the cloned inner, regardless of the original's value.

Attack Chain

  1. Load a cross-origin stylesheet via <link> (no CORS). The loader sets mOriginClean = false on the sheet's StyleSheetInfo inner (Loader.cpp:669).

  2. Load the same URL via a second <link>. SharedStyleSheetCache deduplicates: CreateSheet() finds a cache hit and returns Clone(), which shares the same StyleSheetInfo inner. The inner's mSheets now has length > 1, so HasUniqueInner() returns false.

  3. Modify the sheet's media attribute: sheet.media.appendMedium('screen'). MediaList::DoMediaChange() (MediaList.cpp:50) calls mStyleSheet->WillDirty() with no origin check. WillDirty() calls EnsureUniqueInner() (StyleSheet.cpp:491). Since the inner is shared, CloneFor() creates a new StyleSheetInfo via the copy constructor -- mOriginClean is NOT copied and defaults to true.

  4. The sheet now has a unique inner with mOriginClean = true. AreRulesAvailable() (StyleSheet.cpp:928) passes, granting full CSSOM access: sheet.cssRules, insertRule(), deleteRule() all become available.

Suggested Fix

Copy mOriginClean in the StyleSheetInfo copy constructor:

Diff
    StyleSheetInfo::StyleSheetInfo(StyleSheetInfo& aCopy, StyleSheet* aPrimarySheet)
        : mCORSMode(aCopy.mCORSMode),
          mIntegrity(aCopy.mIntegrity),
+         mOriginClean(aCopy.mOriginClean),
          mSourceMapURL(aCopy.mSourceMapURL),
          mContents(Servo_StyleSheet_Clone(...).Consume())

Tested Version

Firefox 147.0.4 (release), source analysis on mozilla-central commit f8345be3cabc.

The original report as published on Mozilla's Bugzilla, by varde. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The StyleSheetInfo copy constructor omits mOriginClean from its initialiser list, so a cloned inner takes the default value of true instead of inheriting the original's value.

Impact

A page could read cross-origin CSS rules and, when the stylesheet was loaded through a redirect, could leak the redirect destination URL.

What the attacker needed

Victim visits attacker page; attacker controls a cross-origin CSS URL; two link elements to the same URL

The fix

The copy constructor should copy mOriginClean from the original so the clone keeps the correct origin-clean state.

How it was found

  1. Load a cross-origin stylesheet through a link element without CORS, which marks it as not origin-clean.
  2. Load the same URL through a second link element so the shared cache deduplicates them into one shared inner.
  3. Change the sheet's media list, which triggers a clone of the shared inner.
  4. The clone defaults to origin-clean, so the page can now read the CSS rules and insert rules.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

Browsers normally stop a page from reading the contents of a stylesheet hosted on another site, using a flag that marks it as not safe to read. Here, when Firefox made a copy of a shared stylesheet object, it forgot to copy that flag, so the copy looked safe and the page could read the other site's CSS. CSS can contain sensitive things, and the address a stylesheet was redirected to can also be sensitive.

What is Info disclosure?

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.

More by varde

View all

3 more disclosed reports, best first.

More from Mozilla

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.