Happy DOM CVE-2025-61927
HIGHAttack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
AccessSubmit untrusted HTML/JS to app
-
DeliveryContent rendered in Happy DOM VM context
-
ExploitEscape VM via constructor chain to process
-
ExecutionObtain require()/child_process (CommonJS)
-
ImpactExecute commands and exfiltrate secrets
Vulnerability Assessment
| Weakness |
CWE
OWASP Top 10:2025
A05:2025 - Injection
ASVS 5.0
V1 - Encoding and Sanitization Code injection prevention, sandbox exec
MITRE ATT&CK
2 techniques across 2 tactics: Execution, Initial Access The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up. |
| Exploitation Conditions | The consuming application must pass attacker-controlled HTML or JavaScript into a Happy DOM Window (e.g. document.write(), innerHTML, or SSR of user-supplied content) while JavaScript evaluation is enabled - which is the DEFAULT in v19 and lower, so no explicit opt-in is needed by the victim application. Capability depends on the module system: under CommonJS the attacker reaches the require() function for arbitrary module import and full RCE (child_process, fs), while under ESM the escape yields the process object but not require/import, limiting but not eliminating impact. Key LIMITING factors: the vulnerability is NOT triggerable against Happy DOM in isolation - it requires an application that actually evaluates untrusted content; it is absent once upgraded to v20.0.0 (JS eval off by default); and worst-case module-import RCE is specific to CommonJS runtimes. |
| Impact | Signals are mixed and point to a conditional rather than broadly-exploitable risk. The vendor CVSS 4.0 base score is 7.2 (High) with vector AV:N/AC:L/AT:P/PR:H/UI:A - the AT:P (attack requirement present), PR:H and UI:A metrics explicitly encode that meaningful preconditions must be met, namely that the host application deliberately runs untrusted JavaScript inside Happy DOM. EPSS is low-to-moderate at 0.64% (49th percentile), the CVE is NOT on the CISA KEV list, and there is no evidence of active exploitation, so the 'confirmed actively exploited' bar is not met. However, the GitHub Security Advisory (GHSA-37j7-fg3j-429f) ships complete, working proof-of-concept reproduction code for both CommonJS and ESM, so publicly available exploit code exists and the technical barrier to weaponization is low once the vulnerable integration pattern is present. Net: this is a real, patch-worthy issue (full process-level RCE on CommonJS deployments that render untrusted content) but it is NOT a drop-everything, internet-wide mass-exploitation event - risk is concentrated in applications that feed untrusted HTML/JS into Happy DOM (SSR of user content, or test suites running untrusted fixtures). Note a signal tension: the vendor vector marks PR:H (operator/config dependency), yet the actual attacker supplying malicious content typically needs no application credentials - the PR:H reflects the integrating application's responsibility, not an authentication gate on the attacker; verify against your specific deployment. |
| Exploit ScenarioDerived | A Node.js application uses Happy DOM (v19 or lower, default settings) to server-render or test HTML that includes attacker-controlled content, e.g. window.document.write(userControlledHTML). Because JavaScript evaluation is enabled by default and the VM Context is not truly isolated, the attacker's injected <script> reaches out through this.constructor.constructor('return process')() to grab the Node process object; on CommonJS it then obtains require() for full module access. Working PoC code for exactly this is published in the GHSA advisory, so exploitation is straightforward wherever untrusted content flows into Happy DOM. |
Get an e-mail when this CVE is exploited, patched or re-scored. Free account.
Alert meAnalysisAIv1 – Oct 08, 2026
VM context escape in Happy DOM 19.x and earlier allows attacker-controlled JavaScript executed inside a Window to break out of the Node.js VM context and reach process-level functionality; on CommonJS runtimes the escaped code can obtain the require() function, yielding arbitrary module import and full remote code execution, while on ESM the escape yields the process object without require/import. Because JavaScript evaluation is enabled by default in v19 and lower, any application that feeds untrusted HTML or script into a Window (document.write(), innerHTML, or server-side rendering of user-supplied content) is exposed without opting in, and untrusted code does not need to be executed by the victim deliberately. There is no confirmed active exploitation (CISA KEV) and no public exploit weaponization flagged, though the vendor advisory publishes working reproduction snippets; EPSS is low at 0.64% (49th percentile), and the vendor-released patch is Happy DOM 20.0.0, which disables JavaScript evaluation by default.
RemediationAI
Primary fix: upgrade the happy-dom npm dependency to 20.0.0 or later, which disables JavaScript evaluation by default and emits a warning if JavaScript is enabled in what the vendor considers an insecure environment (npm/happy-dom fixed in 20.0.0; advisory https://github.com/capricorn86/happy-dom/security/advisories/GHSA-37j7-fg3j-429f; fix commit https://github.com/capricorn86/happy-dom/commit/819d15ba289495439eda8be360d92a614ce22405, with an additional commit at https://github.com/capricorn86/happy-dom/commit/de438ad72921c69793584aa657b48d3655dfac97). If upgrading is not immediately possible, explicitly disable script evaluation when constructing a Window via the settings object, and for @happy-dom/server-renderer use the renamed CLI flag --browser.disableJavaScriptEvaluation (the old disableJavascriptEvaluation spelling was replaced) - the trade-off is that any test or SSR fixture that depends on executing page scripts will break, which is precisely the behavior the default change intends. Independently, launch the Node.js process with --disallow-code-generation-from-strings, which blocks eval and Function-from-string escapes such as this.constructor.constructor('return process')(); the side effect is that legitimate dynamic code generation from strings anywhere in that process also fails, which is why the vendor applied it per worker in the server-renderer package and added --browser.suppressCodeGenerationFromStringsWarning to quiet the resulting notice. Architecturally, never pass attacker-controlled HTML or JavaScript into a Window and instead sanitize/escape it, and treat any Happy DOM execution of untrusted content as untrusted code by isolating it in a separate process or container with minimal privileges - on CommonJS this matters most, since require() access converts the escape into arbitrary command execution and filesystem reach. Verify via dependency scanning that no transitive dependency still resolves happy-dom < 20.0.0, since the vulnerable behavior is a default, not an API that must be called.
Affected Packages
Source: OSV (Open Source Vulnerabilities)
Affects your stack
Affects 1 package in npm
Checking this CVE against your own stacks and servers is part of the Basic plan and up.
Technical ContextAI · show details
Happy DOM is a JavaScript browser implementation for Node.js that constructs a Window and evaluates page scripts inside a Node.js vm context. The Node.js vm module is explicitly not a security boundary - code running in a context can climb back to the host realm through classic constructor-chain pivots such as this.constructor.constructor('return process')() - so the design flaw is not a memory-safety bug but CWE-94 (Improper Control of Generation of Code), i.e. evaluating untrusted code with host-level capabilities. Impact is asymmetric by module system: under CommonJS the recovered process object exposes process.mainModule.require, enabling require('child_process'), require('fs'), and arbitrary module loading (full RCE), whereas under ESM the process object is reachable but require/import are not, capping the escape at process metadata and related primitives. The fix commit (819d15ba289495439eda8be360d92a614ce22405) flips the default of the JavaScript-evaluation setting, renames the server-renderer flag from disableJavascriptEvaluation to enableJavaScriptEvaluation, adds a suppressCodeGenerationFromStringsWarning option, and hardens the @happy-dom/server-renderer workers with Node's --disallow-code-generation-from-strings flag. Note the nuance that the server-renderer package deliberately keeps enableJavaScriptEvaluation: true by default (its purpose is rendering client-side JavaScript), relying on the worker-level --disallow-code-generation-from-strings restriction instead - so v20 users of that package are not automatically protected by the new default alone. The assessed CVSS 3.1 vector (AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:H) treats this as unauthenticated with no user interaction and scope change, while the vendor-published CVSS 4.0 vector lists PR:H/UI:A; the assessed vector is the one reflected here.
Know when Node.js gets its next vulnerability
- Watch products and get an email when something new is published
- Check this CVE against your own stack and servers
- Exploit and PoC references, threat intelligence from 22 sources
No credit card · 7-day full trial
Severity by source
CVSS:4.0/AV:N/AC:L/AT:P/PR:H/UI:A/VC:L/VI:H/VA:H/SC:H/SI:H/SA:H
AC:H because exploitation depends on the host app rendering untrusted JS (attacker-uncontrolled condition); PR:N/UI:N as the attacker merely supplies content; S:C and C/I/A:H reflect VM-escape to full host-process RCE.
Primary rating from Vendor (github).
CVSS VectorVendor: github
DescriptionCVE.org
Happy DOM is a JavaScript implementation of a web browser without its graphical user interface. Happy DOM v19 and lower contains a security vulnerability that puts the owner system at the risk of RCE (Remote Code Execution) attacks. A Node.js VM Context is not an isolated environment, and if the user runs untrusted JavaScript code within the Happy DOM VM Context, it may escape the VM and get access to process level functionality. It seems like what the attacker can get control over depends on if the process is using ESM or CommonJS. With CommonJS the attacker can get hold of the require() function to import modules. Happy DOM has JavaScript evaluation enabled by default. This may not be obvious to the consumer of Happy DOM and can potentially put the user at risk if untrusted code is executed within the environment. Version 20.0.0 patches the issue by changing JavaScript evaluation to be disabled by default.
Executive ViewAI
Happy DOM, a headless JavaScript DOM implementation widely embedded in server-side rendering pipelines, test harnesses, and content sanitization tooling, contains a sandbox escape affecting version 19.x and earlier that lets attacker-supplied JavaScript reach Node.js process-level capabilities and, on CommonJS runtimes, import and execute arbitrary modules. Because script evaluation is on by default, any team that renders untrusted HTML or user-submitted script through a Window is exposed without having opted in, meaning the engineering organization, its CI/CD infrastructure, and any customers whose content flows through those services carry the exposure. Leadership should treat this as a critical remediation priority owned jointly by application engineering and platform security, since successful exploitation converts a content-handling feature into full server-side code execution.
Apply vendor patch.
Threat Intelligence Overview
How this decision was reached
The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.
What every action level means
SSVC AssessmentENISA
Priority Score
Attack Technique
Code injection occurs when an application accepts user input and passes it directly into a language interpreter or evaluator without proper sanitization.
Remote Code Execution represents the critical moment when an attacker successfully runs arbitrary code on a target system without physical access.
Remote code execution in n8n's workflow expression evaluation system allows an authenticated user with workflow creation
A vulnerability in the NuPoint Unified Messaging (NPM) component of Mitel MiCollab through 9.8 SP1 FP2 (9.8.1.201) could
FortiOS and FortiProxy contain an authentication bypass via the Node.js websocket module allowing unauthenticated remote
Denial of service against HTTP/2 server implementations allows remote unauthenticated attackers to exhaust server resour
Eval injection vulnerability in the internals.batch function in lib/batch.js in the bassmaster plugin before 1.5.2 for t
Flowise version 3.0.5 contains a remote code execution vulnerability in the CustomMCP node. The mcpServerConfig paramete
Node.js 8.5.0 before 8.6.0 allows remote attackers to access unintended files, because a change to ".." handling was inc
An issue was discovered in the node-serialize package 0.0.4 for Node.js. Rated critical severity (CVSS 9.8), this vulner
OpenSSL before 0.9.8za, 1.0.0 before 1.0.0m, and 1.0.1 before 1.0.1h does not properly restrict processing of ChangeCiph
Directory traversal vulnerability in the st module before 0.2.5 for Node.js allows remote attackers to read arbitrary fi
Multiple SQL injection vulnerabilities in the Manage Accounts page in the AccountManagement.asmx service in the Solarwin
The JS-YAML module before 2.0.5 for Node.js parses input without properly considering the unsafe !!js/function tag, whic
NVD
CVE.org
EPSS
GitHub
Exploit-DB