Vulnerabilities in pkg:npm/ghtml

PACKAGE
Advisory Identifier: GHSA-vvhj-v88f-5gxr
Advisory Summary

CVE-2024-37166 is a HIGH (CVSS 8.9) cross-site scripting vulnerability (CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS)) affecting Ghtml libraries in the npm ecosystem. The issue involves ghtml cross-site scripting (xss) vulnerability. Remediation is available by upgrading affected packages to version 2.0.0.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:npm/ghtml

1 Known Advisory Record(s)

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

Advisory ID CVE / NVD Severity Summary
GHSA-vvhj-v88f-5gxr CVE-2024-37166 HIGH ghtml Cross-Site Scripting (XSS) vulnerability

CVE-2024-37166 at a Glance

CVE Identifier CVE-2024-37166
GHSA Identifier GHSA-vvhj-v88f-5gxr
Severity HIGH
CVSS v3.1 Base Score 8.9
CWE Classification CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS)
Affected Product Ghtml
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 8.9

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

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

How to Fix CVE-2024-37166

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

ghtml fixed: 2.0.0
npm install ghtml@2.0.0
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 ghtml

How to Check if You Are Affected

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

npm ls ghtml

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

Note: The npm ls ghtml 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-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS), where the product receives input from an upstream component, but it does not neutralize or incorrectly neutralizes special characters such as "<", ">", and "&" that could be interpreted as web-scripting elements when they are sent to a downstream component that processes web pages. In Ghtml, 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 It is possible to introduce user-controlled JavaScript code and trigger a Cross-Site Scripting (XSS) vulnerability in some cases. ## Actions Taken - Updated the documentation to clarify that while `ghtml` escapes characters with special meaning in HTML, it does not provide comprehensive protection against all types of XSS attacks in every scenario. **_This aligns with the approach taken by other template engines. Developers should be cautious and take additional measures to sanitize user input and prevent potential vulnerabilities._** More reading: https://cheatsheetseries.owasp.org/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html - The backtick character (`) is now also escaped to prevent the creation of strings in most cases where a malicious actor somehow gains the ability to write JavaScript. This does not provide comprehensive protection either.

CVE-2024-37166 Affected Ghtml Versions

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

References

Frequently Asked Questions

What is CVE-2024-37166?
CVE-2024-37166 is a security vulnerability in Ghtml involving ghtml Cross-Site Scripting (XSS) vulnerability under CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS).
Which Ghtml versions are affected?
Affected versions include releases prior to 2.0.0 across affected packages: ghtml.
What version fixes CVE-2024-37166?
Upgrading to 2.0.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is ghtml affected?
Yes, ghtml is affected in releases prior to 2.0.0. Upgrade your dependency to 2.0.0 or later.
What is the CVSS score of CVE-2024-37166?
CVE-2024-37166 has a CVSS v3.1 base score of 8.9 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:H/A:L.
What CWE is associated with CVE-2024-37166?
CVE-2024-37166 is classified under CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS) (The product receives input from an upstream component, but it does not neutralize or incorrectly neutralizes special characters such as "<", ">", and "&" that could be interpreted as web-scripting elements when they are sent to a downstream component that processes web pages.).
How can I check npm dependencies for CVE-2024-37166?
Run the dependency tree command: 'npm ls ghtml'. 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-vvhj-v88f-5gxr",
  "modified" : "2024-06-11T18:27:52Z",
  "published" : "2024-06-10T21:36:48Z",
  "aliases" : [ "CVE-2024-37166" ],
  "summary" : "ghtml Cross-Site Scripting (XSS) vulnerability",
  "details" : "## Summary\n\nIt is possible to introduce user-controlled JavaScript code and trigger a Cross-Site Scripting (XSS) vulnerability in some cases.\n\n## Actions Taken\n\n- Updated the documentation to clarify that while `ghtml` escapes characters with special meaning in HTML, it does not provide comprehensive protection against all types of XSS attacks in every scenario. **_This aligns with the approach taken by other template engines. Developers should be cautious and take additional measures to sanitize user input and prevent potential vulnerabilities._** More reading: https://cheatsheetseries.owasp.org/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html\n- The backtick character (`) is now also escaped to prevent the creation of strings in most cases where a malicious actor somehow gains the ability to write JavaScript. This does not provide comprehensive protection either.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:H/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "ghtml"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.0.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/gurgunday/ghtml/security/advisories/GHSA-vvhj-v88f-5gxr"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-37166"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/gurgunday/ghtml/commit/df1ea50fe8968a766fd2b9379a8f9806375227f8"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/gurgunday/ghtml"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79", "CWE-80" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-06-10T21:36:48Z",
    "nvd_published_at" : "2024-06-10T22:15:12Z"
  }
}