DOM AST Security Purifier

Online SVG Sanitizer & Script Stripper

Disarm dangerous vector graphics by permanently stripping executable scripts, event listeners, and XML entities directly in your browser. Prevents Stored XSS attacks.

Drop your SVG vector file here or click to browse
Supports global clipboard paste: press Ctrl + V anywhere on this page
SVG 1.1 / 2.0 AST DOM Purified 100% In-Browser

The XML Nature of SVG: Why Vector Graphics Are Actually Executable Programs

Most internet users perceive image files as static matrices of colored pixels. When you view a PNG, JPEG, or WebP photograph, your operating system decodes binary streams into an array of red, green, blue, and alpha subpixels. A raster file contains no execution logic, no conditional branches, and no network capabilities; it is pure mathematical data.

Scalable Vector Graphics (SVG) share almost none of those characteristics. An SVG file is not a raster bitmap. It is an XML text document structured with tags, attributes, and hierarchical nodes exactly like an HTML webpage. When your web browser opens an SVG document, it invokes an active XML parser to construct a live Document Object Model (DOM) tree. Because the W3C SVG specification was engineered to support interactive animations and dynamic web user interfaces, that DOM tree natively supports execution of JavaScript code. In the eyes of a browser engine, an SVG file is an executable application.

Anatomy of SVG Stored Cross-Site Scripting (XSS)

Because vector files are executable programs, accepting user-uploaded SVG graphics without thorough deep inspection is functionally equivalent to allowing untrusted users to upload arbitrary HTML pages to your domain origin.

Attackers deploy multiple sophisticated vectors within vector graphics:

AST DOM Allowlisting vs Fragile Regular Expressions

Many unhardened web services attempt to sanitize vector files using simple regular expressions. Attackers routinely bypass regex filters using XML character entities (such as replacing script with encoded hexadecimal entities), nested CDATA blocks, whitespace obfuscation, and case manipulation.

Robust SVG sanitization requires true Abstract Syntax Tree (AST) traversal. Our client-side purifier parses the raw vector markup into an active in-memory DOM document. The sanitizer walks every child node, strictly destroying forbidden elements (including script, foreignObject, iframe, embed, object, and external use references). It systematically strips all event attributes starting with on and purges suspicious URL protocols. The resulting clean tree is then serialized back into standard, safe XML markup with all vector paths, curves, and styling completely intact.

In addition to element pruning, recursive attribute filtering inspects inline style sheets and presentation attributes. Malicious SVG vectors frequently hide JavaScript within CSS expressions, URL parameters, and animated SMIL target attributes. Our purifier scans every style declaration, scrubbing unapproved font imports, external stylesheet links, and dynamic behaviors to ensure that only pure graphic coordinates reach the final output.

Defense in Depth: Edge Content-Security-Policy Isolation

Client-side sanitization is the first line of defense, but true platform security demands defense in depth. When SVG vectors are uploaded or shared, production web applications must never serve them under an ambiguous content type or from their primary origin. If served with an HTML MIME type or without sandboxing, browser parsers may execute residual XML entities.

At PoofShare, all vector assets are served with strict edge Content-Security-Policy headers that enforce default-src 'none' and the sandbox directive. This directive strips the document of origin access, disabling local storage, session cookies, and cross-origin fetch requests even if a client attempts to bypass sanitization. By pairing client-side AST purification with edge HTTP header sandboxing, designers and developers can publish vector illustrations with zero risk of account compromise.

Vector Security Filtering Specifications

Threat Vector Attack Mechanism PoofShare Sanitization Action Resulting State
<script> Blocks Immediate JavaScript execution on render Complete AST node destruction Zero Script Elements
Inline Event Handlers onload, onerror, onclick attribute hooks Systematic attribute stripping All Event Hooks Eradicated
<foreignObject> XHTML Arbitrary HTML form & iframe embedding Complete container node removal Pure Vector Primitives Only
<!DOCTYPE> Entities XXE server disclosure & billion-laughs DoS Pre-parse entity stripping All External Entities Purged
javascript: URIs Protocol execution via href & xlink:href Strict URI protocol filtering Safe Fragments & Links Only
Deep-Dive Technical Reference

Explore how attackers weaponize vector graphics and how edge servers enforce Content-Security-Policy sandboxing: read our full architectural analysis on Why SVG Files Are Actually Executable Code (And How to Host Them Safely).

100% In-Browser DOMParser Guarantee

Your proprietary vector logos, illustrations, and design assets are parsed and sanitized entirely within your local browser memory. No code or graphics are ever sent to our servers during purification.

Frequently Asked Questions

Why are SVG files security hazards compared to PNG or JPEG images?
Unlike raster images that store static pixel grids, Scalable Vector Graphics are XML documents parsed directly into an active Document Object Model. This means an SVG file can harbor live executable script tags, inline event listeners like onload, and XHTML objects capable of triggering Stored Cross-Site Scripting.
What is the direct navigation trap for SVG files?
When an SVG is embedded inside an img tag, web browsers disable scripting. However, if a user opens the direct image URL in a browser tab, the SVG executes as a top-level XML document with full origin script privileges. Our sanitizer purges dangerous nodes so SVGs remain completely safe in all contexts.
Will sanitizing my SVG alter its visual design or vector geometry?
No. The sanitizer only strips executable payloads such as script blocks, foreignObject nodes, and event attributes. Safe graphic primitives including path, circle, rect, polygon, and gradient definitions remain completely intact.
Does this tool protect against XML External Entity (XXE) attacks?
Yes. Our client-side sanitizer automatically strips all DOCTYPE and ENTITY declarations before XML parsing, eradicating XXE file disclosure exploits and recursive billion-laughs denial-of-service payloads.
Are my SVG vector files sent to your servers for processing?
Never. All AST inspection, XML manipulation, and serialization occur 100% inside your browser's local DOMParser memory. Zero vector data touches our servers.