CVE-2024-51757: Happy dom Happy-dom Allows For Server Side Vulnerability

CRITICAL
Advisory Identifier: GHSA-96g7-g7g9-jxw8
CWE-79
Published
Advisory Summary

CVE-2024-51757 is a CRITICAL happy-dom allows for server side vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting Happy dom libraries in the npm ecosystem. The issue involves happy-dom allows for server side code to be executed by a <script> tag. Remediation is available by upgrading affected packages to version 15.10.2.

CVE-2024-51757 at a Glance

CVE Identifier CVE-2024-51757
GHSA Identifier GHSA-96g7-g7g9-jxw8
Severity CRITICAL
CVSS v3.1 Base Score N/A
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product Happy dom
Package Ecosystem npm
Published Date
Last Updated

How to Fix CVE-2024-51757

To remediate this vulnerability, upgrade all affected Happy dom dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

happy-dom fixed: 15.10.2
npm install happy-dom@15.10.2
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls happy-dom

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2024-51757, inspect your project dependencies using npm:

npm ls happy-dom

Analyze the terminal output to locate any version of Happy dom in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 15.10.2), your application is affected.

Note: The npm ls happy-dom command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In Happy dom, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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-2024-51757 Affected Happy dom Versions

1 component(s)
Fixed Versions:
15.10.2
Product / Package Ecosystem Affected Versions Fixed Version
happy-dom
npm
< 15.10.2
15.10.2

References

Frequently Asked Questions

What is CVE-2024-51757?
CVE-2024-51757 is a security vulnerability in Happy dom involving happy-dom allows for server side code to be executed by a <script> tag under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which Happy dom versions are affected?
Affected versions include releases prior to 15.10.2 across affected packages: happy-dom.
What version fixes CVE-2024-51757?
Upgrading to 15.10.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is happy-dom affected?
Yes, happy-dom is affected in releases prior to 15.10.2. Upgrade your dependency to 15.10.2 or later.
What CWE is associated with CVE-2024-51757?
CVE-2024-51757 is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.).
How can I check npm dependencies for CVE-2024-51757?
Run the dependency tree command: 'npm ls happy-dom'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-96g7-g7g9-jxw8",
  "modified" : "2024-11-06T23:39:29Z",
  "published" : "2024-11-06T15:27:50Z",
  "aliases" : [ "CVE-2024-51757" ],
  "summary" : "happy-dom allows for server side code to be executed by a <script> tag",
  "details" : "### Impact\nConsumers of the NPM package `happy-dom`\n\n### Patches\nThe security vulnerability has been patched in v15.10.2\n\n### Workarounds\nNo easy workarounds to my knowledge\n\n### References\n[#1585](https://github.com/capricorn86/happy-dom/issues/1585)\n",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "happy-dom"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "15.10.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/capricorn86/happy-dom/security/advisories/GHSA-96g7-g7g9-jxw8"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-51757"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/capricorn86/happy-dom/issues/1585"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/capricorn86/happy-dom/pull/1586"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/capricorn86/happy-dom/commit/5ee0b1676d4ce20cc2a70d1c9c8d6f1e3f57efac"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/capricorn86/happy-dom/commit/d23834c232f1cf5519c9418b073f1dcec6b2f0fd"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/capricorn86/happy-dom"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/capricorn86/happy-dom/releases/tag/v15.10.2"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-11-06T15:27:50Z",
    "nvd_published_at" : "2024-11-06T20:15:06Z"
  }
}