Skip to content
XSS Disclosed report Advanced CVE-2026-6771

CSP strict-dynamic bypass: XSLT loads exempt from strict-dynamic enforcement, allowing same-origin stylesheet loading when host sources should be ignored

Firefox's CSP implementation exempts XSLT stylesheet loads from strict-dynamic enforcement, so host-based sources such as 'self' are still evaluated for them even though the spec says they should be ignored. An attacker who can inject an xml-stylesheet processing instruction into an XML document could therefore load a same-origin XSLT that restructures the page for phishing or content injection, though it cannot run JavaScript.

Rayhan Hanaputra Follow

Originally disclosed on Mozilla

  • Fixed in 7 days
  • Paid in 19 days
  • Disclosed after 7 days

Created attachment 9555802 attachment_6_csp_xslt_bypass.txt

Discovery

  • Method: Manual source code audit of dom/security/nsCSPUtils.cpp CSP evaluation logic
  • Firefox version: mozilla-central trunk, affects all current versions
  • OS: All platforms

Root Cause

At dom/security/nsCSPUtils.cpp:1342-1344, XSLT loads are explicitly exempted from strict-dynamic enforcement:

C++
// XXX I don't think we should apply strict-dynamic to XSLT.
if (hasStrictDynamicKeyword && aLoadInfo->InternalContentPolicyType() !=
                                     nsIContentPolicy::TYPE_XSLT) {
    // Step 1.4.1  If the request's parser metadata is "parser-inserted",
    // return "Blocked". Otherwise, return "Allowed".
    if (aLoadInfo->GetParserCreatedScript()) {
        return false;  // blocked
    }
    return true;  // allowed
}

When a request has TYPE_XSLT, this entire block is skipped. Execution falls through to lines 1360-1365:

C++
for (uint32_t i = 0; i < mSrcs.Length(); i++) {
    if (mSrcs[i]->permits(aUri, aWasRedirected, aReportOnly,
                          aUpgradeInsecure)) {
        return true;  // XSLT allowed by host-based source matching
    }
}

This evaluates host-based source expressions like 'self' against the XSLT URL. Per the CSP Level 3 specification, when strict-dynamic is present, host-based sources should be ignored for script-like requests. But the XSLT exemption causes them to be evaluated.

XSLT is Treated as Script for CSP

This is not a case of XSLT being outside CSP scope. Line 321-322 explicitly maps XSLT to the script-src directive:

C++
// BLock XSLT as script, see bug 910139
case nsIContentPolicy::TYPE_XSLT:
case nsIContentPolicy::TYPE_SCRIPT:
    return nsIContentSecurityPolicy::SCRIPT_SRC_DIRECTIVE;

So XSLT loads are governed by script-src, and strict-dynamic applies to script-src, but the exemption at line 1342 creates an inconsistency.

The Developer Was Uncertain

The XXX comment ("I don't think we should apply strict-dynamic to XSLT") indicates this was a deliberate but uncertain decision. The CSP3 spec does not explicitly carve out an exception for XSLT.

Attack Scenario

Consider an XML API endpoint with CSP: script-src 'strict-dynamic' 'nonce-abc123' 'self'

Per the CSP3 spec, 'self' should be ignored when strict-dynamic is present. But due to the XSLT exemption:

  1. Attacker finds an injection point in an XML document (e.g., reflected content in an XML API response)
  2. Attacker injects: <?xml-stylesheet type="text/xsl" href="/path/to/attacker-uploaded.xsl"?>
  3. The XSLT load check: TYPE_XSLT -> skips strict-dynamic block -> falls to source matching -> 'self' matches -> ALLOWED
  4. The XSLT stylesheet loads and transforms the entire page content

Impact

The loaded XSLT can:

  • Completely restructure the page -- replace all visible content with attacker-controlled HTML
  • Phishing -- display a fake login form that looks like the legitimate site
  • Content injection -- insert misleading information, fake error messages, etc.
  • CSS-based data exfiltration -- use CSS selectors to leak page data to an external server via background-image URLs

The XSLT cannot execute JavaScript -- scripts in XSLT output are created with FROM_PARSER_XSLT (line 483 of txMozillaXMLOutput.cpp), which is treated as parser-inserted and blocked by strict-dynamic. So this is content injection, not full XSS.

Limitations

  • Requires an XML document (not HTML) -- the <?xml-stylesheet?> processing instruction is only valid in XML
  • Requires the CSP to include both strict-dynamic AND a host-based source like 'self' (this is a common migration pattern)
  • The XSL file must be on an allowed host (e.g., same-origin for 'self')
  • Scripts in XSLT output are still blocked by strict-dynamic

Steps to Reproduce

  1. Serve an XML page with CSP: Content-Security-Policy: script-src 'strict-dynamic' 'nonce-test' 'self'
  2. The XML page includes: <?xml-stylesheet type="text/xsl" href="transform.xsl"?>
  3. transform.xsl is a same-origin XSLT that restructures the page
  4. Expected (per spec): XSLT load blocked (strict-dynamic ignores 'self')
  5. Actual: XSLT loads and transforms the page content

Suggested Fix

Remove the XSLT exemption and let strict-dynamic apply uniformly:

C++
// Remove the TYPE_XSLT exception:
if (hasStrictDynamicKeyword) {
    if (aLoadInfo->GetParserCreatedScript()) {
        return false;
    }
    return true;
}

If XSLT needs special handling, it should be parser-inserted (blocked) since <?xml-stylesheet?> is parser-inserted by definition. This would make the behavior consistent with the spec and with how Firefox treats scripts under strict-dynamic.

The original report as published on Mozilla's Bugzilla, by Rayhan Hanaputra. 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

Likely a deliberate but uncertain exemption in the CSP evaluation code skips the strict-dynamic check for XSLT loads, letting them fall through to host-based source matching that the spec says should be ignored.

Impact

The loaded XSLT could restructure the page, show a fake login form for phishing, inject misleading content, or leak page data through CSS, but it cannot execute JavaScript because scripts in XSLT output are still blocked by strict-dynamic.

What the attacker needed

An XML document, not HTML; CSP has strict-dynamic plus a host source; attacker can inject an xml-stylesheet instruction; XSL file hosted on an allowed origin

The fix

The XSLT exemption should be removed so strict-dynamic applies uniformly, or XSLT loads should be treated as parser-inserted and blocked.

How it was found

  1. Serve an XML page with a CSP that has strict-dynamic, a nonce and 'self'.
  2. The XML page references a same-origin XSLT stylesheet via an xml-stylesheet processing instruction.
  3. The XSLT loads and transforms the page, where the spec says it should be blocked.

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.

A Content Security Policy is a rule set a website sends to the browser saying which scripts and styles it may load. The strict-dynamic keyword is meant to make the browser ignore older host-based rules like 'self' and only trust scripts that a trusted script created. This report found that Firefox still applies the old host-based rules to XSLT stylesheets, which are files that reshape an XML page, so a page that should be locked down can still be restyled by an attacker who can inject a stylesheet reference.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

More from Mozilla

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.