Repository navigation
Restrict ImageMagick policy to block ImageTragick-class coders - #1577
Merged
Merged
Conversation
The empty policy.xml override re-enabled every ImageMagick coder, including URL/HTTP(S), MVG, MSL, TEXT, the "@" indirect file read, and the Ghostscript-backed PS/EPS/PDF/XPS coders. Notebooks opening untrusted dataset files with Wand were exposed to SSRF, local file disclosure, and Ghostscript RCE. Replace it with a restrictive policy that keeps common raster formats working and uses generous resource limits. PDF rasterization moves to pdf2image, which was already installed but broken because poppler-utils was missing. http://b/584415262
calderjo
approved these changes
Nov 16, 2026
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.
patches/imagemagick-policy.xmlreplaced the distro policy with an empty<policymap>. That re-enabled every ImageMagick coder. Any notebook opening an untrusted dataset file with Wand was exposed to:URL/HTTP/HTTPSlabel:@/pathandtext:MVG/MSLscriptingPS/EPS/PDF/XPS. Content sniffing means a.jpgwith a%PDF/%!PSheader also reaches Ghostscript.The empty policy was added in 2020 so Wand could read PDFs.
Changes
@*path pattern,EPHEMERAL,MVG,MSL,TEXT,SHOW,WIN,PLT, and all Ghostscript-backed coders (incl.PDF).poppler-utils.pdf2imagewas already installed but unusable withoutpdftoppm; it is now the supported way to rasterize PDFs.test_pytesseractusespdf2imageinstead of Wand to read the PDF.test_wand.py: checks that raster reads work and that PDF (filename and blob), PostScript,label:@,text:, MVG, MSL and URL reads raisePolicyError.Behavior change:
wand.image.Image(filename='x.pdf')now raisesPolicyError. Usepdf2image.convert_from_pathinstead.Testing: Ran
tests/test_wand.pyandtests/test_pytesseract.pyin the current staging image with the new policy copied in andpoppler-utilsinstalled: 12 passed. With the old empty policy, the Wand suite crashes.http://b/584415262