CVE-2025-61927: CWE-94: Improper Control of Generation of Code ('Code Injection') in capricorn86 happy-dom
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.
AI Analysis
Technical Summary
Happy DOM is a JavaScript implementation of a web browser environment without a graphical interface, commonly used in Node.js applications for DOM manipulation and testing. Versions prior to 20.0.0 contain a critical security vulnerability (CVE-2025-61927) classified as CWE-94 (Improper Control of Generation of Code). The root cause is that the Node.js VM Context, which Happy DOM uses to execute JavaScript, is not a fully isolated sandbox. This allows malicious JavaScript code executed inside the VM Context to escape the sandbox restrictions and gain access to the underlying Node.js process environment. Specifically, in CommonJS module systems, attackers can access the require() function, enabling them to load arbitrary modules and execute arbitrary code on the host system, resulting in remote code execution (RCE). The vulnerability is worsened by the fact that JavaScript evaluation is enabled by default in Happy DOM, which may not be obvious to developers using the library. This default setting increases the risk that untrusted or malicious scripts could be executed inadvertently. The patch in Happy DOM version 20.0.0 addresses the issue by disabling JavaScript evaluation by default, thereby reducing the attack surface. The CVSS 4.0 score of 7.2 reflects a high severity, considering the network attack vector, low attack complexity, and the requirement for privileges and user interaction. Although no known exploits have been reported in the wild, the potential for exploitation exists, especially in environments where untrusted JavaScript code is processed. The vulnerability impacts confidentiality, integrity, and availability due to the possibility of arbitrary code execution on the host system. Organizations using Happy DOM in their Node.js environments should prioritize upgrading to the patched version and review their usage of JavaScript evaluation within VM contexts to prevent exploitation.
Potential Impact
For European organizations, this vulnerability poses a significant risk, particularly for those leveraging Happy DOM in development, testing, or server-side rendering environments where untrusted JavaScript code might be executed. Successful exploitation could lead to remote code execution, allowing attackers to compromise sensitive data, manipulate application logic, or disrupt services. This could affect confidentiality by exposing sensitive information, integrity by allowing unauthorized code execution or data tampering, and availability by enabling denial-of-service attacks through system compromise. Industries with high reliance on Node.js applications, such as financial services, e-commerce, and technology sectors, are especially vulnerable. Additionally, organizations involved in software development or continuous integration pipelines using Happy DOM may inadvertently expose their infrastructure. The risk is amplified if attackers gain initial access through phishing or insider threats, as some privileges and user interaction are required. The lack of known exploits currently provides a window for proactive mitigation, but the widespread use of Node.js and JavaScript-based tools in Europe means the potential impact is broad and critical if exploited.
Mitigation Recommendations
1. Upgrade all instances of Happy DOM to version 20.0.0 or later, where JavaScript evaluation is disabled by default, effectively mitigating the vulnerability. 2. Audit all Node.js applications and development pipelines to identify where Happy DOM is used, especially in contexts that execute untrusted or external JavaScript code. 3. Implement strict code review and validation processes to prevent untrusted code execution within Happy DOM VM contexts. 4. Where possible, isolate execution environments further by using containerization or sandboxing technologies that provide stronger isolation than Node.js VM Contexts. 5. Disable or restrict the use of CommonJS modules in environments where untrusted code execution is necessary, or switch to ESM modules with careful evaluation of their security implications. 6. Monitor application logs and system behavior for unusual activity indicative of code injection or sandbox escape attempts. 7. Educate developers and DevOps teams about the risks of enabling JavaScript evaluation by default and the importance of secure configuration. 8. Apply principle of least privilege to Node.js processes running Happy DOM to limit the potential damage from exploitation. 9. Stay informed about updates or patches from the Happy DOM project and related Node.js security advisories.
Affected Countries
Germany, United Kingdom, France, Netherlands, Sweden, Finland, Denmark, Ireland, Belgium, Poland
CVE-2025-61927: CWE-94: Improper Control of Generation of Code ('Code Injection') in capricorn86 happy-dom
Description
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.
AI-Powered Analysis
Technical Analysis
Happy DOM is a JavaScript implementation of a web browser environment without a graphical interface, commonly used in Node.js applications for DOM manipulation and testing. Versions prior to 20.0.0 contain a critical security vulnerability (CVE-2025-61927) classified as CWE-94 (Improper Control of Generation of Code). The root cause is that the Node.js VM Context, which Happy DOM uses to execute JavaScript, is not a fully isolated sandbox. This allows malicious JavaScript code executed inside the VM Context to escape the sandbox restrictions and gain access to the underlying Node.js process environment. Specifically, in CommonJS module systems, attackers can access the require() function, enabling them to load arbitrary modules and execute arbitrary code on the host system, resulting in remote code execution (RCE). The vulnerability is worsened by the fact that JavaScript evaluation is enabled by default in Happy DOM, which may not be obvious to developers using the library. This default setting increases the risk that untrusted or malicious scripts could be executed inadvertently. The patch in Happy DOM version 20.0.0 addresses the issue by disabling JavaScript evaluation by default, thereby reducing the attack surface. The CVSS 4.0 score of 7.2 reflects a high severity, considering the network attack vector, low attack complexity, and the requirement for privileges and user interaction. Although no known exploits have been reported in the wild, the potential for exploitation exists, especially in environments where untrusted JavaScript code is processed. The vulnerability impacts confidentiality, integrity, and availability due to the possibility of arbitrary code execution on the host system. Organizations using Happy DOM in their Node.js environments should prioritize upgrading to the patched version and review their usage of JavaScript evaluation within VM contexts to prevent exploitation.
Potential Impact
For European organizations, this vulnerability poses a significant risk, particularly for those leveraging Happy DOM in development, testing, or server-side rendering environments where untrusted JavaScript code might be executed. Successful exploitation could lead to remote code execution, allowing attackers to compromise sensitive data, manipulate application logic, or disrupt services. This could affect confidentiality by exposing sensitive information, integrity by allowing unauthorized code execution or data tampering, and availability by enabling denial-of-service attacks through system compromise. Industries with high reliance on Node.js applications, such as financial services, e-commerce, and technology sectors, are especially vulnerable. Additionally, organizations involved in software development or continuous integration pipelines using Happy DOM may inadvertently expose their infrastructure. The risk is amplified if attackers gain initial access through phishing or insider threats, as some privileges and user interaction are required. The lack of known exploits currently provides a window for proactive mitigation, but the widespread use of Node.js and JavaScript-based tools in Europe means the potential impact is broad and critical if exploited.
Mitigation Recommendations
1. Upgrade all instances of Happy DOM to version 20.0.0 or later, where JavaScript evaluation is disabled by default, effectively mitigating the vulnerability. 2. Audit all Node.js applications and development pipelines to identify where Happy DOM is used, especially in contexts that execute untrusted or external JavaScript code. 3. Implement strict code review and validation processes to prevent untrusted code execution within Happy DOM VM contexts. 4. Where possible, isolate execution environments further by using containerization or sandboxing technologies that provide stronger isolation than Node.js VM Contexts. 5. Disable or restrict the use of CommonJS modules in environments where untrusted code execution is necessary, or switch to ESM modules with careful evaluation of their security implications. 6. Monitor application logs and system behavior for unusual activity indicative of code injection or sandbox escape attempts. 7. Educate developers and DevOps teams about the risks of enabling JavaScript evaluation by default and the importance of secure configuration. 8. Apply principle of least privilege to Node.js processes running Happy DOM to limit the potential damage from exploitation. 9. Stay informed about updates or patches from the Happy DOM project and related Node.js security advisories.
For access to advanced analysis and higher rate limits, contact root@offseq.com
Technical Details
- Data Version
- 5.1
- Assigner Short Name
- GitHub_M
- Date Reserved
- 2025-10-03T22:21:59.616Z
- Cvss Version
- 4.0
- State
- PUBLISHED
Threat ID: 68e96415b83e3429f324341a
Added to database: 10/10/2025, 7:52:53 PM
Last enriched: 10/10/2025, 7:53:14 PM
Last updated: 10/11/2025, 3:21:57 AM
Views: 6
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Related Threats
CVE-2025-9560: CWE-79 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') in extendthemes Colibri Page Builder
MediumCVE-2025-11380: CWE-862 Missing Authorization in everestthemes Everest Backup – WordPress Cloud Backup, Migration, Restore & Cloning Plugin
MediumCVE-2025-54654: CWE-264 Permissions, Privileges, and Access Controls in Huawei HarmonyOS
MediumCVE-2025-11590: SQL Injection in CodeAstro Gym Management System
MediumDeepfake Awareness High at Orgs, But Cyber Defenses Badly Lag
HighActions
Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.
Need enhanced features?
Contact root@offseq.com for Pro access with improved analysis and higher rate limits.