happy-dom

Ecosystem: npm

Downloads: 104.83 Mln

Vulnerabilities from the last (months)
  • 3CriticalAffects 3 versions
  • 4HighAffects 4 versions
  • 0MediumAffects 0 versions
  • 1ModerateAffects 1 version
  • 0LowAffects 0 versions
Severity distribution (all time)
8vulnerabilities
  • Critical3 (37.5%)
  • High4 (50.0%)
  • Medium0 (0.0%)
  • Moderate1 (12.5%)
  • Low0 (0.0%)

Monthly breakdown

  • Critical
  • High
  • Medium
  • Moderate
  • Low
  • 3 vulnerabilities
    • Critical: 0
    • High: 2
    • Medium: 0
    • Moderate: 1
    • Low: 0
  • 2 vulnerabilities
    • Critical: 0
    • High: 2
    • Medium: 0
    • Moderate: 0
    • Low: 0
  • 2 vulnerabilities
    • Critical: 2
    • High: 0
    • Medium: 0
    • Moderate: 0
    • Low: 0
  • 1 vulnerabilities
    • Critical: 1
    • High: 0
    • Medium: 0
    • Moderate: 0
    • Low: 0

Vulnerabilities (8)

Known vulnerabilities affecting happy-dom, based on data from OSV.

Vulnerabilities affecting happy-dom
IDSeveritySummaryAffected versionsPublishedSource
GHSA-5fpq-26gf-qwcrModerateHappy DOM has cookie scope forgery: no DNS-label boundary on Domain= matching , attacker origin sets victim cookies### Summary A cookie-scoping bug in happy-dom lets an attacker origin set cookies that a victim origin then receives, diverging from browser semantics. ### Details happy-dom matches Domain=example.com against notexample.com (endsWith without a DNS-label boundary), diverging from browser semantics (verified 20.11.6 npm latest: cookieMatchesURL(Domain=example.com, url=http://notexample.com) = true). Relevant where happy-dom is used for SSR/prerender cookie handling. Matching in src/cookie/CookieContainer.ts. ### PoC Run: ```bash node poc-happydom-cookie-domain.js ``` Full proof-of-concept so
  • < 20.14.6
GitHub (opens in a new tab)
GHSA-c8p4-j97h-3vg8HighHappy DOM: SSRF via iframe and link stylesheet when parsing untrusted HTML## Summary happy-dom v20.8.9 makes real server-side HTTP requests to arbitrary URLs when parsing HTML containing `<iframe>` or `<link rel="stylesheet">` elements. This behavior is enabled by default (`disableIframePageLoading: false`, `disableCSSFileLoading: false`). When an application uses happy-dom to parse untrusted HTML on the server side, an attacker can trigger Server-Side Request Forgery by embedding these elements. ## Affected Versions - happy-dom <= 20.8.9 (latest) ## Vulnerable Behavior By default, happy-dom has: - `disableIframePageLoading: false` — iframes fetch their `src` URL
  • < 21.0.0
GitHub (opens in a new tab)
GHSA-834v-8h66-3h79HighHappy DOM: Incomplete fix for CVE-2026-33943: unsanitized import alias leads to host code execution## Summary The ESM compiler in `happy-dom@20.14.5` does 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 `importName` in the local `export { ... }` handler, but the named import handler still places an unvalidated `alias` directly into code context. These issues were confir
  • >= 17.0.0, < 21.0.4
GitHub (opens in a new tab)
GHSA-w4gp-fjgq-3q4gHighHappy DOM's fetch credentials include uses page-origin cookies instead of target-origin cookies### Summary `happy-dom` may attach cookies from the current page origin (`window.location`) instead of the request target URL when `fetch(..., { credentials: "include" })` is used. This can leak cookies from origin A to destination B. ### Details In [`packages/happy-dom/src/fetch/utilities/FetchRequestHeaderUtility.ts`](https://github.com/capricorn86/happy-dom/blob/f8d8cad41e9722fab9eefb9dfb3cca696462e908/packages/happy-dom/src/fetch/utilities/FetchRequestHeaderUtility.ts) (`getRequestHeaders()`), cookie selection is performed with `originURL`: ```ts const originURL = new URL(options.window.
  • < 20.8.9
GitHub (opens in a new tab)
GHSA-6q6h-j7hj-3r64HighHappy DOM ECMAScriptModuleCompiler: unsanitized export names are interpolated as executable code### Summary 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. ### Details **Vulnerable file**: `packages/happy-dom/src/module/ECMAScriptModuleCompiler.ts`, lines 371-385 The "Export objec
  • >= 15.10.0, < 20.8.8
GitHub (opens in a new tab)
GHSA-qpm2-6cq5-7pq5Criticalhappy-dom's `--disallow-code-generation-from-strings` is not sufficient for isolating untrusted JavaScript### Summary The mitigation proposed in GHSA-37j7-fg3j-429f for disabling eval/Function when executing untrusted code in happy-dom does not suffice, since it still allows prototype pollution payloads. ### Details The untrusted script and the rest of the application still run in the same Isolate/process, so attackers can deploy prototype pollution payloads to hijack important references like "process" in the example below, or to hijack control flow via flipping checks of undefined property. There might be other payloads that allow the manipulation of require, e.g., via (univeral) gadgets (https
  • >= 19.0.0, < 20.0.2
