Repository navigation
chore(deps): update dependency happy-dom to v21 [security] - #799
renovate[bot] wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
28c27b3 to
99213bb
Compare
99213bb to
32a8aa6
Compare
32a8aa6 to
cea5fef
Compare
cea5fef to
7789894
Compare
7789894 to
1551142
Compare
1551142 to
b7186fa
Compare
This PR contains the following updates:
^20.11.1→^21.0.0^20.9.0→^21.0.0Happy DOM: Incomplete fix for CVE-2026-33943: unsanitized import alias leads to host code execution
CVE-2026-115895 / GHSA-834v-8h66-3h79
More information
Details
Summary
The ESM compiler in
happy-dom@20.14.5does not validate imported local binding aliases before interpolating them into generated JavaScript.As a result, an invalid ESM import alias can be transformed into a valid JavaScript destructuring default initializer and executed.
This appears to be an alternate injection path and incomplete remediation of GHSA-6q6h-j7hj-3r64 / CVE-2026-33943. The previous fix validates
importNamein the localexport { ... }handler, but the named import handler still places an unvalidatedaliasdirectly into code context.These issues were confirmed through the public
Windowand<script type="module">APIs using the publishedhappy-domnpm package. The PoC reaches the Node.js hostprocess, obtainsnode:fs, and creates a proof directory on the host filesystem.Confirmed affected versions
The PoC was directly tested against:
happy-dom@17.0.0happy-dom@20.0.0happy-dom@20.1.0happy-dom@20.14.5The same PoC does not trigger on
happy-dom@16.8.1.The ESM compiler was introduced by commit
7bc831df2, first released inv17.0.0. The vulnerable interpolation remains present throughv20.14.5, the latest release at the time of testing.Suggested affected range:
No patched version is currently available.
Preconditions
enableJavaScriptEvaluation: true.Technical details
In
packages/happy-dom/src/module/ECMAScriptModuleCompiler.ts, the named import handler splits an import specifier and extracts its alias:Unlike the patched
export { ... }handler, the value ofaliasis not validated as a JavaScript identifier.It is subsequently inserted directly into generated binding syntax:
Consider the following source:
This is invalid ECMAScript module syntax. Node.js rejects it at the
=token.Happy DOM instead transforms it into the equivalent of:
This generated JavaScript is valid. Because the imported JSON object does not contain a
missingproperty, the default initializer executes.The
with { type: 'json' }attribute is relevant because the compiler only generates its circular import resolver for ESM imports:Using a JSON module prevents the malicious alias from being emitted again in a later circular-import assignment, leaving the generated function syntactically valid.
Backtick strings also survive the existing quote removal. This allows the injected initializer to reach Node.js host APIs:
Proof of concept
The following PoC uses only the public Happy DOM API and performs a harmless filesystem action by creating a directory named
HAPPY_DOM_RCE_PROOF.1. Create
package.json{ "name": "happy-dom-import-alias-rce-poc", "private": true, "type": "module", "dependencies": { "happy-dom": "20.14.5" } }2. Create
dep.json{}3. Create
payload.mjsThis file is used as a control to demonstrate that a native ECMAScript parser rejects the source:
4. Create
poc.mjs5. Run the control test
Expected result:
This confirms that the source is not valid ESM.
6. Run the Happy DOM PoC
node poc.mjsExpected result:
The existence of
HAPPY_DOM_RCE_PROOFconfirms that the expression injected through the import alias executed and reached the host filesystem.The PoC was also verified inside a
node:24-alpineDocker container, where it created:Impact
An attacker who can supply module source to an application that evaluates JavaScript through Happy DOM can cause syntactically invalid import declarations to be transformed into executable JavaScript.
This may bypass upstream syntax validation or application assumptions that malformed import clauses will be rejected.
The demonstrated payload reaches Node.js
processand built-in modules. It can therefore be adapted to read or modify files, access environment data, or execute operating-system commands with the privileges of the Happy DOM host process.Relationship to CVE-2026-33943
CVE-2026-33943 covers expression injection through a local export declaration:
Its fix added identifier validation to the
importNameused by theexport { ... }handler:This report uses a different parsing and code-generation path:
The unvalidated value is the local import
alias, and the injection occurs in a generated destructuring binding rather than the export assignment patched by CVE-2026-33943.The issue remains reproducible in versions released after the CVE-2026-33943 fix, including
20.14.5.Suggested fix
Validate the imported local binding before placing it into code context. The existing
VALID_VARIABLE_NAME_REGEXPcan be reused:A regression test should compile and execute the malicious import declaration, then verify that the initializer was not evaluated.
This change was tested locally. The focused
ECMAScriptModuleCompilertest suite passes with 30 tests, and ESLint reports no errors.For additional hardening, generated property keys should use
JSON.stringify()instead of manual quote interpolation.Verification record
24.14.1happy-dom@20.14.5v20.14.50d4cdbe7442af49d16b49ddf1acf7cc9684ed31817.0.016.8.1Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:HReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Release Notes
capricorn86/happy-dom (happy-dom)
v21.0.4Compare Source
👷♂️ Patch fixes
data:iframes cannot access their parent or top window - By @capricorn86v21.0.3Compare Source
👷♂️ Patch fixes
v21.0.2Compare Source
👷♂️ Patch fixes
v21.0.1Compare Source
👷♂️ Patch fixes
--cssand--iframefor enabling CSS and iframe loading to @happy-dom/server-renderer - By @capricorn86v21.0.0Compare Source
💣 Breaking Changes
<iframe>or<link rel="stylesheet">elements in untrusted HTML to make Happy DOM send HTTP requests from the server to attacker-chosen URLs, including internal services. This could allow access to otherwise unreachable endpoints or trigger unintended actions, depending on the application and its network access.disableCSSFileLoadinghas been deprecated<=v20.14.6by sending in{ enableCSSFileLoading: true, enableIframePageLoading: true }as broswer settings (e.g.new Window({ settings }));v20.14.6Compare Source
👷♂️ Patch fixes
v20.14.5Compare Source
👷♂️ Patch fixes
v20.14.4Compare Source
👷♂️ Patch fixes
v20.14.3Compare Source
👷♂️ Patch fixes
v20.14.2Compare Source
👷♂️ Patch fixes
getComputedStyle()- By @klaesra in task #2344v20.14.1Compare Source
👷♂️ Patch fixes
v20.14.0Compare Source
🎨 Features
v20.13.2Compare Source
👷♂️ Patch fixes
v20.13.1Compare Source
👷♂️ Patch fixes
v20.13.0Compare Source
🎨 Features
v20.12.2Compare Source
👷♂️ Patch fixes
v20.12.1Compare Source
🎨 Features
CSSStyleDeclaration- By @capricorn86 in task #2256CSSStyleDeclaration- By @capricorn86 in task #2256👷♂️ Patch fixes
v20.12.0Compare Source
🎨 Features
Animation,AnimationTimeline,DocumentTimelineandKeyframeEffect- By @capricorn86Element.animate()- By @capricorn86v20.11.15Compare Source
👷♂️ Patch fixes
v20.11.14Compare Source
👷♂️ Patch fixes
v20.11.13Compare Source
👷♂️ Patch fixes
v20.11.12Compare Source
👷♂️ Patch fixes
v20.11.11Compare Source
👷♂️ Patch fixes
v20.11.10Compare Source
👷♂️ Patch fixes
v20.11.9Compare Source
👷♂️ Patch fixes
v20.11.8Compare Source
👷♂️ Patch fixes
adoptedStyleSheetarray should be validated - By @capricorn86 in task #2315v20.11.7Compare Source
👷♂️ Patch fixes
Document.adoptedStyleSheetsandShadowRoot.adoptedStyleSheetsshould validate it's value - By @capricorn86 in task #2313v20.11.6Compare Source
👷♂️ Patch fixes
v20.11.5Compare Source
👷♂️ Patch fixes
querySelector<HTMLInputElement>(".my-input")) - By @cyphercodesv20.11.4Compare Source
👷♂️ Patch fixes
fetch()to match origins instead of host and protocol - By @rexxars in task #1490v20.11.3Compare Source
👷♂️ Patch fixes
Configuration
📅 Schedule: (UTC)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about these updates again.
This PR was generated by Mend Renovate. View the repository job log.