CVE-2021-26539: Apostrophe sanitize-html IDN bypass in allowedIframeHostnames

CVE-2021-26539 · Severity: low · CVSS 3.1 · Published 2021-05-06

sanitize-html is a popular Node.js library used to remove potentially dangerous HTML markup from user-supplied content while preserving safe tags. An attacker can bypass the hostname whitelist protection (allowedIframeHostnames option) by crafting internationalized domain names (IDN), potentially allowing malicious iframes to be embedded in sanitized content. This could lead to XSS attacks or content spoofing if the application relies on the whitelist for security.

Technologies: sanitize-html (npm). Vendors: npm.

Quick answers

Is CVE-2021-26539 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2021-26539 being exploited in the wild.
How severe is CVE-2021-26539?
Low severity, with a CVSS score of 3.1, published 6 May 2021.
Which products and versions are affected?
sanitize-html (npm) SEMVER:introduced=0,fixed=2.3.1.
Is there a fix for CVE-2021-26539?
Yes. sanitize-html (npm): upgrade to 2.3.1 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2021-26539 attacked?
It is attacked over the network, in a software library.
Am I affected by CVE-2021-26539?
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.

How to fix

  • sanitize-html (npm): upgrade to 2.3.1 or later
    npm install sanitize-html@2.3.1

Technical details

The vulnerability is an improper input validation issue (CWE-20) in the sanitize-html library before version 2.3.1. The library fails to properly normalize internationalized domain names (IDN) when validating iframe hostnames against the allowedIframeHostnames whitelist. An attacker can supply an IDN-encoded domain that, when interpreted by the browser, resolves to a different domain than what is validated, bypassing the whitelist check. The attack requires no authentication or special preconditions; any application using the allowedIframeHostnames option is potentially vulnerable. The fix was released in version 2.3.1 (January 22, 2021) and normalizes IDN domains before validation.

Affected products

  • Apostrophe Technologies sanitize-html before 2.3.1

Identifiers

  • CVE-2021-26539
  • GHSA-rjqq-98f6-6j3r

Timeline

  • 2021-02-08: disclosed: CVE-2021-26539 published on NVD
  • 2021-01-22: patched: Fix released in version 2.3.1

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.