High firefox Logic Error 🔧 Commit mapped

Overview

High
Severity
—
CVSS
No
Exploited ITW
Fixed
Fix Status
Impacthigh
DescriptionIncorrect boundary conditions in the SVG component
ComponentLayout
Bug ClassLogic Error
Tracker2079938
Fix commita12d1f77df06 (firefox) +24/-4
CISA KEVNot listed
CreditedMozilla
Disclosed2026-10-20

Files Changed

  • layout/base/nsCSSFrameConstructor.cpp
  • testing/web-platform/tests/css/css-display/display-contents-svg-pseudo-crash.html
diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp
index c961a95763f..c6db978bcac 100644
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -4981,12 +4981,13 @@ nsCSSFrameConstructor::FindElementData(const Element& aElement,
                                        ItemFlags aFlags) {
   // Don't create frames for non-SVG element children of SVG elements.
   if (!aElement.IsSVGElement()) {
-    // NOTE: Anon content is allowed, the native code should know what it's
-    // doing. In practice we care about ::backdrop and the
-    // custom-content-container.
+    // NOTE: Anon content (from non display: contents) is allowed, the native
+    // code should know what it's doing. In practice we care about ::backdrop
+    // and the custom-content-container.
     if (aParentFrame && IsFrameForSVG(aParentFrame) &&
         !aParentFrame->IsSVGForeignObjectFrame() &&
-        !aElement.IsRootOfNativeAnonymousSubtree()) {
+        (aElement.GetParent() != aParentFrame->GetContent() ||
+         !aElement.IsRootOfNativeAnonymousSubtree())) {
       return nullptr;
     }
     if (aFlags.contains(ItemFlag::IsWithinSVGText)) {
diff --git a/testing/web-platform/tests/css/css-display/display-contents-svg-pseudo-crash.html b/testing/web-platform/tests/css/css-display/display-contents-svg-pseudo-crash.html
new file mode 100644
index 00000000000..8ac48961e98
--- /dev/null
+++ b/testing/web-platform/tests/css/css-display/display-contents-svg-pseudo-crash.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<style>
+g { display: contents; }
+g::before { content: "cap"; display: table-caption; }
+</style>
+<svg id=root width=300 height=300><g id=g></g></svg>
+<script>
+onload = () => {
+  document.documentElement.offsetWidth;
+  let r = document.createElementNS("http://www.w3.org/2000/svg", "rect");
+  r.setAttribute("width", 100);
+  r.setAttribute("height", 100);
+  r.style.filter = "blur(2px)";
+  g.appendChild(r);
+  document.documentElement.offsetWidth;
+  root.style.textShadow = "2px 2px red";
+  document.documentElement.offsetWidth;
+};
+</script>
Loading diff…

Regression Test / PoC

shipped with the fix
diff --git a/testing/web-platform/tests/css/css-display/display-contents-svg-pseudo-crash.html b/testing/web-platform/tests/css/css-display/display-contents-svg-pseudo-crash.html
new file mode 100644
index 00000000000..8ac48961e98
--- /dev/null
+++ b/testing/web-platform/tests/css/css-display/display-contents-svg-pseudo-crash.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<style>
+g { display: contents; }
+g::before { content: "cap"; display: table-caption; }
+</style>
+<svg id=root width=300 height=300><g id=g></g></svg>
+<script>
+onload = () => {
+  document.documentElement.offsetWidth;
+  let r = document.createElementNS("http://www.w3.org/2000/svg", "rect");
+  r.setAttribute("width", 100);
+  r.setAttribute("height", 100);
+  r.style.filter = "blur(2px)";
+  g.appendChild(r);
+  document.documentElement.offsetWidth;
+  root.style.textShadow = "2px 2px red";
+  document.documentElement.offsetWidth;
+};
+</script>
Loading diff…