RubySec

Providing security resources for the Ruby community

GHSA-v99p-m5vm-fqqc (image_processing): Command execution through MiniMagick option names

Command execution through MiniMagick option names

Published: November 21, 2026

SECURITY IDENTIFIERS

GEM

image_processing

SEVERITY

CVSS v3.x: 9.8 (Critical)

PATCHED VERSIONS

>= 2.0.1

DESCRIPTION

Impact

When MiniMagick loader or saver option names come from unsanitized user input, an attacker can execute arbitrary shell commands.

The fix for CVE-2022-24720 (GHSA-cxf7-qrc5-9446) only covered #apply, so applications that sanitize #apply input but pass user-controlled option names to #loader or #saver remain vulnerable. Exploitation does not depend on the web framework: this affects Rails, Sinatra, Hanami and plain Ruby scripts or CLI tools alike. ImageProcessing::Vips is not affected.

Patches

The vulnerability has been fixed in version 2.0.1 of image_processing, which dispatches loader/saver options with public_send. Later releases (2.0.3, 2.2.1) harden this path further, so upgrading to the latest version is recommended.

Workarounds

Never pass user-controlled hash keys to #loader or #saver. If option names need to come from user input, filter them against an allowlist of the options you support:

ALLOWED = %w[quality strip interlace]
options = params[:saver].to_h.select { |name, _| ALLOWED.include?(name) }

ImageProcessing::MiniMagick.source(file).saver(**options.transform_keys(&:to_sym)).call

RELATED