/

CVE-2025-24293

Severity:

HIGH RISK

(8.1)

Command Injection (CWE-77) via Rails Active Storage

CVE-2025-24293

Deferred

Vulnerability type

Category:

Command Injection

CWE:

CWE-77, CWE-94, CWE-88

Impact:

Arbitrary Command Execution via Image Processing Pipeline

Severity:

HIGH RISK

(8.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A command injection risk exists in Ruby on Rails Active Storage when user-supplied input is passed directly into image transformation methods and parameters.

In configurations using the image_processing gem with mini_magick, unsafe transformations can bypass default protections and may allow attackers to trigger arbitrary ImageMagick commands under certain conditions.

Affected context

This vulnerability occurs in Rails applications using Active Storage together with the image_processing gem configured to use mini_magick as the underlying processor.

It becomes risky when templates or controllers accept arbitrary user input as transformation methods or arguments, such as blob.variant(params[:t] => params[:v]), without strict validation.

The issue is tied to how image processing operations are translated into ImageMagick commands, and manifests when application-level safeguards are bypassed or misused.

Exploit preconditions

  • Attack surface: Web-facing endpoints that render or process images via Active Storage variants.
  • Required access: Ability to supply or influence transformation method names or parameters (e.g., HTTP query parameters, form fields, JSON body).
  • Trigger point: Invocation of blob.variant or similar APIs that construct image transformations from untrusted input, which are then executed through mini_magick/ImageMagick.
  • Why exploitation is possible: Certain allowed transformation methods and parameter combinations can be abused to circumvent Active Storage's safety defaults and cause crafted arguments to be passed into ImageMagick, enabling command execution primitives.

Why this happens

The underlying bug class is command injection arising from unsafe composition of shell-executed commands using untrusted data.

In this case, the image processing pipeline translates Ruby-level transformation options into ImageMagick command-line invocations via mini_magick.

When developers treat user-supplied transformation methods and parameters as trusted and pass them directly into these APIs, they create a path where unvalidated input can influence command construction and execution.

This maps to CWE-77: Command Injection, and also relates to CWE-94/88 where untrusted inputs control executable behavior in an underlying tool or interpreter.

Potential impact

  • Attackers may execute arbitrary ImageMagick commands with the privileges of the application process.
  • Attackers could read, modify, or delete files accessible to the web application user.
  • Attackers can perform server-side request forgery (SSRF) or data exfiltration via ImageMagick features, depending on configuration.
  • Attackers may pivot to broader system compromise if the process has elevated permissions or weak isolation.

General mitigation guidance

Effective mitigation focuses on removing trust from user-controlled transformation input and tightening the image processing boundary.

Recommended patterns include:

  • Defining a fixed, application-controlled set of allowed transformations (e.g., named presets) rather than accepting methods/parameters directly from users.
  • Performing strict validation and whitelisting of any transformation options that originate from external sources, ensuring they map only to safe operations.
  • Applying a strong, restrictive ImageMagick security policy that disables risky coders, delegates, and file system or network access features.
  • Running image processing components with least privilege and in isolated environments (separate worker, container, or sandbox) to limit blast radius if misconfiguration occurs.
  • Treating all image transformation configuration as code, not data, and subjecting changes to code review and security scrutiny.

How teams detect issues like this

Detection typically involves a combination of code-level and configuration-level review:

  • Static analysis rules or custom linters that flag uses of blob.variant or other image processing APIs where parameters are derived directly from params, request bodies, or other untrusted sources.
  • Code review checklists that require auditing views and controllers for dynamic image transformation logic and ensure all transformations come from a controlled set of options.
  • Configuration audits of ImageMagick security policy files to verify that dangerous coders, delegates, or command features are disabled.
  • Runtime monitoring for unusual or unexpected ImageMagick command invocations, particularly those involving external network access or shell delegation.
  • Integration of automated security scanners that understand common command injection patterns in image processing libraries and flag risky usages.

Sources

SourceLink
github.comgithub.com/advisories/GHSA-r4mg-4433-c7g3
access.redhat.comaccess.redhat.com/security/cve/CVE-2025-24293
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2435565
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2025/cve-2025-24293.json

Frequently asked

questions

Yes. If a web endpoint accepts user-controlled transformation methods or parameters and passes them into Active Storage variants, a remote attacker can exploit the issue via crafted HTTP requests.

The attacker needs the ability to influence the image transformation options, typically through request parameters or form inputs. No direct shell access is required; exploitation occurs through the normal image processing workflow.

The safest pattern is to eliminate dynamic, user-driven transformations and restrict all variants to a predefined set of server-side configurations. Any remaining input that affects transformations must be strictly validated against a whitelist of safe operations and arguments.

Treat all data that can influence commands, interpreters, or external tools as untrusted. Use fixed transformation profiles, rigorous input validation, strong security policies for underlying tools like ImageMagick, and include command injection checks in code review and automated security testing.

Find out what's already
exploitable in your codebase.