Vulnerabilities in pkg:npm/layui

PACKAGE
Advisory Identifier: GHSA-j827-6rgf-9629
Advisory Summary

CVE-2024-47075 is a MODERATE (CVSS 6.4) cross-site scripting vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting Layui libraries in the npm ecosystem. The issue involves layui has dom clobbering gadgets that leads to cross-site scripting. Remediation is available by upgrading affected packages to version 2.9.17.

3 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:npm/layui

3 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:npm/layui. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-j827-6rgf-9629 CVE-2024-47075 MODERATE Layui has DOM Clobbering gadgets that leads to Cross-site Scripting
GHSA-rcvr-8whx-3m5p CVE-2023-50550 MODERATE Layui cross-site scripting (XSS) vulnerability
GHSA-hx4h-676r-j3qp CVE-2023-3691 MODERATE layui vulnerable to cross-site scripting

CVE-2024-47075 at a Glance

CVE Identifier CVE-2024-47075
GHSA Identifier GHSA-j827-6rgf-9629
Severity MODERATE
CVSS v3.1 Base Score 6.4
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product Layui
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 6.4

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:H).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability High (A:H)

How to Fix CVE-2024-47075

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

layui fixed: 2.9.17
npm install layui@2.9.17
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 layui

How to Check if You Are Affected

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

npm ls layui

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

Note: The npm ls layui 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 Layui, 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

### Summary A DOM Clobbering vulnerability has been discovered in `layui` that can lead to Cross-site Scripting (XSS) on web pages where attacker-controlled HTML elements (e.g., `img` tags with unsanitized `name` attributes) are present. It's worth noting that we’ve identifed similar issues in other popular client-side libraries like Webpack ([CVE-2024-43788](https://github.com/webpack/webpack/security/advisories/GHSA-4vvj-4cpr-p986)) and Vite ([CVE-2024-45812](https://github.com/vitejs/vite/security/advisories/GHSA-64vr-g452-qvp3)), which might serve as valuable references. ### Backgrounds DOM Clobbering is a type of code-reuse attack where the attacker first embeds a piece of non-script, seemingly benign HTML markups in the webpage (e.g. through a post or comment) and leverages the gadgets (pieces of js code snippet) living in the existing libraries to transform it into executable code. ### Impact This vulnerability can lead to cross-site scripting (XSS) on websites that uses `layui` library and allow users to inject certain scriptless HTML tags with improperly sanitized `name` or `id` attributes. ### Patch This problem has been patched in Layui 2.9.17. You can find the official fix announcement at: https://layui.dev/notes/share/security-currentscript.html

CVE-2024-47075 Affected Layui Versions

1 component(s)
Fixed Versions:
2.9.17
Product / Package Ecosystem Affected Versions Fixed Version
layui
npm
< 2.9.17
2.9.17

References

Frequently Asked Questions

What is CVE-2024-47075?
CVE-2024-47075 is a security vulnerability in Layui involving Layui has DOM Clobbering gadgets that leads to Cross-site Scripting under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which Layui versions are affected?
Affected versions include releases prior to 2.9.17 across affected packages: layui.
What version fixes CVE-2024-47075?
Upgrading to 2.9.17 (or the latest patched release for your respective branch) resolves the vulnerability.
Is layui affected?
Yes, layui is affected in releases prior to 2.9.17. Upgrade your dependency to 2.9.17 or later.
What is the CVSS score of CVE-2024-47075?
CVE-2024-47075 has a CVSS v3.1 base score of 6.4 (MODERATE) with vector string CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:H.
What CWE is associated with CVE-2024-47075?
CVE-2024-47075 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-47075?
Run the dependency tree command: 'npm ls layui'. 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-j827-6rgf-9629",
  "modified" : "2025-08-15T16:25:42Z",
  "published" : "2024-09-26T17:54:24Z",
  "aliases" : [ "CVE-2024-47075" ],
  "summary" : "Layui has DOM Clobbering gadgets that leads to Cross-site Scripting",
  "details" : "### Summary\nA DOM Clobbering vulnerability has been discovered in `layui` that can lead to Cross-site Scripting (XSS) on web pages where attacker-controlled HTML elements (e.g., `img` tags with unsanitized `name` attributes) are present.\n\nIt's worth noting that we’ve identifed similar issues in other popular client-side libraries like Webpack ([CVE-2024-43788](https://github.com/webpack/webpack/security/advisories/GHSA-4vvj-4cpr-p986)) and Vite ([CVE-2024-45812](https://github.com/vitejs/vite/security/advisories/GHSA-64vr-g452-qvp3)), which might serve as valuable references.\n\n###  Backgrounds\n\nDOM Clobbering is a type of code-reuse attack where the attacker first embeds a piece of non-script, seemingly benign HTML markups in the webpage (e.g. through a post or comment) and leverages the gadgets (pieces of js code snippet) living in the existing libraries to transform it into executable code. \n\n### Impact\n\nThis vulnerability can lead to cross-site scripting (XSS) on websites that uses `layui` library and allow users to inject certain scriptless HTML tags with improperly sanitized `name` or `id` attributes.\n\n### Patch\n\nThis problem has been patched in Layui 2.9.17. You can find the official fix announcement at: \nhttps://layui.dev/notes/share/security-currentscript.html",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:H"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:A/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "layui"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.9.17"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/layui/layui/security/advisories/GHSA-j827-6rgf-9629"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-47075"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/layui/layui/commit/f756b41d63bf3d488a2cb042918638c9851bf2b0"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/layui/layui"
  }, {
    "type" : "WEB",
    "url" : "https://layui.dev/notes/share/security-currentscript.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-09-26T17:54:24Z",
    "nvd_published_at" : "2024-09-26T18:15:08Z"
  }
}