WeSearch

The Woes of Sanitizing SVGs

·13 min read · 0 reactions · 0 comments · 3 views
#svg security#xss#http leaks#dompurify#web vulnerabilities
⚡ TL;DR · AI summary

Scratch has faced recurring security issues due to its handling of user-generated SVGs, repeatedly patching vulnerabilities such as XSS and HTTP leaks only to encounter new ones stemming from the inherent risks of parsing untrusted SVG content. Despite layers of sanitization using tools like DOMPurify and custom CSS parsers, attackers have consistently found bypasses through SVG features like script tags, CSS imports, url() functions, and newer CSS capabilities. The article argues that Scratch's approach to SVG sanitization is fundamentally flawed and unsustainable due to the complexity and evolving nature of web standards. Multiple vulnerabilities remain unfixed or only partially mitigated as of 2026.

Key facts
Original article
muffin.ink
Read full at muffin.ink →
Opening excerpt (first ~120 words) tap to expand

The woes of sanitizing SVGs 2026-04-11 on muffin.ink Scratch has a long history of SVG-related vulnerabilities. The source of these is that Scratch parses user-generated (ie. attacker-controlled) content into an <svg> element and appends it into the main document for various operations (eg. measuring SVG bounding box in a more reliable way than viewbox or width/height). No matter how briefly the SVG remains in the main document, this is an inherently unsafe operation. Scratch's approach to making this safe has been to build increasingly complex infrastructure around parsing the SVG and the markup within to remove dangerous parts. I think Scratch's approach to SVG sanitization is doomed.

Excerpt limited to ~120 words for fair-use compliance. The full article is at muffin.ink.

Anonymous · no account needed
Share 𝕏 Facebook Reddit LinkedIn Threads WhatsApp Bluesky Mastodon Email

Discussion

0 comments

More from muffin.ink