Skip to content

fix(sandbox): validate view_image raster content - #4462

Merged
seratch merged 1 commit into
mainfrom
fix/view-image-content-validation-takeover
Aug 16, 2026
Merged

seratch merged 1 commit into
mainfrom
fix/view-image-content-validation-takeover

Conversation

@seratch

@seratch seratch commented Aug 16, 2026

Copy link
Copy Markdown
Member

This pull request supersedes #4450 and fixes view_image so raster-looking filenames cannot authorize arbitrary bytes as structured image output.

Raster formats now require one of the existing byte signatures, while SVG and SVGZ retain their released filename fallback through explicit case-insensitive suffix checks. Unlike #4450's latest implementation, this does not delegate the fallback decision to Python's mutable, environment-dependent MIME registry. Applications can customize that registry with mimetypes.add_type(), which could otherwise map .png or another raster extension to image/svg+xml and reopen the filename-based bypass. Checking .svg and .svgz directly keeps the trust boundary deterministic while preserving UTF-8 prolog variants, UTF-16 SVG, and compressed SVGZ compatibility.

Focused regression coverage verifies raster-extension rejection, registry-mutation resistance, signature-based raster acceptance, and the supported SVG/SVGZ compatibility cases.

@seratch seratch added this to the 0.21.x milestone Aug 16, 2026
@seratch
seratch enabled auto-merge (squash) August 16, 2026 09:03
@seratch
seratch merged commit 4cb461a into main Aug 16, 2026
14 checks passed
@seratch
seratch deleted the fix/view-image-content-validation-takeover branch August 16, 2026 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant