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.
Quick Take
- What: CVE-2026-122006 allows arbitrary file write and read through ImageMagick coders in Rails Active Storage
- Who is affected: Rails applications using ImageMagick (mini_magick variant processor) that accept file uploads from untrusted users
- Severity: Critical (CVSS 9.8), no authentication required, can lead to remote code execution
- Fixed versions: activestorage 8.1.4.1 and 8.0.5.2
- 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.



