Information Exposure Vulnerability in node-sanitize-html Package

node-sanitize-html Updated 02 Oct 2025

Summary

24/02/2024
N/A
Yes i
Unrated
Not published

DEBIAN-CVE-2024-21501: Versions of the package sanitize-html before 2.12.1 are vulnerable to Information Exposure when used on the backend and with the style attribute allowed, allowing enumeration of files in the system (including project dep... Affects node-sanitize-html versions < 2.13.0+~2.11.0-1. Fixed in 2.13.0+~2.11.0-1. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

Background

The node-sanitize-html package is a popular library used in Node.js applications to sanitize HTML content, ensuring that it is safe for rendering in web applications. It allows developers to specify which HTML tags and attributes are permitted, making it a crucial tool for preventing XSS (Cross-Site Scripting) attacks. However, certain versions of this package are vulnerable to information exposure, particularly when the style attribute is allowed, which can lead to unintended file system disclosures.

Vulnerability Detail

Versions of the node-sanitize-html package prior to 2.12.1 are susceptible to an Information Exposure vulnerability. This issue arises when the package is used on the backend with the style attribute enabled, allowing attackers to enumerate files within the system, including sensitive project dependencies. The vulnerability can lead to the exposure of the file system structure and critical information about the server's configuration, potentially facilitating further attacks.

How To Fix

Minimum fixed version

2.13.0+~2.11.0-1

This is the first release that contains the fix.

sudo apt-get install --only-upgrade node-sanitize-html

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

As a temporary workaround, you can disable the use of the style attribute in your sanitization settings. This can be done by configuring the options in the sanitize-html function as follows:

const cleanHtml = sanitizeHtml(dirtyHtml, { allowedAttributes: { '*': ['href', 'src'] } });

This configuration will prevent the style attribute from being processed, mitigating the risk of information exposure.

Conclusion

The information exposure vulnerability in the node-sanitize-html package poses significant risks to applications that utilize this library. It is crucial for developers to update to the patched version to safeguard their applications against potential exploitation. Additionally, employing workarounds can provide temporary relief until the update is applied.

See every vulnerability recorded for node-sanitize-html →

Share this vulnerability

FAQ

node-sanitize-html is a library for sanitizing HTML content in Node.js applications, preventing XSS attacks by allowing developers to specify safe HTML elements and attributes.

Versions prior to 2.12.1 of the node-sanitize-html package are vulnerable to the information exposure issue.

You can use the Vulert playground at Vulert Scanner to check if your application is affected by this vulnerability without requiring any signup.

If exploited, this vulnerability can allow attackers to gain insights into the file system structure and dependencies of the targeted server, potentially leading to further attacks.

Yes, you can temporarily mitigate the risk by disabling the style attribute in your sanitization settings, as described in the workaround section.

Related vulnerabilities

Recent vulnerabilities recorded for node-sanitize-html.

How To Fix

Minimum fixed version

2.13.0+~2.11.0-1

This is the first release that contains the fix.

sudo apt-get install --only-upgrade node-sanitize-html

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback