---
id: "TECH-202610-svg-sanitizer-bypasses-six-of-eight-popular-svg-sanitizer-li"
kind: "technique"
aliases: []
title: "SVG sanitizer bypasses: six of eight popular SVG sanitizer libraries let uploaded SVGs run JavaScript (XSS)"
severity: "medium"
cvss: null
epss: null
exploited: false
status: "open"
category: "package"
products: [{"name": "sanitize-svg", "fixed": [], "vendor": "mattkrick", "ecosystem": "npm"}, {"name": "svg-sanitizer", "fixed": [], "vendor": "Borewit", "ecosystem": "npm"}, {"name": "safe-svg", "fixed": [], "vendor": "bgalek"}, {"name": "SVG-Sanitizer", "fixed": [], "vendor": "alnorris"}, {"name": "svg-hush", "fixed": [], "vendor": "Cloudflare", "ecosystem": "crates.io"}, {"name": "py-svg-hush", "fixed": [], "vendor": "jams2", "ecosystem": "PyPI"}]
ecosystems: []
tags: ["early-warning", "technique"]
not_affected_if: []
published_at: null
first_seen_at: "2026-10-27T15:07:17+00:00"
updated_at: "2026-10-27T15:07:17+00:00"
sources: [{"source": "analyst", "url": null, "first_seen_at": "2026-10-27T15:07:17+00:00"}]
---

# SVG sanitizer bypasses: six of eight popular SVG sanitizer libraries let uploaded SVGs run JavaScript (XSS)

PortSwigger Research (Gareth Heyes, 2026-10-27) bypassed 6 of 8 popular SVG sanitizers, so apps that accept SVG uploads and rely on them can serve stored XSS. Affected: mattkrick/sanitize-svg (XHTML namespace switch, foreignobject case bug, nested svg onload, XSLT), Borewit/svg-sanitizer (animate/set of href to javascript: URL), bgalek/safe-svg and alnorris/SVG-Sanitizer (xml-stylesheet processing instruction pointing to a data: URL XSLT stylesheet), cloudflare/svg-hush, jams2/py-svg-hush and bgalek/safe-svg (Safari <use> importing an uploaded GIF/image as SVG). Also shown: Firefox runs an XSLT stylesheet supplied in a Link response header even when the body is harmless XML. DOMPurify and darylldoyle/svg-sanitizer held up. The author says two unnamed popular applications were exploited. Proof of concept only; no in-the-wild use reported. Fix status per library: unknown.

_Summary, check and fix written by a model from the sources; labelled as such._

## Affected

- npm:sanitize-svg affected ? fixed ?
- npm:svg-sanitizer affected ? fixed ?
- :safe-svg affected ? fixed ?
- :SVG-Sanitizer affected ? fixed ?
- crates.io:svg-hush affected ? fixed ?
- PyPI:py-svg-hush affected ? fixed ?

## How to check

Check if your app accepts SVG uploads and sanitizes them with sanitize-svg (mattkrick), svg-sanitizer (Borewit), safe-svg (bgalek), SVG-Sanitizer (alnorris), svg-hush (Cloudflare, Rust) or py-svg-hush; look in stored SVGs for xml-stylesheet processing instructions with data: URLs, <animate>/<set> on href, elements with an XHTML xmlns, and <use> pointing at uploaded image files

## Fix

Switch SVG sanitizing to DOMPurify (SVG profile) or darylldoyle/svg-sanitizer, or watch for fixed releases of the affected libraries; serve user-uploaded SVGs from a separate sandbox domain with Content-Security-Policy: sandbox / script-src 'none' and Content-Disposition: attachment, or convert them to raster images; strip xml-stylesheet processing instructions

## Timeline

- 2026-10-27T15:07:17+00:00 analyst

## Documents

- [describes] PortSwigger Research: Scalable Vector Grief https://portswigger.net/research/scalable-vector-grief

---

_Free to read at a human pace. An API with keys and an MCP server are in preparation; early access: hello@infrastack.ai_
