Review 14.3 Merged

97725[SECURITY] Do not trust libmagic file type for ImageMagick coder

Benjamin Franzke CR +2 V +2 Normal +79 −8 updated 11/17/26, 10:34

Commit message

ImageMagickFile::resolvePrefix() used the file extension reported
by libmagic for any "image/*" mime-type as ImageMagick/GraphicsMagick
coder. This extension is derived from the file contents, which are
controlled by whoever uploaded the file. A file containing MVG
instructions is detected as "image/x-mvg", which resolved to the
"mvg:" coder, even for files named "image.png". Rendering MVG allows
reading arbitrary local files into the processed image.

The extension provided by libmagic is now only used if it is part
of the allowed raster formats, or if the mime-type has been
configured explicitly by a system maintainer in
"SYS/FileInfo/fileExtensionToMimeType". Otherwise the regular
file extension allowlist applies, which forces a safe raster coder
(e.g. "png:") or rejects the file.

Formats which are not part of the default image file extensions
(e.g. "psd" or "ppm") need to be configured explicitly in
"fileExtensionToMimeType" to be processed by ImageMagick.

Review

  • Code review CR +2 Done
    • Benjamin Franzke +2
  • Verified V +2 Done
    • Benjamin Franzke +2

Issues 2

Files 5

Review log 2

  1. Benjamin Franzke wrote 11/17/26, 10:31

    Hashtag added: sec-2026-11
  2. Benjamin Franzke merged patch set 2 11/17/26, 10:34