CVE-2026-33943: 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. In versions 15.10.0 through 20.8.7, a code injection vulnerability in `ECMAScriptModuleCompiler` allows an attacker to achieve Remote Code Execution (RCE) by injecting arbitrary JavaScript expressions inside `export { }` declarations in ES module scripts processed by happy-dom. The compiler directly interpolates unsanitized content into generated code as an executable expression, and the quote filter does not strip backticks, allowing template literal-based payloads to bypass sanitization. Version 20.8.8 fixes the issue.
AI Analysis
Technical Summary
Happy DOM is a JavaScript library that simulates a web browser environment without a graphical user interface, often used for server-side rendering, testing, or automation. Versions 15.10.0 through 20.8.7 contain a critical code injection vulnerability (CWE-94) in the ECMAScriptModuleCompiler module. This component compiles ES module scripts and processes export declarations. The vulnerability stems from the compiler directly interpolating unsanitized user-controlled JavaScript expressions inside export { } statements. The sanitization mechanism, specifically the quote filter, does not remove backticks (`), which allows attackers to craft payloads using template literals that bypass filtering. By injecting malicious JavaScript expressions, an attacker can achieve remote code execution (RCE) within the context where happy-dom is used. Exploitation requires user interaction (e.g., supplying malicious module scripts) but no prior authentication, making it accessible to remote attackers. The vulnerability impacts confidentiality, integrity, and availability by enabling arbitrary code execution, potentially leading to data theft, system compromise, or denial of service. The issue was fixed in version 20.8.8 by properly sanitizing input and preventing unsafe code interpolation. No known exploits are currently reported in the wild, but the high CVSS score (8.8) reflects the severity and ease of exploitation.
Potential Impact
This vulnerability allows remote attackers to execute arbitrary JavaScript code in environments using vulnerable versions of happy-dom, potentially leading to full system compromise. Organizations relying on happy-dom for server-side rendering, automated testing, or any backend JavaScript execution are at risk of data breaches, unauthorized access, and service disruption. The attack could be leveraged to pivot within networks, deploy malware, or exfiltrate sensitive information. Because happy-dom is used in development and CI/CD pipelines, compromised environments could lead to supply chain risks affecting downstream applications. The lack of authentication requirement and network attack vector increases the threat surface. The vulnerability's impact spans confidentiality, integrity, and availability, making it critical for organizations to address promptly.
Mitigation Recommendations
The primary mitigation is to upgrade happy-dom to version 20.8.8 or later, where the vulnerability is patched. Organizations should audit their codebases and dependencies to identify usage of affected versions. If immediate upgrade is not feasible, restrict access to environments running happy-dom to trusted users and networks to reduce exposure. Implement input validation and sanitization on any user-supplied module scripts processed by happy-dom. Employ runtime application self-protection (RASP) or sandboxing techniques to limit the impact of potential code execution. Monitor logs and network traffic for suspicious activity related to module compilation or unexpected code execution. Incorporate static and dynamic code analysis tools to detect unsafe code injection patterns. Finally, educate developers about secure coding practices to prevent injection flaws in custom extensions or integrations.
Affected Countries
United States, Germany, India, Japan, United Kingdom, Canada, Australia, France, Netherlands, South Korea
CVE-2026-33943: 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. In versions 15.10.0 through 20.8.7, a code injection vulnerability in `ECMAScriptModuleCompiler` allows an attacker to achieve Remote Code Execution (RCE) by injecting arbitrary JavaScript expressions inside `export { }` declarations in ES module scripts processed by happy-dom. The compiler directly interpolates unsanitized content into generated code as an executable expression, and the quote filter does not strip backticks, allowing template literal-based payloads to bypass sanitization. Version 20.8.8 fixes the issue.
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
Happy DOM is a JavaScript library that simulates a web browser environment without a graphical user interface, often used for server-side rendering, testing, or automation. Versions 15.10.0 through 20.8.7 contain a critical code injection vulnerability (CWE-94) in the ECMAScriptModuleCompiler module. This component compiles ES module scripts and processes export declarations. The vulnerability stems from the compiler directly interpolating unsanitized user-controlled JavaScript expressions inside export { } statements. The sanitization mechanism, specifically the quote filter, does not remove backticks (`), which allows attackers to craft payloads using template literals that bypass filtering. By injecting malicious JavaScript expressions, an attacker can achieve remote code execution (RCE) within the context where happy-dom is used. Exploitation requires user interaction (e.g., supplying malicious module scripts) but no prior authentication, making it accessible to remote attackers. The vulnerability impacts confidentiality, integrity, and availability by enabling arbitrary code execution, potentially leading to data theft, system compromise, or denial of service. The issue was fixed in version 20.8.8 by properly sanitizing input and preventing unsafe code interpolation. No known exploits are currently reported in the wild, but the high CVSS score (8.8) reflects the severity and ease of exploitation.
Potential Impact
This vulnerability allows remote attackers to execute arbitrary JavaScript code in environments using vulnerable versions of happy-dom, potentially leading to full system compromise. Organizations relying on happy-dom for server-side rendering, automated testing, or any backend JavaScript execution are at risk of data breaches, unauthorized access, and service disruption. The attack could be leveraged to pivot within networks, deploy malware, or exfiltrate sensitive information. Because happy-dom is used in development and CI/CD pipelines, compromised environments could lead to supply chain risks affecting downstream applications. The lack of authentication requirement and network attack vector increases the threat surface. The vulnerability's impact spans confidentiality, integrity, and availability, making it critical for organizations to address promptly.
Mitigation Recommendations
The primary mitigation is to upgrade happy-dom to version 20.8.8 or later, where the vulnerability is patched. Organizations should audit their codebases and dependencies to identify usage of affected versions. If immediate upgrade is not feasible, restrict access to environments running happy-dom to trusted users and networks to reduce exposure. Implement input validation and sanitization on any user-supplied module scripts processed by happy-dom. Employ runtime application self-protection (RASP) or sandboxing techniques to limit the impact of potential code execution. Monitor logs and network traffic for suspicious activity related to module compilation or unexpected code execution. Incorporate static and dynamic code analysis tools to detect unsafe code injection patterns. Finally, educate developers about secure coding practices to prevent injection flaws in custom extensions or integrations.
Technical Details
- Data Version
- 5.2
- Assigner Short Name
- GitHub_M
- Date Reserved
- 2026-03-24T19:50:52.104Z
- Cvss Version
- 3.1
- State
- PUBLISHED
Threat ID: 69c6f6ca3c064ed76ff81bae
Added to database: 3/27/2026, 9:29:46 PM
Last enriched: 3/27/2026, 9:45:34 PM
Last updated: 3/27/2026, 11:02:14 PM
Views: 5
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.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.