Replace sanitize-html with dompurify in Wysiwyg preview
fix(content-manager): replace sanitize-html with dompurify in Wysiwyg preview (#26150)
Replace sanitize-html with dompurify in Wysiwyg preview875752-fix-replace-sanitize-html-with-dompurify-in-wysiwyg-cve-2026-90561fixreplace sanitize html dompurify wysiwyg preview
Committed by unrevised6419
commit message
fix(content-manager): replace sanitize-html with dompurify in Wysiwyg preview (#26150)
* fix(content-manager): replace sanitize-html with dompurify in Wysiwyg preview
sanitize-html pulls postcss into the browser bundle, triggering vite
"Module externalized for browser compatibility" warnings (path, fs, url,
source-map-js) on admin panel load. The library's own README states it
is intended for Node.js use.
Swap to DOMPurify (browser-native, no Node polyfills, ships own types).
Extract sanitization to a util with config that mirrors the prior
allowlist (attributes + URL schemes) and add unit tests pinning the
contract. Drop now-dead deps from @strapi/admin and the vite
optimizeDeps include.
* fix(content-manager): allow class and title attrs in Wysiwyg preview sanitizer
highlight.js code-block styling (hljs/language-* classes) and footnote
styling (footnote-ref/footnote-backref) depend on `class`, which both the
old sanitize-html config and the initial DOMPurify swap stripped — leaving
solarized-dark.css effectively dead. Also allow `title` for link/image
tooltips and the markdown-it abbr plugin. Both attrs are inert behind the
tag allowlist. `id` left out to avoid DOM clobbering.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
* fix(content-manager): strip all data: URIs in Wysiwyg preview sanitizer
DOMPurify allows data: URIs on media tags (img/source/video/audio) via its
internal DATA_URI_TAGS allowlist, bypassing ALLOWED_URI_REGEXP — so inline
data:image/* and even data:text/html;base64 survived on <img>. The prior
sanitize-html config stripped all data: URIs; an afterSanitizeAttributes hook
restores that parity.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
* chore(content-manager): scope Wysiwyg sanitizer hook to a private instance
Address review: create an own DOMPurify instance via createDOMPurify(window)
so the data: hook no longer mutates the library-wide singleton, trim the now
-stale registration comment, and drop the test-file doc block that duplicated
the production-code comments.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Co-authored-by: Ben Irvin <[email protected]>Editor assessment
This commit patches CVE-2026-90561. A detailed and well-structured body. It explains why sanitize-html was the wrong tool in the browser bundle (postcss, Node polyfills, vite externalization warnings), describes the DOMPurify swap, and then documents two follow-ups: restoring class/title attributes for highlight.js and footnote styling, and stripping all data: URIs with an afterSanitizeAttributes hook on a private DOMPurify instance. The scope is accurate and the header clean; the squash log makes it long, but every section carries information. The only missing piece is a short summary paragraph at the top.