# CVE-2026-40186: Apostrophe sanitize-html allowedTags bypass in textarea and option tags

Source: https://junglewise.ai/threats/cve-2026-40186-apostrophe-sanitize-html-allowedtags-bypass-in-textarea-and  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-04-15. Updated: 2026-05-11  
License: CC BY 4.0 with a link back

CVE-2026-40186 · Severity: medium · CVSS 6.1 · Published 2026-04-15

A vulnerability in the sanitize-html library allows attackers to bypass security filters and inject malicious scripts into web applications. This occurs when the library is configured to allow certain form-related tags like text areas or dropdown options. An exploit could lead to cross-site scripting (XSS), allowing attackers to steal user session data or perform unauthorized actions on behalf of users.

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

## Quick answers

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

**How severe is CVE-2026-40186?** Medium severity, with a CVSS score of 6.1, published 15 April 2026.

**Which products and versions are affected?** sanitize-html (npm) >= 2.17.2, < 2.17.3, SEMVER:introduced=2.17.2,fixed=2.17.3.

**Is there a fix for CVE-2026-40186?** Yes. sanitize-html (npm): upgrade to 2.17.3 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2026-40186 attacked?** It is attacked over the network, in a software library.

**Am I affected by CVE-2026-40186?** Check whether you run ApostropheCMS, ApostropheCMS Sanitize-Html or 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.17.3 or later

  ```sh
  npm install sanitize-html@2.17.3
  ```


## Technical details

A regression introduced in commit 49d0bb7 causes sanitize-html to skip HTML escaping for text content within elements defined in nonTextTagsArray (specifically <textarea> and <option>). The library incorrectly assumes that the underlying parser (htmlparser2) does not decode entities in these contexts; however, htmlparser2 10.x does decode them. Consequently, an attacker can provide entity-encoded payloads (e.g., &lt;script&gt;) which are decoded by the parser and then written directly to the output without being re-escaped. This allows for complete bypass of the allowedTags enforcement and enables stored XSS. The vulnerability is present in version 2.17.2 and is fixed in version 2.17.3.

## Affected products

- apostrophecms sanitize-html >= 2.17.2, < 2.17.3

## Identifiers

- CVE-2026-40186
- GHSA-9mrh-v2v3-xpfm

## Timeline

- 2026-04-15: disclosed
- 2026-04-15: patched
- 2026-04-16: advisory

## References

- [https://api.github.com/users/offset](https://api.github.com/users/offset)
- [https://github.com/offset](https://github.com/offset)
- [https://api.github.com/users/offset/gists%7B/gist_id%7D](https://api.github.com/users/offset/gists%7B/gist_id%7D)
- [https://api.github.com/users/offset/repos](https://api.github.com/users/offset/repos)
- [https://avatars.githubusercontent.com/u/114768995?v=4](https://avatars.githubusercontent.com/u/114768995?v=4)
- [https://api.github.com/users/offset/events%7B/privacy%7D](https://api.github.com/users/offset/events%7B/privacy%7D)

## Related threats

- [ApostropheCMS unauthenticated file upload in import routes](https://junglewise.ai/threats/cve-2026-113711-apostrophecms-is-an-open-source-node-js-content-management)
- [ApostropheCMS password-change endpoint lacks attempt throttling](https://junglewise.ai/threats/cve-2026-113710-apostrophecms-no-attempt-throttling-on-authenticated-password)
- [ApostropheCMS page REST API authorization bypass](https://junglewise.ai/threats/cve-2026-113670-apostrophecms-page-rest-api-authorization-bypass)
- [ApostropheCMS cross-domain session token in URL confers session takeover](https://junglewise.ai/threats/cve-2026-113669-apostrophecms-cross-domain-session-token-in-url-confers-session)
- [ApostropheCMS REST route authorization bypass in locales endpoint](https://junglewise.ai/threats/cve-2026-113668-apostrophecms-id-locales-rest-route-omits-the-public-api)
