skillfed

py_svg_hush

py-svg-hush v0.3.0 82.5K downloads/30d#14,160 on PyPI7
License unclear AGING released

What it is and what it does

py-svg-hush is a Python wrapper around Cloudflare's svg-hush Rust library that removes potentially malicious content from SVG files. It provides a single function, filter_svg, which takes SVG bytes and an optional dictionary of allowed MIME types for data URLs, then returns sanitized SVG bytes. The package strips dangerous elements and attributes while enforcing a whitelist of permitted data URL MIME types—any data URL whose type is not in the whitelist is dropped entirely.

The package is built as a compiled extension using Rust bindings, which means installation requires downloading or building wheels for your platform and Python version. It supports Python 3.10 through 3.14 on CPython and PyPy, with prebuilt wheels available for common architectures. The API is minimal and straightforward: one function call with two parameters, raising ValueError or TypeError on invalid input.

Use it for:

  • Sanitize user-uploaded SVG files in a web application before storing or displaying them.
  • Strip embedded scripts and event handlers from SVG graphics in a content management system.
  • Enforce a whitelist of allowed image MIME types in SVG data URLs to prevent unexpected content injection.
  • Batch-process a collection of SVG files to remove known attack vectors before distribution.
  • Validate SVG safety in a document processing pipeline that accepts external graphics.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Sanitizes SVG files by removing malicious elements, attributes, and restricting data URL MIME types through a Python wrapper around the svg-hush Rust library.

Yes, if you need to sanitize untrusted SVG input and can accept the license uncertainty. The package is straightforward, has no runtime dependencies, and benefits from battle-tested Rust logic. However, verify the license terms before use in proprietary or commercial contexts, and confirm that svg-hush's threat model matches your security requirements. The aging maintenance status (182 days since last release) is not a blocker for a stable utility, but monitor the repository for security updates.

Install

py-svg-hush on PyPI

pip

pip install py-svg-hush

uv

uv add py-svg-hush

poetry

poetry add py-svg-hush

Installing py_svg_hush

Before you install

Medium install friction due to compiled Rust bindings; wheels are available for Python 3.10–3.14 across Linux, macOS, and Windows. Last commit was 182 days ago and the project is marked as aging, though the repository remains active and unarchived.

License in practice

License status is unclear—no SPDX identifier or raw license text is recorded in the package metadata, so the legal terms for use and redistribution cannot be determined from the fact sheet.

Quickstart

pip install py-svg-hush

from py_svg_hush import filter_svg

svg_bytes = b'<svg>...</svg>'
keep_data_url_mime_types = {"image": ["jpeg", "png", "gif"]}
sanitized = filter_svg(svg_bytes, keep_data_url_mime_types)

Requires Python 3.10 or later.

Verify before relying

  • Whether the underlying svg-hush Rust library's security model and threat coverage are documented or audited.
  • What specific malicious elements and attributes are removed by filter_svg beyond data URL filtering.
  • Whether the package is actively maintained or in maintenance-only mode given the 182-day gap since last release.

Package facts

License not declared (unclear)
Python support supports the current Python release (>=3.10)
Install friction medium — platform-specific wheel
Runtime dependencies none
Maintenance aging — 182 days since the last release
Last repo commit
First released
Downloads 82,483/month — #14,160 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: py_svg_hush-0.3.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; py_svg_hush-0.3.0-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl; py_svg_hush-0.3.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl; py_svg_hush-0.3.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl; py_svg_hush-0.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; py_svg_hush-0.3.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl; py_svg_hush-0.3.0-cp310-cp310-musllinux_1_2_aarch64.whl; py_svg_hush-0.3.0-cp310-cp310-musllinux_1_2_armv7l.whl; py_svg_hush-0.3.0-cp310-cp310-musllinux_1_2_i686.whl; py_svg_hush-0.3.0-cp310-cp310-musllinux_1_2_x86_64.whl; py_svg_hush-0.3.0-cp310-cp310-win_amd64.whl; py_svg_hush-0.3.0-cp311-cp311-macosx_10_12_x86_64.whl; py_svg_hush-0.3.0-cp311-cp311-macosx_11_0_arm64.whl; py_svg_hush-0.3.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; py_svg_hush-0.3.0-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl; py_svg_hush-0.3.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl; py_svg_hush-0.3.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl; py_svg_hush-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; py_svg_hush-0.3.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl; py_svg_hush-0.3.0-cp311-cp311-musllinux_1_2_aarch64.whl

Programming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyProgramming Language :: Rust

Tags

svg sanitizationremove malicious svg contentsvg security filteringsvg data url filteringsvg xss preventionsvg element stripping
svg-securityrust-bindings

More Security packages