proof-of-concept: sanitise via bundled svg-hush, remove bespoke sanitizer#1
Draft
davidtaylorhq wants to merge 1 commit into
Draft
proof-of-concept: sanitise via bundled svg-hush, remove bespoke sanitizer#1davidtaylorhq wants to merge 1 commit into
svg-hush, remove bespoke sanitizer#1davidtaylorhq wants to merge 1 commit into
Conversation
Replace the in-house REXML/`SvgCss` SVG sanitizer with Cloudflare's memory-safe, fuzzed `svg-hush`, bundled as a prebuilt per-platform binary and run through the existing argv-only + Landlock path (no FFI). This deletes ~1.5k lines of bespoke parsing/CSS-allowlist code and the bug class that came with it: the prior `delete_attribute(local_name)` path let a namespace-prefixed `onload` survive on a real `<svg>` element, an executing same-origin XSS in `:standalone` output. `sanitize_svg!(path, max_pixels:)` now produces document-safe output only (the `id_namespace:` inline-into-DOM layer is removed). `SvgMetadata` still enforces the byte-size, encoding, and pixel pre-checks before the binary runs, so the `LimitError`/`InvalidImageError` hierarchy is unchanged. The operation no longer routes through the sandbox worker; `svg-hush` is its own sandboxed subprocess, and `Sandbox.capture_command!` now grants Landlock execute on the command's own directory so a gem-bundled binary outside the system bin dirs can run. Binaries are produced by `script/build-svg-hush.sh` from a pinned `svg-hush` version and vendored under `vendor/svg-hush/`; an unbundled platform raises rather than compiling at install.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(AI-authored experiment. Unsuitable for merge)
Replace the in-house REXML/
SvgCssSVG sanitizer with Cloudflare's memory-safe, fuzzedsvg-hush, bundled as a prebuilt per-platform binary and run through the existing argv-only + Landlock path (no FFI). This deletes ~1.5k lines of bespoke parsing/CSS-allowlist code and the bug class that came with it: the priordelete_attribute(local_name)path let a namespace-prefixedonloadsurvive on a real<svg>element, an executing same-origin XSS in:standaloneoutput.sanitize_svg!(path, max_pixels:)now produces document-safe output only (theid_namespace:inline-into-DOM layer is removed).SvgMetadatastill enforces the byte-size, encoding, and pixel pre-checks before the binary runs, so theLimitError/InvalidImageErrorhierarchy is unchanged. The operation no longer routes through the sandbox worker;svg-hushis its own sandboxed subprocess, andSandbox.capture_command!now grants Landlock execute on the command's own directory so a gem-bundled binary outside the system bin dirs can run.Binaries are produced by
script/build-svg-hush.shfrom a pinnedsvg-hushversion and vendored undervendor/svg-hush/; an unbundled platform raises rather than compiling at install.