---
title: "Critical Active Storage flaw: is your Rails app exposed? What now?"
description: "Rails 8.1.4.1 and 8.0.5.2 fix 21 security issues. In the worst, an upload from an unauthenticated attacker may write files on the server when ImageMagick processes images. Update, and rotate secrets if files sit on Disk."
url: https://ihsanalapsi.dev/articles/rails-active-storage-critical-file-write
lang: en
date: 2026-11-09
updated: 2026-11-09
tags: ["Security updates", "App security", "Web development"]
author: Ihsan Alapsi (إحسان العبسي)
---
# Critical Active Storage flaw: is your Rails app exposed? What now?

If you run a Rails app that accepts files from users and stores them with Active Storage, this update comes before anything else on your list. According to the [official Rails release announcement](https://rubyonrails.org/2026/11/4/Rails-8.0.5.2-and-8.1.4.1-have-been-released), versions 8.1.4.1 and 8.0.5.2 came out on November 4, 2026 and fix 21 security issues, one of them Critical. By the end of this article you will know whether your app is exposed, which version to install, and what to do if you cannot update today.

## What is the critical Active Storage flaw?

The Active Storage flaw GHSA-f3w6-w445-fwh9 may let an unauthenticated attacker write files on your server just by uploading a crafted file, when your app processes images with ImageMagick. It is rated Critical, 9.8 out of 10.

ImageMagick is a tool on the server that opens and converts images. It picks the way it reads a file (the coder) from the file's content, and some coders work on other files named inside the image, not on the image itself. According to the [Rails security advisory for the flaw](https://github.com/rails/rails/security/advisories/GHSA-f3w6-w445-fwh9), Active Storage restricted none of those coders, and the image analyzer runs the moment a file is attached to a record. So the attacker does not need your app to ask for a `variant`, a `preview` or an `analyze` call: attaching the upload is enough.

The mistake is one of logic before code: the file that anyone uploads decides how it gets read, and the app put no limit on what it may ask for.

Writing files is not the end of it. If attachments are stored with the Disk service, the attacker may also read any file the application process can read, and those usually include `secret_key_base` and credentials for other systems. From there, the advisory says, they may reach remote code execution or those other systems. The advisory is also frank on one more point: one attack chain was reported to the Rails team, and they do not assume it is the only one.

## Which Rails apps are exposed?

A Rails app is exposed to the critical flaw when three conditions meet: it processes images with ImageMagick, the ImageMagick policy on the server does not deny the coders involved, and it accepts files from users you do not trust.

1. Your app processes images with `:mini_magick`, which means `config.active_storage.variant_processor = :mini_magick`, the default for apps on `load_defaults 6.1` or earlier. So if you upgraded Rails but left `load_defaults` at 6.1, your app may be on it without you noticing.
2. The ImageMagick policy on your server does not deny those coders. The advisory says the policies that Debian and Ubuntu package do not, so a plain server that nobody has hardened meets this condition.
3. Your app accepts files from untrusted users: a profile picture, an attachment on a support message, or any form with a file field.

Reading files takes a fourth condition: your attachments are stored with the Disk service, on the server's own disk.

The second condition is a reminder of the [two PHP2Shell flaws in PHP itself](/articles/php2shell-php-rce): the risk sits in a layer under your code, in a tool on the server and its default settings, not in a line you wrote.

To find out where you stand, run these from the project folder:

```bash
grep -rn "load_defaults\|variant_processor" config/
grep -n "service:" config/storage.yml
grep -n "active_storage.service" config/environments/production.rb
```

If you see `variant_processor = :mini_magick`, or `load_defaults` at 6.1 or earlier with no `variant_processor` line that changes it, your app is on ImageMagick. And if the service your production environment uses has `service: Disk` in `storage.yml`, your files are on the server's disk.

## Which version should you update to, and how?

Update to Rails 8.1.4.1 if your app is on 8.1, or to Rails 8.0.5.2 if it is on 8.0. Those are the two patched versions the advisory names, and they ship an ImageMagick policy that denies the risky coders.

1. Check the version you are running:
   ```bash
   bundle exec rails -v
   ```
2. Update Rails. If your `Gemfile` pins an exact version, change it first to `8.1.4.1` or `8.0.5.2`:
   ```bash
   bundle update rails
   ```
3. If your image processor is `:mini_magick`, update `mini_magick` too. The new policy needs 5.1 or later, and with an older one the app raises an error at boot:
   ```bash
   bundle update mini_magick
   ```
4. Make sure the policy is loaded. The [official Active Storage guide](https://guides.rubyonrails.org/active_storage_overview.html) gives this command, because the policy path is set in MiniMagick's settings, not in the shell:
   ```bash
   bin/rails runner 'puts MiniMagick.identify { |i| i.list "policy" }'
   ```

Watch for a few cases after the update. If your app renders PDF or PostScript through ImageMagick, you have to re-allow the `gs` delegate and the coders you use in the server's `policy.xml`. If your app replaces `MiniMagick.cli_env` after boot, clears the environment with `MiniMagick.cli_prefix`, or installs its own `MiniMagick::Shell`, the policy that ships with Rails does not reach it, so you have to put its rules in the system policy. The same goes for GraphicsMagick: it does not read ImageMagick policies at all. And any rule in the server's policy that allows a coder, even a wildcard such as `pattern="*"`, overrides the deny that ships with Rails, so allow only what you use.

### What else does the update fix?

The rest of the release, by the announcement's own labels: 4 High, 13 Medium and 3 Low. The ones worth knowing:

- A second High flaw in Active Storage, GHSA-v924-7rp8-4mxh, rated 8.8: file read and remote code execution through video previews, video analysis and image processing. The tools pick a decoder from the file extension when the content does not say what it is, and the attacker chooses the name.
- A Strong Parameters bypass in `Parameters#each_key`.
- IP spoofing in `remote_ip` through the `Forwarded` header, in 8.1 only.
- Several XSS flaws in Action View helpers.
- Session issues: a destroyed session restored by `CacheStore`, a session cookie leaked by Active Storage proxy mode, and a missing `SameSite` attribute on session cookies. If you want to check those attributes on your own site, we have an article on [how to check your session cookie: HttpOnly, Secure, SameSite](/articles/session-cookie-flags-check).

## What can you do if you cannot update today?

Copy the rules of the ImageMagick policy that the patched versions ship into the system policy on your server. The advisory says that at a minimum you should deny the MSL coder, the Ghostscript coders and the gs delegate.

The full policy is at `activestorage/lib/active_storage/image_magick/policy.xml` in the source, and the system policy lives at a path such as `/etc/ImageMagick-7/policy.xml`. These are the three lines the advisory gives as the minimum:

```xml
<policy domain="coder" rights="none" pattern="MSL"/>
<policy domain="delegate" rights="none" pattern="gs"/>
<policy domain="coder" rights="none" pattern="{PS,PS2,PS3,EPS,EPS2,EPS3,EPI,EPSF,EPSI,EPT,EPT2,EPT3,PDF,AI,EPDF,PDFA,POCKETMOD,XPS,PCL}"/>
```

Then check the active policy with the command from the [security policy page on the ImageMagick site](https://imagemagick.org/security-policy/):

```bash
magick identify -list policy
```

The advisory also links a patch for each branch, 8.1 and 8.0, if you want to apply it yourself until you can update.

For the High video flaw, its advisory gives a second stopgap: stop Active Storage from running FFmpeg on uploaded files. Remove `ActiveStorage::Previewer::VideoPreviewer` from `config.active_storage.previewers`, and `ActiveStorage::Analyzer::VideoAnalyzer` and `ActiveStorage::Analyzer::AudioAnalyzer` from `config.active_storage.analyzers`.

## If your files are on Disk, why rotate your secrets?

If your attachments are on the Disk service, the attacker may have read `secret_key_base` and your credentials before you updated, and the update closes the hole without undoing what was read. That is why the advisory asks you to change them.

What to change, per the advisory:

- `secret_key_base`.
- The master key, and everything in `config/credentials.yml.enc`.
- Storage and database credentials.
- Third-party tokens.

Do not keep any exposed secret as a fallback; the advisory says so in those words. And according to the [advisory for the High flaw GHSA-v924-7rp8-4mxh](https://github.com/rails/rails/security/advisories/GHSA-v924-7rp8-4mxh) from the same release, changing `secret_key_base` expires active sessions and invalidates signed and encrypted cookies, signed global IDs and Active Storage URLs. So plan for every user to sign in again.

If you want a practical order for rotating secrets, we have an article on [the Railway breach and which secrets to rotate first](/articles/railway-breach-env-vars-rotate-secrets).

## Why plan the move from Rails 8.0 to 8.1?

Security support for the Rails 8.0 series ended on November 7, 2026, so a flaw found after that date will not get a new 8.0 release. The Rails 8.1 series gets security fixes until October 10, 2027.

Under the [Rails maintenance policy](https://rubyonrails.org/maintenance), each series gets security fixes for two years after its first release. After that, a fix may be published to git, but no new version is released, and dealing with the flaw is your own job. So 8.0.5.2 fixes today's flaws, and any fix released as a new version after that date will be for 8.1 or newer.

If you are still on Rails 7 or older, the release announcement says versions older than the 8.0 series are unsupported, and the advisory counts every `activestorage` below 8.0.5.2 as affected. So there is no patched version for your branch: the policy is a stopgap, and upgrading is the fix.

## Where do you start now?

Start with the app that accepts files from the public and stores them on Disk, because it has the most to lose. In order:

1. Run the `grep` commands above on every app you have, and note which ones are on `:mini_magick` and which use Disk.
2. Update the ones on 8.1 to 8.1.4.1 and the ones on 8.0 to 8.0.5.2, and check the policy with the `bin/rails runner` command.
3. If your files are on Disk, rotate your secrets the same day.
4. Set a date for the move from 8.0 to 8.1.

And if your app accepts files from the public and you are not sure what happens to them after upload, [Muhassan](/muhassan) finds the flaws in your platform before someone else does.

Which image processor is your app on right now: `:vips` or `:mini_magick`?

## FAQ

**My app processes images with vips, not ImageMagick. Do I still need to update?**

Yes. According to the advisory, the critical flaw needs ImageMagick as the image processor, so an app on vips does not meet its first condition. But the release fixes 21 issues, including XSS in Action View helpers and a Strong Parameters bypass, and those have nothing to do with the image processor.

**My app takes no uploads from visitors, but signed-in users upload profile pictures. Am I safe?**

Not for sure. The advisory's condition is that the app accepts uploads from untrusted users, and an ordinary account that anyone can open is an untrusted user. The safe move is to update and treat yourself as exposed.

**Is updating ImageMagick on the server enough?**

No. The advisory does not list an ImageMagick update as a fix. The fix is updating activestorage, or as a stopgap an ImageMagick policy that denies the risky coders.

**What happens to my users if I change secret_key_base?**

Active sessions expire, and signed and encrypted cookies and Active Storage URLs stop working, so everyone signs in again. Do not keep the old value as a fallback: the advisory says so in those words.

**My app is on Rails 7. Is there a fixed version for me?**

No. The advisory counts every activestorage version below 8.0.5.2 as affected, and the only patched versions are 8.1.4.1 and 8.0.5.2. The stopgap is the ImageMagick policy, and the lasting fix is upgrading.