GitHub (opens in a new tab)
GHSA-37j7-fg3j-429fCriticalHappy DOM: VM Context Escape can lead to Remote Code Execution# Escape of VM Context gives access to process level functionality ## Summary 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 impor
  • < 20.0.0
GitHub (opens in a new tab)
GHSA-96g7-g7g9-jxw8Criticalhappy-dom allows for server side code to be executed by a <script> tag### Impact Consumers of the NPM package `happy-dom` ### Patches The security vulnerability has been patched in v15.10.2 ### Workarounds No easy workarounds to my knowledge ### References [#1585](https://github.com/capricorn86/happy-dom/issues/1585)
  • < 15.10.2
GitHub (opens in a new tab)
  • GHSA-5fpq-26gf-qwcrModerate
    Happy DOM has cookie scope forgery: no DNS-label boundary on Domain= matching , attacker origin sets victim cookies
    • < 20.14.6

    ### Summary A cookie-scoping bug in happy-dom lets an attacker origin set cookies that a victim origin then receives, diverging from browser semantics. ### Details happy-dom matches Domain=example.com against notexample.com (endsWith without a DNS-label boundary), diverging from browser semantics (verified 20.11.6 npm latest: cookieMatchesURL(Domain=example.com, url=http://notexample.com) = true). Relevant where happy-dom is used for SSR/prerender cookie handling. Matching in src/cookie/CookieContainer.ts. ### PoC Run: ```bash node poc-happydom-cookie-domain.js ``` Full proof-of-concept so

    CVE: CVE-2026-118661

  • GHSA-c8p4-j97h-3vg8High
    Happy DOM: SSRF via iframe and link stylesheet when parsing untrusted HTML
    • < 21.0.0

    ## Summary happy-dom v20.8.9 makes real server-side HTTP requests to arbitrary URLs when parsing HTML containing `<iframe>` or `<link rel="stylesheet">` elements. This behavior is enabled by default (`disableIframePageLoading: false`, `disableCSSFileLoading: false`). When an application uses happy-dom to parse untrusted HTML on the server side, an attacker can trigger Server-Side Request Forgery by embedding these elements. ## Affected Versions - happy-dom <= 20.8.9 (latest) ## Vulnerable Behavior By default, happy-dom has: - `disableIframePageLoading: false` — iframes fetch their `src` URL

    CVE: CVE-2026-118660

  • GHSA-834v-8h66-3h79High
    Happy DOM: Incomplete fix for CVE-2026-33943: unsanitized import alias leads to host code execution
    • >= 17.0.0, < 21.0.4

    ## Summary The ESM compiler in `happy-dom@20.14.5` does 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 `importName` in the local `export { ... }` handler, but the named import handler still places an unvalidated `alias` directly into code context. These issues were confir

    CVE: CVE-2026-115895

  • GHSA-w4gp-fjgq-3q4gHigh
    Happy DOM's fetch credentials include uses page-origin cookies instead of target-origin cookies
    • < 20.8.9

    ### Summary `happy-dom` may attach cookies from the current page origin (`window.location`) instead of the request target URL when `fetch(..., { credentials: "include" })` is used. This can leak cookies from origin A to destination B. ### Details In [`packages/happy-dom/src/fetch/utilities/FetchRequestHeaderUtility.ts`](https://github.com/capricorn86/happy-dom/blob/f8d8cad41e9722fab9eefb9dfb3cca696462e908/packages/happy-dom/src/fetch/utilities/FetchRequestHeaderUtility.ts) (`getRequestHeaders()`), cookie selection is performed with `originURL`: ```ts const originURL = new URL(options.window.

    CVE: CVE-2026-34226

  • GHSA-6q6h-j7hj-3r64High
    Happy DOM ECMAScriptModuleCompiler: unsanitized export names are interpolated as executable code
    • >= 15.10.0, < 20.8.8

    ### Summary 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. ### Details **Vulnerable file**: `packages/happy-dom/src/module/ECMAScriptModuleCompiler.ts`, lines 371-385 The "Export objec

    CVE: CVE-2026-33943

  • GHSA-qpm2-6cq5-7pq5Critical
    happy-dom's `--disallow-code-generation-from-strings` is not sufficient for isolating untrusted JavaScript
    • >= 19.0.0, < 20.0.2

    ### Summary The mitigation proposed in GHSA-37j7-fg3j-429f for disabling eval/Function when executing untrusted code in happy-dom does not suffice, since it still allows prototype pollution payloads. ### Details The untrusted script and the rest of the application still run in the same Isolate/process, so attackers can deploy prototype pollution payloads to hijack important references like "process" in the example below, or to hijack control flow via flipping checks of undefined property. There might be other payloads that allow the manipulation of require, e.g., via (univeral) gadgets (https

    CVE: CVE-2025-62410

  • GHSA-37j7-fg3j-429fCritical
    Happy DOM: VM Context Escape can lead to Remote Code Execution
    • < 20.0.0

    # Escape of VM Context gives access to process level functionality ## Summary 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 impor

    CVE: CVE-2025-61927

  • GHSA-96g7-g7g9-jxw8Critical
    happy-dom allows for server side code to be executed by a <script> tag
    • < 15.10.2

    ### Impact Consumers of the NPM package `happy-dom` ### Patches The security vulnerability has been patched in v15.10.2 ### Workarounds No easy workarounds to my knowledge ### References [#1585](https://github.com/capricorn86/happy-dom/issues/1585)

    CVE: CVE-2024-51757

Showing 1-8 of 8 vulnerabilities