# CVE-2024-21501: sanitize-html information exposure via style attribute

Source: https://junglewise.ai/threats/cve-2024-21501-sanitize-html-information-exposure-via-style-attribute  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2024-02-24. Updated: 2026-09-25  
License: CC BY 4.0 with a link back

CVE-2024-21501 · Severity: low · CVSS 3.1 · Published 2024-02-24

sanitize-html is a widely-used Node.js library that removes potentially dangerous HTML and CSS from user-supplied content. When the style attribute is allowed and the library is used on a backend server, an attacker can craft CSS rules that leak information about the server's filesystem and installed dependencies. This allows reconnaissance of the target environment and could inform follow-up attacks.

Technologies: [sanitize-html (npm)](https://junglewise.ai/threats/technologies/sanitize-html). Vendors: [npm](https://junglewise.ai/threats/vendors/npm).

## Quick answers

**Is CVE-2024-21501 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2024-21501 being exploited in the wild.

**How severe is CVE-2024-21501?** Low severity, with a CVSS score of 3.1, published 24 February 2024.

**Which products and versions are affected?** sanitize-html (npm) before 2.12.1.

**Is there a fix for CVE-2024-21501?** A patch was published on 2024-02-22: Fix merged in PR #650 for version 2.12.1 Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2024-21501 attacked?** It is attacked over the network.

**Am I affected by CVE-2024-21501?** Check whether you run sanitize-html (npm) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## Technical details

sanitize-html versions before 2.12.1 fail to properly sanitize CSS in the style attribute when PostCSS processes source maps. An attacker can inject CSS that uses URL references or other techniques to enumerate local files and directory structures on the backend server. The vulnerability requires that (1) the style attribute is explicitly allowed in the sanitizer configuration, and (2) the application processes user-supplied HTML on a backend server rather than in a browser. Exploitation reveals filesystem paths and dependency information without authentication. The fix in version 2.12.1 ignores source maps during PostCSS processing to prevent this leak.

## Affected products

- npm sanitize-html before 2.12.1

## Identifiers

- CVE-2024-21501
- GHSA-rm97-x556-q36h

## Timeline

- 2024-02-24: disclosed: GHSA-rm97-x556-q36h and CVE-2024-21501 published
- 2024-02-22: patched: Fix merged in PR #650 for version 2.12.1

## References

- [https://github.com/apostrophecms/sanitize-html/pull/650](https://github.com/apostrophecms/sanitize-html/pull/650)

## Related threats

- [sanitize-html incomplete : meta refresh URL scheme bypass](https://junglewise.ai/threats/cve-2026-113661-apostrophecms-incomplete-meta-http-equiv-refresh-content-still)
- [ApostropheCMS sanitize-html: SMIL animation namespace-prefix bypass allows javascript: URI injection (XSS)](https://junglewise.ai/threats/cve-2026-113657-apostrophecms-is-an-open-source-node-js-content-management)
- [sanitize-html noscript XSS bypass](https://junglewise.ai/threats/cve-2026-113654-apostrophecms-is-an-open-source-node-js-content-management)
- [sanitize-html unbounded recursion denial of service](https://junglewise.ai/threats/cve-2026-113650-apostrophecms-is-an-open-source-node-js-content-management)
- [sanitize-html stored XSS via SVG SMIL URI-list scheme bypass](https://junglewise.ai/threats/cve-2026-84371-sanitize-html-stored-xss-via-svg-smil-uri-list-scheme-bypass)
