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

Source: https://junglewise.ai/threats/cve-2021-26539-apostrophe-sanitize-html-idn-bypass-in-allowediframehostnames  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2021-05-06. Updated: 2026-09-25  
License: CC BY 4.0 with a link back

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)](https://junglewise.ai/threats/technologies/sanitize-html). Vendors: [npm](https://junglewise.ai/threats/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

  ```sh
  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

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

## 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)
