CVE-2026-122006: Rails Active Storage arbitrary file write and read via ImageMagick

A critical vulnerability in Rails Active Storage allows unauthenticated attackers to write and read arbitrary files on the server when processing image attachments with ImageMagick, potentially exposing secrets and enabling remote code execution.

Christopher Ort
By i10X News Desk · Reviewed by Christopher Ort · 3 min read
Share
A server room with racks of computers, red warning lights illuminating the equipment, suggesting a critical security incident requiring immediate attention
Image: AI-generated, i10X
On this page
  1. Quick Take
  2. In plain English
  3. What happened
  4. What you should do
  5. What it means
  6. Sources

A critical vulnerability in Ruby on Rails Active Storage allows unauthenticated attackers to write arbitrary files on the server and read sensitive files when applications process image attachments with ImageMagick. The flaw, tracked as CVE-2026-122006, was responsibly disclosed by HackerOne researcher ryotak and affects applications using the mini_magick variant processor.

i10X Quick Take

Quick Take

  1. What: CVE-2026-122006 allows arbitrary file write and read through ImageMagick coders in Rails Active Storage
  2. Who is affected: Rails applications using ImageMagick (mini_magick variant processor) that accept file uploads from untrusted users
  3. Severity: Critical (CVSS 9.8), no authentication required, can lead to remote code execution
  4. Fixed versions: activestorage 8.1.4.1 and 8.0.5.2
  5. What to do: Upgrade to patched versions immediately and rotate all secrets if using Disk storage service

In plain English

Rails is a popular web framework, and Active Storage is its file upload system. When Rails applications use ImageMagick to process uploaded images, attackers can upload specially crafted files that trick ImageMagick into reading or writing files anywhere on the server instead of just processing the image. This happens because ImageMagick has special “coders” that can act on filenames inside the image file itself. Attackers can steal secret keys and passwords stored on the server, which could let them take over the entire application or connected systems.

What you should do: If you run a Rails application that accepts image uploads, you need to upgrade immediately to version 8.1.4.1 or 8.0.5.2 and change all your secret keys. If you don’t run Rails applications, you can ignore this.

What happened

ImageMagick selects a coder based on the content of files it processes, and some coders act on files named inside the image rather than on the image itself. Active Storage did not constrain any of ImageMagick’s coders, and the ImageMagick analyzer runs automatically when a file is attached. An attacker who can upload a crafted file can invoke dangerous coders without needing to trigger any variant, preview, or analyze call.

The vulnerability allows attackers to:

  • Write arbitrary files on the server
  • Read arbitrary files readable by the application process when attachments are stored with the Disk service
  • Access secret_key_base and credentials for external systems
  • Potentially escalate to remote code execution or lateral movement to connected systems

The Rails team noted that one specific attack chain has been reported, but they do not assume it is the only one that exists.

What you should do

Upgrade to activestorage 8.1.4.1 or 8.0.5.2 immediately. Applications using mini_magick as the variant processor must also use mini_magick 5.1 or later, which the policy requires. With an older mini_magick version, applications will raise an exception during boot.

If attachments are stored with the Disk service, change secret_key_base and every secret readable by the application process, including:

  • The master key
  • Everything in config/credentials.yml.enc
  • Storage and database credentials
  • Third-party tokens

Do not retain an exposed secret as a fallback.

Applications that render PostScript or PDF through ImageMagick must re-allow the gs delegate and the coders it uses in the host’s policy.xml.

What it means

The fixed versions ship an ImageMagick security policy and prepend its directory to MAGICK_CONFIGURE_PATH through MiniMagick.cli_env, so every ImageMagick process that MiniMagick spawns applies it. The policy denies:

  • The MSL scripting coder
  • Coders that read or delete files other than the image
  • Coders that fetch remote or local references or display to a screen
  • Every coder backed by Ghostscript together with the gs delegate
  • @filename indirection

ImageMagick applies every policy.xml on its search path, so the shipped policy adds to the host’s policy rather than replacing it. The policy applies to every ImageMagick command that MiniMagick runs, not only those of Active Storage.

Applications are affected if they meet all of these requirements:

  • Use ImageMagick for Active Storage image processing (config.active_storage.variant_processor = :mini_magick, the default for applications on load_defaults 6.1 or earlier)
  • Run ImageMagick under a security policy that does not already deny the coders involved (Debian and Ubuntu packaged policies do not)
  • Allow file uploads from untrusted users

As a workaround for those who cannot upgrade immediately, copy the rules from activestorage/lib/active_storage/image_magick/policy.xml into ImageMagick’s system policy (for example /etc/ImageMagick-7/policy.xml). At a minimum, deny the MSL coder, the Ghostscript coders, and the gs delegate.

Sources

Christopher Ort

Christopher Ort

Christopher Ort is the editor of i10X News at i10x.ai. He has worked hands-on with AI tools, models and agent workflows for years and leads i10X’s coverage of AI launches, funding and research. He is the author of “The Style Penalty”, an SSRN study on how frontier AI models judge AI-written CVs, covered by heise online and t3n.

Editor's picks

  1. Georgia Tech’s Academic AI Playbook: 20 Lessons From 67 Real Courses, Free to Reuse
  2. Arcfront’s $1B Run Rate: What the AI Data Startup Confirms and What It Doesn’t
  3. GPT-6.2 Astra Tops Blueprint-Bench 2, 70% Above May Leader GPT-5.5
  4. Deutsche Telekom Puts 100 Million Euros Into Mistral for Sovereign AI in Germany
  5. Inkling 2 Mini: Thinking Machines’ Looped Open Model Tops Qwen on Coding Tests