Repository navigation
fix(deps): update dependency sanitize-html to v2.18.1 [security] - #673
Open
renovate[bot] wants to merge 1 commit into
Open
renovate[bot] wants to merge 1 commit into
renovate[bot] wants to merge 1 commit into
Conversation
renovate
Bot
force-pushed
the
renovate/npm-sanitize-html-vulnerability
branch
from
October 26, 2026 20:34
46a216e to
32d2f33
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
2.18.0→2.18.1ApostropheCMS sanitize-html: unbounded recursion when re-sanitizing the fallback of a discarded iframe (stack overflow, nestingLimit not enforced)
CVE-2026-113650 / GHSA-c9rx-x947-fp3h
More information
Details
Summary
Since 2.18.0, when an
<iframe>is not allowed anddisallowedTagsModeis'discard'(the defaults),its raw-text content is re-sanitized by a recursive call to
sanitizeHtml(text, options)(the changefrom #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:
<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 depthcount at zero, so the output can be nested arbitrarily deep regardless of the configured limit.
Affected versions
latest), and themainbranch at the time of writing (the recursive call isstill in
packages/sanitize-html/index.js, in theontexthandler, branchtag === 'iframe' && !tagAllowed(tag) && options.disallowedTagsMode === 'discard').Tested with Node.js v26.7.0.
Reproduction 1: stack overflow with the default options
Results:
'<iframe>'.repeat(1000)'<iframe>'.repeat(2000)'<iframe>'.repeat(20000)The threshold depends on the remaining stack, so it is lower when
sanitizeHtmlis called from analready deep call stack (for example inside a server-side rendering pass).
Reproduction 2:
nestingLimitis bypassedWithout an iframe, the same options cap the output at three nested
<b>in all three versions. Withkrepetitions of'<iframe>' + '<b>'.repeat(3), 2.18.0 returns3 * knested<b>(measured fork = 1, 5, 50: depth 3, 15, 150).
Cause
In 2.18.0 the
ontexthandler does:Because htmlparser2 treats
<iframe>as a raw-text element, the text of an unclosed iframe is the wholeremainder 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 thefallback are not counted against
nestingLimittogether 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
nestingLimitapplies tothe whole output.
Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:LReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Release Notes
apostrophecms/apostrophe (sanitize-html)
v2.18.1Compare Source
Changes
Remove the
deepmergedependency, which was used only to combine tag-specific and*(all tags) entries inallowedClassesandallowedStyles. That is now done by a few lines of code within sanitize-html.This is not a fix for a vulnerability in sanitize-html. Security scanners such as Snyk now report CVE-2026-93753 in
deepmerge, which can affect applications that merge untrusted objects, such as parsed JSON request bodies. sanitize-html only ever merged the developer's own configuration, never anything taken from the HTML being sanitized, so it was not exploitable through sanitize-html. Since we needed only a small part of whatdeepmergedoes, we removed the dependency so that these reports no longer appear for sanitize-html users.Security
Since 2.18.0, the fallback markup of a discarded
<iframe>was re-sanitized by a recursive call with no limit, one level per nested unclosed<iframe>. A few kilobytes of crafted input could throwRangeError: Maximum call stack size exceededwith the default options, and thenestingLimitoption was not enforced across the fallback because each nested call started counting from zero. The fallback of a discarded<iframe>is still sanitized and kept, but only up to eight nested<iframe>elements (deeper fallback is escaped as text, as before 2.18.0), and the current nesting depth now carries into the nested call sonestingLimitapplies to the whole output. Only 2.18.0 was affected, and the exception is thrown synchronously, so applications that catch errors fromsanitizeHtmlonly lost the affected request (CWE-674, GHSA-c9rx-x947-fp3h).Thanks to hkmj19, JohnBeckley, and amikhailovstiltsoft for reporting the vulnerability.
Configuration
📅 Schedule: (UTC)
🚦 Automerge: Enabled.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.