1-minute read of a 5 min report

Rails Image Upload Flaw Lets Attackers Write Server Files

By

1-minute read

What a defender needs to know

Rails fixed a critical Active Storage image-processing flaw in activestorage 8.1.4.1 and 8.0.5.2. An unauthenticated attacker who can upload an attachment to an affected application may cause ImageMagick to write server files. With Active Storage’s Disk service, the same weakness may expose files readable by the Rails process, including secret_key_base and credentials for connected systems. Analysis runs when the file is attached; a separate preview request is unnecessary. Rails tracks the issue as GHSA-f3w6-w445-fwh9.

Scope applications that accept untrusted uploads, set the Active Storage variant processor to :mini_magick, and permit the relevant ImageMagick coders under their effective policy. Upgrade activestorage; for :mini_magick, require mini_magick 5.1 or later and confirm web and worker processes boot. Check the actual ImageMagick policy: custom MiniMagick.cli_env, MiniMagick.cli_prefix or MiniMagick::Shell integrations can bypass the policy shipped with Rails. Enforce the corresponding rules in the system policy if the shipped one is bypassed.

For Disk-service attachments, rotate every secret readable by the application, including the master key, secret_key_base, everything in config/credentials.yml.enc, storage and database credentials, and third-party tokens. Remove old fallback secrets and confirm they fail authentication. Socket’s free interim patch covers this GHSA alone; the Rails upgrade also addresses other issues in the November release.

Primary sources