Hi all,
this issue is specific to bookworm (bad fix backport). Here is a
proposed debdiff. OK to push to bookworm-security ?
-------- Message transféré --------
Sujet : [Pkg-javascript-devel] Bug#1155077: node-dompurify: sanitize()
throws "ReferenceError: shadowNode is not defined" on all HTML input
Date de renvoi : Mon, 23 Nov 2026 20:53:01 +0000
De (renvoi) : Oreofe Solarin <[email protected]>
Pour (renvoi) : [email protected]
Copie (renvoi) : [email protected],
[email protected]
Date : Mon, 23 Nov 2026 15:52:06 -0500
De : Oreofe Solarin <[email protected]>
Répondre à : Oreofe Solarin <[email protected]>,
[email protected]
Pour : [email protected]
Package: node-dompurify
Version: 2.4.1+dfsg+~2.4.0-2+deb12u1
Severity: grave
Justification: renders package unusable
X-Debbugs-Cc: [email protected] <mailto:[email protected]>
Dear Maintainer,
The security update 2.4.1+dfsg+~2.4.0-2+deb12u1 (bookworm, "Fix
prototype pollutions (Closes: CVE-2024-45801, CVE-2024-48910)")
introduced a regression that makes DOMPurify.sanitize() throw on any
input containing markup.
The previous version, 2.4.1+dfsg+~2.4.0-2, sanitizes the same inputs
correctly.
Reproduction
------------
# apt install node-dompurify node-jsdom
$ node -e '
const { JSDOM } = require("jsdom");
const DOMPurify =
require("/usr/share/nodejs/dompurify/dist/purify.cjs.js")(new
JSDOM("").window);
console.log(DOMPurify.sanitize("<b>hello</b>"));
'
Expected: <b>hello</b>
Actual: ReferenceError: shadowNode is not defined
at .../dompurify/dist/purify.cjs.js:1358
Every input with markup throws (<b>hello</b>, <div><p>x</p></div>,
<img src=x onerror=...>, an HTML comment). Only markup-free plain text
survives, because sanitize() returns before the faulty line is reached.
dist/purify.min.js is affected identically.
Root cause
----------
debian/patches/CVE-2024-45801.patch backports upstream commit 26e1d69.
Upstream adds a numberIsNaN() guard to two existing "nested too deeply"
depth checks: one on `shadowNode` inside the function
_sanitizeShadowDOM(), and one on `currentNode` inside
DOMPurify.sanitize(). In the 2.4.x source the second hunk landed in the
wrong function. It matched on the `_forceRemove(body.firstChild)`
context in sanitize() and replaced the
FORCE_BODY block there with the shadowNode check:
@@ -1484,8 +1485,14 @@
- /* Remove first element node (ours) if FORCE_BODY is set */
- if (body && FORCE_BODY) {
+ /*
+ * Remove an element if nested too deeply to avoid mXSS
+ * or if the __depth might have been tampered with
+ */
+ if (
+ shadowNode.__depth >= MAX_NESTING_DEPTH ||
+ numberIsNaN(shadowNode.__depth)
+ ) {
_forceRemove(body.firstChild);
}
`shadowNode` is a local variable declared only in _sanitizeShadowDOM(),
so in sanitize() it is undefined and the reference throws. In the built
bundle:
_sanitizeShadowDOM() var shadowNode;
dist/purify.cjs.js:1208
DOMPurify.sanitize() function (dirty) {
dist/purify.cjs.js:1262
the faulty line if (shadowNode.__depth >= ...)
dist/purify.cjs.js:1358
Three consequences of the mislocation:
1. sanitize() throws on all markup (shadowNode out of scope);
2. the FORCE_BODY handling in sanitize() is deleted;
3. the depth check this hunk was meant for -- the real one in
_sanitizeShadowDOM() at dist/purify.cjs.js:1236,
`if (shadowNode.__depth >= MAX_NESTING_DEPTH)` -- was never
upgraded with
the numberIsNaN() guard, so CVE-2024-45801 is not actually fixed
on the
shadow-DOM path.
The patch's other two hunks (the numberIsNaN import, and the `currentNode`
guard in sanitize()) are applied correctly.
Impact
------
node-dompurify is a sanitiser; in this build it is unusable for its
purpose. A consumer that does not wrap sanitize() in a try/catch
crashes; one that does catch fails closed (no sanitised output). Either
way the package does not do its job, and the CVE-2024-45801 fix is
incomplete.
Suggested fix
-------------
Rework CVE-2024-45801.patch so the shadowNode guard is applied to the
existing check in _sanitizeShadowDOM() (the `if (shadowNode.__depth >=
MAX_NESTING_DEPTH)` line) rather than to the FORCE_BODY block in
sanitize(), and restore the FORCE_BODY block. The currentNode hunk needs
no change. Equivalent to carrying upstream 2.5.1 commit 26e1d69 onto the
2.4.x tree at the correct anchors.
Affected: bookworm, 2.4.1+dfsg+~2.4.0-2+deb12u1 (the highest 2.x version, so
the one `apt` installs).
Not affected: 2.4.1+dfsg+~2.4.0-2 (in bookworm-security, but
lower-versioned);
trixie/sid on the 3.x line.
Thanks,
Oreofe.
diff --git a/debian/changelog b/debian/changelog
index e9a5528..caa3f74 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
+node-dompurify (2.4.1+dfsg+~2.4.0-2+deb12u2) bookworm-security; urgency=medium
+
+ * Fix regression in the CVE-2024-45801 patch: the numberIsNaN() guard was
+ applied to the FORCE_BODY block in sanitize() instead of the shadow-DOM
+ depth check, making sanitize() throw a ReferenceError on any markup and
+ leaving the shadow-DOM path unfixed (Closes: #1155077)
+
+ -- Yadd <[email protected]> Tue, 24 Nov 2026 15:07:00 +0100
+
node-dompurify (2.4.1+dfsg+~2.4.0-2+deb12u1) bookworm; urgency=medium
* Fix prototype pollutions (Closes: CVE-2024-45801, CVE-2024-48910)
diff --git a/debian/patches/CVE-2024-45801.patch
b/debian/patches/CVE-2024-45801.patch
index 3aa90c4..4b8629a 100644
--- a/debian/patches/CVE-2024-45801.patch
+++ b/debian/patches/CVE-2024-45801.patch
@@ -5,8 +5,9 @@ Origin: upstream,
https://github.com/cure53/DOMPurify/commit/26e1d69c
Bug:
https://github.com/cure53/DOMPurify/security/advisories/GHSA-mmhx-hmjr-r674
Forwarded: not-needed
Applied-Upstream: 2.5.1, https://github.com/cure53/DOMPurify/commit/26e1d69c
+Bug-Debian: https://bugs.debian.org/1155077
Reviewed-By: Yadd <[email protected]>
-Last-Update: 2024-10-30
+Last-Update: 2026-11-24
--- a/src/purify.js
+++ b/src/purify.js
@@ -18,22 +19,22 @@ Last-Update: 2024-10-30
regExpTest,
typeErrorCreate,
lookupGetter,
-@@ -1484,8 +1485,14 @@
+@@ -1352,8 +1353,14 @@
+ }
}
- }
-- /* Remove first element node (ours) if FORCE_BODY is set */
-- if (body && FORCE_BODY) {
-+ /*
-+ * Remove an element if nested too deeply to avoid mXSS
-+ * or if the __depth might have been tampered with
-+ */
-+ if (
-+ shadowNode.__depth >= MAX_NESTING_DEPTH ||
-+ numberIsNaN(shadowNode.__depth)
-+ ) {
- _forceRemove(body.firstChild);
- }
+- /* Remove an element if nested too deeply to avoid mXSS */
+- if (shadowNode.__depth >= MAX_NESTING_DEPTH) {
++ /*
++ * Remove an element if nested too deeply to avoid mXSS
++ * or if the __depth might have been tampered with
++ */
++ if (
++ shadowNode.__depth >= MAX_NESTING_DEPTH ||
++ numberIsNaN(shadowNode.__depth)
++ ) {
+ _forceRemove(shadowNode);
+ }
@@ -1520,8 +1527,14 @@
}