CVE-2026-113650: ApostropheCMS sanitize-html: unbounded recursion when re-sanitizing the fallback of a discarded iframe (stack overflow, nestingLimit not enforced)
Summary Since 2.18.0, when an is not allowed and disallowedTagsMode is 'discard' (the defaults), its raw-text content is re-sanitized by a recursive call to sanitizeHtml(text, options) (the change from #5564, fixing #5550). The recursion has no bound and starts each nested call with a fresh state. Two consequences, both absent from 2.17.7 and 2.17.4: 1.
Published Oct 21, 2026
Affected packages
sanitize-html
- Ecosystem
- npm
- Affected
- >= 2.18.0, < 2.18.1
- Fixed in
- 2.18.1
- Check
npm ls sanitize-html
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
Summary
Since 2.18.0, when an <iframe> is not allowed and disallowedTagsMode is 'discard' (the defaults), its raw-text content is re-sanitized by a recursive call to sanitizeHtml(text, options) (the change from #5564, fixing #5550). The recursion has no bound and starts each nested call with a fresh state. Two consequences, both absent from 2.17.7 and 2.17.4:
- A few kilobytes of unclosed
<iframe>tags throwRangeError: Maximum call stack size exceededwith the default options. Any application that sanitizes untrusted HTML with 2.18.0 can be made to throw on a small crafted input. nestingLimitis not enforced across a discarded iframe: each nested iframe restarts the depth count at zero, so the output can be nested arbitrarily deep regardless of the configured limit.
Affected versions
- 2.18.0 (the current
latest), and themainbranch at the time of writing (the recursive call is still inpackages/sanitize-html/index.js, in theontexthandler, branchtag === 'iframe' && !tagAllowed(tag) && options.disallowedTagsMode === 'discard'). - Not affected: 2.17.7 and 2.17.4 (tested with the same inputs below).
Tested with Node.js v26.7.0.
Reproduction 1: stack overflow with the default options
const sanitizeHtml = require('sanitize-html');
// with 2.18.0:
sanitizeHtml('<iframe>'.repeat(1000)); // 8,000 chars: returns ''
sanitizeHtml('<iframe>'.repeat(2000)); // 16,000 chars: throws RangeError: Maximum call stack size exceeded
sanitizeHtml('<iframe>'.repeat(20000)); // 160,000 chars: throws RangeError: Maximum call stack size exceededResults:
| input | 2.17.4 | 2.17.7 | 2.18.0 | | `'<iframe>'.repeat(1000)` | ok | ok | ok | | `'<iframe>'.repeat(2000)` | ok | ok | RangeError | | `'<iframe>'.repeat(20000)` | ok | ok | RangeError |
The threshold depends on the remaining stack, so it is lower when sanitizeHtml is called from an already deep call stack (for example inside a server-side rendering pass).
Reproduction 2: nestingLimit is bypassed
const sanitizeHtml = require('sanitize-html');
const input = ('<iframe>' + ''.repeat(3)).repeat(50) + 'x';
const out = sanitizeHtml(input, { allowedTags: ['b'], nestingLimit: 3 });
// maximum nesting depth of in `out`:
// 2.17.4: 2 2.17.7: 0 (fallback escaped as text) 2.18.0: 150Without an iframe, the same options cap the output at three nested ` in all three versions. With k repetitions of '' + ''.repeat(3), 2.18.0 returns 3 * k nested ` (measured for k = 1, 5, 50: depth 3, 15, 150).
Cause
In 2.18.0 the ontext handler does:
} else if (
tag === 'iframe' &&
!tagAllowed(tag) &&
options.disallowedTagsMode === 'discard'
) {
result += sanitizeHtml(text, options);
}Because htmlparser2 treats <iframe> as a raw-text element, the text of an unclosed iframe is the whole remainder of the input; re-parsing it can meet another unclosed <iframe>, and so on, one stack frame (and one full re-parse) per iframe. The nested call also starts with its own depth, so tags inside the fallback are not counted against nestingLimit together with the enclosing tags.
Possible directions
Not a patch, only what would close both effects: bound the recursion (or process the fallback without recursing), and carry the current depth into the nested sanitization so that nestingLimit applies to the whole output.
Credited to hkmj19, amikhailovstiltsoft.
References
- https://github.com/apostrophecms/apostrophe/security/advisories/GHSA-c9rx-x947-fp3h
- https://nvd.nist.gov/vuln/detail/CVE-2026-113650
- https://github.com/apostrophecms/apostrophe/commit/06e4b377f3c360f9e89c32dccd7e505ad5ddf498
- https://github.com/apostrophecms/apostrophe/commit/40b989b1a9dd23d30029b8ce7668634265cfe5ea
- https://github.com/apostrophecms/apostrophe/releases/tag/[email protected]
- https://github.com/advisories/GHSA-c9rx-x947-fp3h
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology
More npm vulnerabilities
All npm entriesCVE-2026-113654
ApostropheCMS sanitize-html: nonTextTags discard region ends early on an implied close, letting <noscript> content render
medium5.3Oct 20, 2026CVE-2026-113657
ApostropheCMS sanitize-html: SMIL animation namespace-prefix bypass allows javascript: URI injection (XSS)
low3.7Oct 20, 2026CVE-2026-113661
ApostropheCMS: Incomplete CVE-2026-53606: `meta http-equiv=refresh` `content` still ships `javascript:` / `data:` URLs
medium5.4Oct 20, 2026CVE-2026-63670
ApostropheCMS: Mutation-XSS / allowedTags bypass via literal `</textarea/>` solidus close
medium6.1Sep 3, 2026CVE-2026-84371
ApostropheCMS: Stored XSS via SVG SMIL URI-list scheme-policy bypass
medium5.4Sep 1, 2026CVE-2026-53606
sanitize-html has incomplete URI scheme validation in that allows javascript: URIs through action, formaction, data, poster, and background attributes
medium5.4Jul 31, 2026
