Skip to content

Follow-up: allow safe data:image/* schemes via url_filter in SVG sanitizer #5851

Closed as not planned

Description

@jeongbeannnn

Follow-up to #5514.

The SVG sanitizer added in that fix currently blocks every data: URL inside SVG attributes (href, xlink:href, etc.) as a conservative default. That's the right call for the immediate XSS fix — data:image/svg+xml and data:text/html are real vectors, and dropping them outright avoids whack-a-mole on MIME parsing edge cases.

Per @'s comment (#5514 (comment)), opening this so the narrower whitelist doesn't get forgotten.

What's left to do

Wire a url_filter (or equivalent attribute callback) into the sanitizer so the scheme check can distinguish safe raster MIME types from script-capable ones:

  • allow: data:image/png, data:image/jpeg, data:image/gif, data:image/webp
  • keep blocking: data:image/svg+xml, data:text/html, data:application/*, anything ambiguous
  • keep blocking: javascript:, vbscript:, plain data: with no MIME, MIME with stray whitespace/control chars

Why it's worth doing later (not now)

In ADK today, raster artifacts surface as their own image/* blobs rather than embedded inside SVG, so the current block doesn't degrade the dev UI. But once user-supplied SVGs from external sources show up (e.g., LLM-generated diagrams that inline a small PNG legend), the strict block will start cutting legitimate content. Better to land the relaxation behind a tested filter than to loosen the regex under pressure.

Suggested tests

# allow
assert sanitize('<svg><image href="data:image/png;base64,iVBORw0K..."/></svg>')  # preserved

# block
assert 'data:' not in sanitize('<svg><image href="data:image/svg+xml;base64,..."/></svg>')
assert 'data:' not in sanitize('<svg><image href="data:text/html,<script>alert(1)</script>"/></svg>')
assert 'data:' not in sanitize('<svg><image href="data:image/png ;base64,..."/></svg>')  # stray space

Activity

  1. added
    web
    on May 26, 2026
  2. added theissue type on May 26, 2026
  3. sanketpatil06 commented on May 26, 2026

    @sanketpatil06

    Hi @jeongbeannnn , Thanks for the update. The request is currently being reviewed by our team, and we will let you know if anything further is needed. Thank you for understanding.

  4. self-assigned this
    on Sep 16, 2026
  5. GWeale commented on Sep 16, 2026

    @GWeale
    Collaborator

    no svg sanitizer ever landed here. #5515 was closed on 11 september on the view that ad-hoc svg sanitization is the wrong mitigation, and #5514 was fixed in google/adk-web#514, which downgrades scriptable artifact blobs so they download instead of rendering.

    so there's nothing with a url_filter to relax. closing because the approach this tracks was dropped, not because the analysis was wrong. open a new issue if an svg still renders on a current version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

web

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions