Update dependency sanitize-html to v2.17.7 [SECURITY] - #85
Open
renovate[bot] wants to merge 1 commit into
Open
Conversation
renovate
Bot
force-pushed
the
renovate/npm-sanitize-html-vulnerability
branch
from
September 2, 2026 02:02
b9d4715 to
7303b80
Compare
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.3.2→2.17.7sanitize-html Information Exposure vulnerability
CVE-2024-21501 / GHSA-rm97-x556-q36h
More information
Details
Versions of the package sanitize-html before 2.12.1 are vulnerable to Information Exposure when used on the backend and with the style attribute allowed, allowing enumeration of files in the system (including project dependencies). An attacker could exploit this vulnerability to gather details about the file system structure and dependencies of the targeted server.
Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Sanitize-html Vulnerable To REDoS Attacks
CVE-2022-25887 / GHSA-cgfm-xwp7-2cvr
More information
Details
The package sanitize-html before 2.7.1 are vulnerable to Regular Expression Denial of Service (ReDoS) due to insecure global regular expression replacement logic of HTML comment removal.
Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:HReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
sanitize-html has incomplete URI scheme validation in that allows javascript: URIs through action, formaction, data, poster, and background attributes
CVE-2026-53606 / GHSA-vccv-cmxp-4j9h
More information
Details
Summary
sanitize-html uses
allowedSchemesAppliedToAttributes(default:['href', 'src', 'cite']) to gate thenaughtyHref()function that blocks dangerous URI schemes likejavascript:andvbscript:. The HTML specification defines 10+ attributes that accept URIs (action,formaction,data,poster,background,ping,xlink:href,dynsrc,lowsrc), but none of these are included in the default gate list. When a developer allows any of these attributes in their configuration,javascript:URIs pass through completely unmodified, enabling XSS.The library has zero awareness of these URI-bearing attributes — none appear anywhere in the 854-line source file (verified by grep). No warning mechanism exists, and the README provides no security guidance about expanding
allowedSchemesAppliedToAttributeswhen allowing form or media attributes.Severity
Exploitation requires non-default configuration: the developer must explicitly allow a non-default tag (e.g.,
form) AND a non-default attribute (e.g.,action). Default configuration is NOT vulnerable. However, this is a common configuration pattern for CMS platforms, form builders, and rich content editors.Affected Versions
All versions of sanitize-html from v1.18.0 (which introduced
allowedSchemesAppliedToAttributes) through at least v2.17.2. The default list has been['href', 'src', 'cite']since introduction and has never been expanded.Root Cause
File:
index.js:329(sanitize-html 2.10.0, confirmed same in 2.17.x)Default list at line 829:
The
naughtyHref()function (lines 627-667) correctly blocksjavascript:,vbscript:, and other dangerous schemes. However, it has exactly 2 call sites in the entire codebase (lines 330 and 395), both inside theindexOfgate. There is no ungated path.When attribute name is
action,formaction,data,poster,background, etc.:indexOf('action')returns-1ifblock is skipped entirelynaughtyHref()is never calledjavascript:alert(1)passes through unmodifiedThe
escapeHtml()function at line 464 provides no defense — it only encodes& < > "characters, which are not present injavascript:alert(1).Data Flow:
Steps to Reproduce
Observed behavior:
javascript:preserved onaction/formaction/databut correctly stripped onhref.Expected behavior:
javascript:should be stripped on ALL URI-bearing attributes, or at minimum, the library should warn developers when they allow URI-bearing attributes not covered by scheme validation.Impact
An attacker can achieve XSS in applications that use sanitize-html with non-default configurations allowing URI-bearing attributes:
<form action="javascript:...">— XSS on form submission (all modern browsers)<button formaction="javascript:...">— per-button XSS override (all modern browsers)<object data="javascript:...">— object load XSS (Chrome, Firefox)<video poster="javascript:...">— limited browser support but spec-validCommon vulnerable configurations:
Mitigating factors:
form-actiondirective mitigates form-based vectorsallowedSchemesAppliedToAttributesRemediation
Option 1 (Recommended): Expand the default
allowedSchemesAppliedToAttributeslist:Option 2: Apply
naughtyHref()to ALL attributes by default (invert the gate logic).Option 3: Add a runtime warning when developers allow URI-bearing attributes not in
allowedSchemesAppliedToAttributes(analogous tovulnerableTagswarning forscript/styleat lines 124-129).Reporter
Kevin Lee (Changseon Lee)
OPCIA Corp. / PeanutAI Inc.
Seoul, South Korea
GitHub: crattack
Severity
CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
ApostropheCMS: Stored XSS via SVG SMIL URI-list scheme-policy bypass
CVE-2026-84371 / GHSA-g8qq-57p8-ggw5
More information
Details
Summary
When SVG animation is allowed,
attributeName="href"makesvaluesa list of URL destinations.sanitize-htmlaccepts a list that starts with a safe fragment even whenvaluesis explicitly scheme-checked, allowing a laterjavascript:destination to execute when the sanitized link is activated.Details
index.js:371-383validates each attribute as one flat URL. It does not recognize thatattributeName="href"gives the siblingvaluesattribute SMIL URI-list semantics. Forvalues="#safe;javascript:...", the leading fragment passes the flat check and the complete list is retained.PoC
This was reproduced with
sanitize-html@2.17.6and Chromium 150.0.7871.124. The configuration adds SVG animation to the defaults and applies the existing scheme policy tovalues; it does not allowjavascript:. Save this aspoc.js:Install and run it, then open
poc.htmland clickClick me:npm install sanitize-html@2.17.6 node poc.js > poc.htmlThe output retains the
javascript:entry, and clicking the sanitized SVG displaysXSS. Withinputchanged to<a href="javascript:alert(1)">control</a>, the same configuration removeshref.Impact
In an application that accepts attacker-authored SVG animation, the attacker can store this payload without scripts or event handlers. A victim who activates the sanitized link executes JavaScript in the application's origin despite the configured scheme policy.
Suggested fix
Reject
attributeNamevalues selectinghreforxlink:hrefon SVGanimateandset, while retaining safe targets such asfill. Addvalues,from, andtoregression cases.Severity
CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Release Notes
apostrophecms/apostrophe (sanitize-html)
v2.17.7Security
animate,animateColor,animateMotion,animateTransformorset) together withattributeNameand one of the animation value attributes. The default configuration was not affected, as these elements are not in the defaultallowedTags.apostrophecmswas not affected. Thanks to koyokr for responsibly disclosing the vulnerability (GHSA-g8qq-57p8-ggw5).v2.17.6Fixes
Security
textareaorxmp) nested inside ansvgormathroot were re-emitted without HTML-escaping.sanitize-htmltreated that content as inert raw text becausehtmlparser210.x classified raw-text elements by tag name and ignored the namespace, but a real HTML5 parser treatstextarea/xmpas ordinary foreign elements inside SVG/MathML and re-parses their contents as live markup. As a result, markup and event-handler attributes that the allowlist never permitted (for example<svg><textarea><img src=x onerror=alert(1)>) could survive sanitization and execute in the browser. This is now fixed on two fronts:htmlparser2was upgraded to 12.x, which is namespace-aware and parsestextarea/xmpinside SVG/MathML as ordinary elements, so their non-allowlisted children (such as the injectedimg) are dropped by the allowlist instead of being preserved as raw text; and any raw-text contentsanitize-htmlstill emits for these tags (at HTML integration points such asforeignObject/mtext, or outside foreign content) is always HTML-escaped. The default configuration is not affected; the precondition is anallowedTagsthat includessvgormathtogether withtextareaorxmp. Thanks to khoadb175 for responsibly disclosing the vulnerability.allowedTagsbypass affecting configurations that allow thetextareaorxmpraw-text tags.htmlparser210.x did not recognize an end tag with a trailing solidus (e.g.</textarea/>) as closing the element, so it kept the following markup as raw text, but a spec-compliant browser treats</textarea/>as a valid close and parses that markup as a live element. Because raw-text content was re-emitted without escaping, a payload such as<textarea></textarea/><img src=x onerror=...>could smuggle non-allowlisted, executable markup through the sanitizer. The default configuration was not affected. This is now defended at two layers:htmlparser2was upgraded to 12.x, whose tokenizer closes these end tags correctly, and the raw text sanitize-html emits for these tags is always escaped so no<can reopen a tag when the output is re-parsed (textarea, an RCDATA element whose entitieshtmlparser2decodes, is escaped like normal text, whilexmp, a raw-text element, has only its angle brackets escaped to avoid double-encoding already-encoded entities). Becausehtmlparser2is ESM-only from version 11 onward,sanitize-htmlnow requires Node.js>=22.12.0(the first 22.x release in whichrequire()of an ES module is available unflagged). Thanks to bibu123456 for reporting the vulnerability and Kayiz-PT for coordinating the disclosure (GHSA-jxwj-j7wr-gfrw).v2.17.5Compare Source
v2.17.4Compare Source
Changes
sanitize-htmlandlaundernow share a single implementation ofnaughtyHref, based on that which previously existed insanitize-html.Security
v2.17.3Compare Source
Security
optiontags. There was no vulnerability when not explicitly allowingoptiontags.v2.17.2Compare Source
Changes
htmlparser2from 8.x to 10.1.0. This improves security by correctly decoding zero-padded numeric character references (e.g.,&#​0000001) that previously bypassedjavascript:URL detection. Also fixes double-encoding of entities inside raw text elements liketextareaandoption.v2.17.1Compare Source
Fixes
<hello) returning empty string inescapeandrecursiveEscapemodes. Fixes #706.Thanks to Byeong Hyeon for the fix.
v2.17.0Compare Source
preserveEscapedAttributes, allowing attributes on escaped disallowed tags to be retained. Thanks to Ben Elliot for this new option.v2.16.0Compare Source
onOpenTagandonCloseTagevents to enable advanced filtering to hook into the parser. Thanks to Rimvydas Naktinis.v2.15.0Compare Source
"excludeTag". Thanks to rChaoz.v2.14.0Compare Source
transformTagsin cases where it originally had no text child elements. Thanks to f0x.v2.13.1Compare Source
allowedClasseswildcard whitelist. Thanks toanak-dev.v2.13.0Compare Source
Documentation update regarding minimum supported TypeScript version.
Added disallowedTagsMode:
completelyDiscardoption to remove the content also in HTML. Thanks to Gauav Kumar for this addition.v2.12.1Compare Source
post-css. This fixes a vulnerability in which information about the existence or non-existence of files on a server could be disclosed via properly crafted HTML input when thestyleattribute is allowed by the configuration. Thanks to the Snyk Security team for the disclosure and to Dylan Armstrong for the fix.v2.12.0Compare Source
Introduced the
allowedEmptyAttributesoption, enabling explicit specification of empty string values for select attributes, with the default attribute set toalt. Thanks to Na for the contribution.Clarified the use of SVGs with a new test and changes to documentation. Thanks to Gauav Kumar for the contribution.
Do not process source maps when processing style tags with PostCSS.
v2.11.0Compare Source
falseinallowedClassesattributes. Thanks to Kevin Jiang for this fix!.ideatemp files to.gitignorev2.10.0Compare Source
disallowedTagModeis set to any variant ofescape-- just escape the disallowed tags that are present. This fixes issue #464. Thanks to Daniel LiebnertagAllowed()helper function which takes a tag name and checks it againstoptions.allowedTagsand returnstrueif the tag is allowed andfalseif it is not.v2.9.0Compare Source
v2.8.1Compare Source
v2.8.0Compare Source
htmlparser2to new major version^8.0.0. Thanks to Kedar Chandrayan for this contribution.v2.7.3Compare Source
false, then do not assume that all tags are allowed. Rather, allow no tags in this case, to be on the safe side. This matches the existing documentation and fixes issue #176. Thanks to Kedar Chandrayan for the fix.v2.7.2Compare Source
Kedar Chandrayan for the report and the fix.
v2.7.1Compare Source
v2.7.0Compare Source
<img />tags. Thanks to Zade Viggers.v2.6.1Compare Source
!importantwhen used.transformTagsoptions that was reported on issue #506. Thanks to Alex Rantos.v2.6.0Compare Source
allowedClassesoption. Thanks to Alex Rantos.v2.5.3Compare Source
v2.5.2Compare Source
null,undefinedor implicitundefinedwhen value is not provided. Thanks to Artem Kostiuk for the contribution.v2.5.1Compare Source
allowedScriptHostnamesandallowedScriptDomainsoptions now implicitly purge the inline content of all script tags, not just those withsrcattributes. This behavior was already strongly implied by the fact that they purged it in the case where asrcattribute was actually present, and is necessary for the feature to provide any real security. Thanks to Grigorii Duca for pointing out the issue.v2.5.0Compare Source
allowedScriptHostnamesoption, it enables you to specify which hostnames are allowed in a script tag.allowedScriptDomainsoption, it enables you to specify which domains are allowed in a script tag. Thank you to Yorick Girard for this and theallowedScriptHostnamescontribution.v2.4.0Compare Source
allowedClasses. Thanks to zhangbenber for the contribution.v2.3.3Compare Source
allowedSchemesand related options did not properly block schemes containing a hyphen, plus sign, period or digit, such asms-calculator:. Thanks to Lukas Euler for pointing out the issue.parseroption, especiallydecodeEntities: false. See the documentation.Configuration
📅 Schedule: (UTC)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, 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.