Rails apps that use ImageMagick: one crafted upload can write files on the server. Upgrade this week

By George Bailey   Published: 11/05/26   4 min read

Rails has fixed a critical flaw in Active Storage, the part of the framework that handles file uploads. If an app processes images with ImageMagick, an attacker with no account can upload a crafted file and write files on the server. Simply attaching the upload is enough.

Get the CyberExperts Daily Brief: the day's top security news in 5 minutes. Free.

Apps that keep uploads on the server’s own disk have a second problem. The same bug can read any file the app can read, including the secret key that signs sessions.

On a Rails app that uses ImageMagick, one crafted upload can write files on the server. Attaching it is enough.

A crafted image upload can write files on a Rails server

Rails released 8.1.4.1 and 8.0.5.2 on November 4 with fixes for 21 security issues. The worst is GHSA-f3w6-w445-fwh9, rated critical at 9.8. It has no CVE number yet.

According to the advisory and the fix commit, Active Storage’s image analyzer passed uploads to ImageMagick without limiting which format handlers it could use. An uploaded SVG could reach ImageMagick’s MSL scripting handler, which reads and writes files named in the script. RyotaK of GMO Flatt Security reported it through HackerOne.

A second Active Storage flaw in the same releases, GHSA-v924-7rp8-4mxh (high), let an attacker choose which decoder ImageMagick or FFmpeg used by picking the upload’s filename.

Rails apps that still hand uploads to ImageMagick

Three things must be true. The app uses :mini_magick for Active Storage, which is the default for apps still on load_defaults 6.1 or earlier. Its server’s ImageMagick policy does not block the handlers involved, and Rails says the policies Debian and Ubuntu ship do not. And it accepts uploads from people it does not trust, such as profile photos or support attachments.

Rails 8.0 gets security fixes only until November 7, two days from now. Series older than 8.0 get no fixed release at all.

Upgrade to 8.1.4.1 or 8.0.5.2 and confirm the new policy loads

Forward this

For whoever owns our Ruby on Rails apps: Rails fixed a critical upload bug that lets an attacker write files on the server if the app uses ImageMagick. Can we upgrade to 8.1.4.1 or 8.0.5.2 this week and, for apps that store uploads on local disk, rotate the app secrets?

Details

Hunt / verify

Source: Rails advisory GHSA-f3w6-w445-fwh9; Rails 8.0.5.2 and 8.1.4.1 release

Sources

George Bailey

George Bailey is the byline of the CyberExperts editorial desk, the team behind the CyberExperts Daily Brief. The desk covers vulnerabilities, breaches and security news from vendor advisories, CISA alerts and other primary sources, and links those sources in every story. Questions or corrections: [email protected].