Closed Bug 2007302 (CVE-2026-24868) Opened 7 months ago Closed 7 months ago

CSP strict-dynamic bypass via shimmed Disqus embed code

Categories

(Core :: Privacy: Anti-Tracking, defect, P1)

defect

Tracking

()

VERIFIED FIXED
148 Branch
Tracking Status
firefox-esr115 --- unaffected
firefox-esr140 --- unaffected
firefox146 --- wontfix
firefox147 + verified
firefox148 + verified

People

(Reporter: masatokinugawa, Assigned: emz)

References

(Regression)

Details

(4 keywords, Whiteboard: [client-bounty-form][adv-main147.0.2+])

Attachments

(3 files)

Summary

This is a similar bug to Bug 1909241. When Firefox's Strict Enhanced Tracking Protection is enabled, certain tracking contents are shimmed.
Disqus embed code is one of them. When Firefox detects the Disqus embed code, loading is blocked until the user explicitly allows it. This unblocking process can be abused to bypass CSP strict-dynamic. It allows an attacker to execute arbitrary JavaScript even if the page has strict CSP rules.

Steps to reproduce

  1. Open https://vulnerabledoma.in/fx_csp_bypass_strict-dynamic_disqus.html with Strict Enhanced Tracking Protection enabled. This page contains strict CSP rules:
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'nonce-random' 'strict-dynamic';  [...]">
  1. Click on the Allow on vulnerabledoma.in button.
  2. Click on the Allow Disqus toggle button. An alert dialog will pop up.

Root cause

This querySelector call incorrectly selects a non-Disqus script:
https://searchfox.org/firefox-main/rev/2fd8beb47a8fd1a767e35a987dff4e0ec2536245/browser/extensions/webcompat/shims/disqus-embed.js#13-15
In the PoC case, <script src="data:,alert(document.domain)//.disqus.com/embed.js"></script> is retrieved wrongly.

After loading is allowed via the toggle button, the script is loaded via the following createElement(), bypassing strict-dynamic:
https://searchfox.org/firefox-main/rev/2fd8beb47a8fd1a767e35a987dff4e0ec2536245/browser/extensions/webcompat/lib/smartblock_embeds_helper.js#52-58

Flags: sec-bounty?
Group: firefox-core-security → core-security
Component: Security → Privacy: Anti-Tracking
Keywords: regression
Product: Firefox → Core
Regressed by: 1965307

Set release status flags based on info from the regressing bug 1965307

:emz, since you are the author of the regressor, bug 1965307, could you take a look? Also, could you set the severity field?

For more information, please visit BugBot documentation.

Assignee: nobody → emz
Status: NEW → ASSIGNED
Severity: -- → S2
Flags: needinfo?(emz)
Priority: -- → P1

I can reproduce. To address this we most likely want to properly inspect the src value using JS. We can parse it as a URL first and then do checks on it. We could make the query selector more strict, but that could be bypassed too.

We shouldn't even be looking at the wrong script URLs of course, but we could also think about injecting the scripts in a way that the page's CSP (and other policies like the Integrity-Policy) apply.

Edit: Actually this might be complicated for cases where the original script tag has a nonce.

(In reply to Tom Schuster (MoCo) [PTO Dec 23 - Jan 4] from comment #3)

We shouldn't even be looking at the wrong script URLs of course, but we could also think about injecting the scripts in a way that the page's CSP (and other policies like the Integrity-Policy) apply.

Right, so I'm surprised that injecting the script like here: https://searchfox.org/firefox-main/rev/2fd8beb47a8fd1a767e35a987dff4e0ec2536245/browser/extensions/webcompat/lib/smartblock_embeds_helper.js#52-58 doesn't enforce CSP. It's possible that the comment about the principal is wrong.

Group: core-security → dom-core-security
Attached file (secure)

I've attached a patch that is more strict about which script URIs it picks. We should also fix the CSP bypass issue itself, I'm still looking into that.

Group: dom-core-security → core-security-release
Status: ASSIGNED → RESOLVED
Closed: 7 months ago
Resolution: --- → FIXED
Target Milestone: --- → 148 Branch

The patch landed in nightly and beta is affected.
:emz, is this bug important enough to require an uplift?

For more information, please visit BugBot documentation.

Flags: needinfo?(emz)
Attached file (secure)
Attachment #9536673 - Flags: approval-mozilla-beta?

firefox-beta Uplift Approval Request

  • User impact if declined: Sites can trick Firefox into injecting custom scripts (via our shim embed logic) which bypasses strict-dynamic CSP.
  • Code covered by automated testing: no
  • Fix verified in Nightly: yes
  • Needs manual QE test: yes
  • Steps to reproduce for manual QE testing: See https://bugzilla.mozilla.org/show_bug.cgi?id=2007302#c0
  • Risk associated with taking this patch: low
  • Explanation of risk level: Fairly small code change. The updated code only runs when tracking protection is enabled and when the user visits a site with Disqus embeds.
  • String changes made/needed: no
  • Is Android affected?: yes
Flags: qe-verify+
Flags: needinfo?(emz)
Attachment #9536673 - Flags: approval-mozilla-beta? → approval-mozilla-release?
QA Whiteboard: [uplift][qa-ver-needed-c148/b147]

I've repro this issue with the STR from comment 0, on an affected Nightly build (2025-12-21).

The issue is verified as fixed on latest Nightly 148.0a1 under Win 11, macOS 26.1 and Ubuntu 24.04.

QA Whiteboard: [uplift][qa-ver-needed-c148/b147] → [uplift][qa-ver-done-c148/b147]
Flags: qe-verify+
QA Contact: cgeorgiu
Flags: sec-bounty? → sec-bounty+
Attachment #9536673 - Flags: approval-mozilla-release? → approval-mozilla-release+
QA Whiteboard: [uplift][qa-ver-done-c148/b147] → [uplift][qa-ver-done-c148/b147][qa-ver-needed-c149/b148]
Flags: qe-verify+

This bug is also verified as fixed on Firefox 147.0.2 under Win 11, macOS 26 and Ubuntu 24.

Status: RESOLVED → VERIFIED
QA Whiteboard: [uplift][qa-ver-done-c148/b147][qa-ver-needed-c149/b148] → [uplift][qa-ver-done-c148/b147][qa-ver-done-c149/b148]
Flags: qe-verify+
Whiteboard: [client-bounty-form] → [client-bounty-form][adv-main147+]
Alias: CVE-2026-24868
Whiteboard: [client-bounty-form][adv-main147+] → [client-bounty-form][adv-main147.0.2+]
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: