Happy DOM: Code injection via unsanitized import alias in ESM compiler
Summary
Happy DOM, a JavaScript implementation of a web browser without a graphical user interface, does not validate named ESM import aliases before generating code. If JavaScript evaluation is enabled, attacker-controlled HTML or module source can inject code that runs in the Node.js host process. This is an incomplete fix for CVE-2026-33943 that affects a separate code path.
Affected
- happy-dom from 17.0.0 up to but not including 21.0.4
- Unknown whether any 20.x release is affected or fixed; no 20.x fix has been published.
Fixed in
- Fixed in happy-dom 21.0.4.
Workaround
- Set enableJavaScriptEvaluation to false when processing untrusted HTML or when scripts are not needed.
- Run happy-dom in isolated, least-privilege containers or sandboxes when handling untrusted content.
- No vendor-published workaround beyond these; vendor guidance is to upgrade.
Exploitation
- A public proof of concept is referenced in the advisory, but sources conflict on its status; not verified.
- Exploitation in the wild: no evidence found. Not checked against the CISA KEV catalogue.
- CISA SSVC: exploitation PoC, not automatable, total technical impact.
- Prerequisites: JavaScript evaluation enabled and attacker-controlled HTML or module content reaching happy-dom; user interaction required.
Our recommendation
- Identify all happy-dom installations, direct and transitive, using npm ls happy-dom, lockfiles and SBOMs.
- Prioritise production services that render or scrape untrusted HTML with JavaScript evaluation enabled.
- Upgrade to 21.0.4 or later and test the 21.x major version change, which alters default behaviour.
- Until upgraded, disable JavaScript evaluation for untrusted content and isolate affected runners.
- Development-only installations on CI runners and developer machines that process untrusted content should also be patched.
Public exploits
PoC-in-GitHub, Metasploit and Exploit-DB list nothing for this CVE.
Research sources
- GitHub Security Advisory GHSA-834v-8h66-3h79 github.com
- Happy DOM release v21.0.4 github.com
- Fix commit fd16352 github.com
- Pull request #2537 github.com
- OSV entry CVE-2026-115895 osv.dev
- GitLab advisory CVE-2026-115895 advisories.gitlab.com
Researched and written up in English and German by an AI (Claude by Anthropic) based on NVD, CISA, EPSS and the sources listed. The vendor information is authoritative. Researched on 31 Oct 2026, 10:38.
Original description (NVD)
Happy DOM is a JavaScript implementation of a web browser without its graphical user interface. From 17.0.0 until 21.0.4, packages/happy-dom/src/module/ECMAScriptModuleCompiler.ts accepts a named ESM import alias without validating that it is a JavaScript binding identifier before inserting it into a generated destructuring binding. With enableJavaScriptEvaluation enabled, attacker-controlled HTML or module source can use an invalid alias that becomes a valid default initializer after compilation, causing the generated JavaScript to execute in the Node.js host process. The demonstrated reachable path uses a JSON module import attribute, which prevents the malicious alias from being emitted again in a later ESM circular-import assignment and keeps the generated function syntactically valid. This incomplete fix for CVE-2026-33943 is a distinct residual path because the earlier remediation validated the local export importName path but not the named-import alias. This issue is fixed in version 21.0.4.
NVD references (5)
- https://github.com/capricorn86/happy-dom/commit/fd163520b74d9fa146be91f7b4e4f46d6cccbe13
- https://github.com/capricorn86/happy-dom/pull/2537
- https://github.com/capricorn86/happy-dom/releases/tag/v21.0.4
- https://github.com/capricorn86/happy-dom/security/advisories/GHSA-834v-8h66-3h79
- https://github.com/capricorn86/happy-dom/security/advisories/GHSA-834v-8h66-3h79
Sources
The tracker combines official, freely usable data sources – updated continuously:
- NVD (NIST) – CVEs, rating (CVSS), affected products
- CISA KEV – vulnerabilities confirmed by CISA as actively exploited
- CISA Vulnrichment – CISA assessment (SSVC) in the official CVE record
- FIRST EPSS – probability of exploitation
- Microsoft MSRC – Patch Tuesday: vulnerabilities, severity, updates
- PoC-in-GitHub – public proof-of-concept repositories
- Metasploit (Rapid7) – modules of the Metasploit Framework
- Exploit-DB (OffSec) – archive of public exploits (links only)
- Patch days: official vendor pages (linked per vendor) (Vendor patch days)
This product uses data from the NVD API but is not endorsed or certified by the NVD. EPSS data © FIRST.org.
Affected? We can help.
We check whether your systems are affected, install updates and close the gap – continuously with the System Health Checker if you wish.
