CVE-2026-66066: Rails Active Storage File Read Through libvips

If your Rails app takes image uploads from strangers and processes them with libvips, a crafted file may let an unauthenticated attacker read files from your server. Bumping the gem is the easy half. The fix depends on a native library that lives in your image and not in your Gemfile, and no upgrade brings back a secret that has already left.
| Field | Detail |
|---|---|
| Identifier | CVE-2026-66066, GHSA-xr9x-r78c-5hrm. Its finders call it KindaRails2Shell. |
| Affected | activestorage below 7.2.3.2, 8.0 below 8.0.5.1, 8.1 below 8.1.3.1, with the :vips processor and untrusted image uploads |
| Fixed in | 7.2.3.2, 8.0.5.1, 8.1.3.1 |
| Severity | 9.5 Critical, CVSS 4.0, scored by GitHub as the CNA according to NVD |
| Exploited as of 2026-07-31 | None known. Rails says it is not aware of any. Not in CISA KEV catalog 2026.07.27 when The Hacker News checked on July 29. |
| Disclosed | 2026-07-29, NVD published 2026-07-30 |
What is actually broken
libvips reads and writes formats through loaders and savers. It flags some of them as "unfuzzed", meaning unsafe for untrusted content, and several handle formats unrelated to web images. Active Storage did not disable these itself. image_processing 2.0 disables them when it loads, and a change on 8.2 edge then re-enabled them, according to the fix commit. The advisory's summary, as quoted on oss-security, is one line: "Active Storage did not disable the unfuzzed operations". The weakness class is CWE-1188, an insecure default.
The reported primitive, per The Hacker News, is a crafted MAT v7.3 file, an HDF5 container with an external dataset, which reads files from the server. Rails is careful here: one chain was reported and "we do not assume it is the only one that exists".
The file read is what matters first. The arbitrary files include the process environment, and the advisory says that environment "typically holds secret_key_base and often credentials for external systems, which may in turn allow escalation to remote code execution or lateral movement to those systems." The advisory title names code execution while its primitive is file read, and The Hacker News reports that a chain published by one of the finding teams reaches it through the same primitive plus CVE-2025-24293.
Two things must both be true: config.active_storage.variant_processor = :vips, and image uploads from untrusted users. The advisory text talks about causing a variant, but Rails also said "Generating variants is not a separate requirement". Never generating thumbnails does not clear you.
The advisory's version range is everything below 7.2.3.2. The finders, who reported it independently, list 7.0.0 onward in default configuration and 6.0.0 to 6.1.7.10 only when configured for Vips. Rails told The Hacker News that the researchers' range is accurate, and that the advisory covers the lines under security support: 7.2, 8.0 and 8.1. If you run 6.x with Vips, you are affected too.
What to do now
- Read the effective processor setting.
:vipscomes fromload_defaults 7.0, so check the value your app runs with. Apps on MiniMagick are reported as not exposed through this path. - Upgrade to 7.2.3.2, 8.0.5.1 or 8.1.3.1. Rails 7.1 and earlier are end of life and get no backport, so those apps have to move to a supported line.
- Rebuild on a libvips that can take the fix. The fix calls
Vips.block_untrusted(true)at boot and needs libvips 8.13 or later, plus ruby-vips 2.2.1 or later if installed. Otherwise Active Storage raises at boot. A gem bump can look fine in review and then refuse to start on an old base image. - If you cannot upgrade today, use a workaround from the advisory. On libvips 8.13 or later, set the
VIPS_BLOCK_UNTRUSTEDenvironment variable, which needs no Rails upgrade. With ruby-vips 2.2.1 or later, callVips.block_untrusted(true)from an initializer. Below libvips 8.13, the only workaround is removing the dependency. - Rotate if you were exposed, even with no sign of attack. "Upgrading closes the vulnerability but does not undo an exfiltrated secret." That means
secret_key_base, the master key andcredentials.yml.enccontents, Active Storage service credentials, database credentials and third-party keys. Do not keep an exposed secret as a fallback. Rotatingsecret_key_baseinvalidates sessions, signed and encrypted cookies, signed global IDs and Active Storage URLs, so schedule it. - Look back. The Rails forensics toolkit helps establish your exposure window and scans blobs for files whose first bytes claim MATLAB level 5 while the version field in the same 128-byte header sends libmatio to its HDF5 reader. It does not cover other places your app passes user files to libvips, and Rails says "A clean result from this tooling is strong evidence, not proof." Its investigation guide also explains what to pull from logs once the sweep has found crafted checksums: the upload requests, requests to the representations endpoint, destroy or update calls on signed-id routes, and rejected requests. Start that extraction early, because log retention is already running.
- Test your uploads after patching. BMP, ICO and PSD variants now raise
Vips::Error, as does FITS, JXL and ImageMagick-delegated output. SVG, JPEG XL, JPEG 2000 and Netpbm analysis no longer records width and height. You can re-enable a loader in an initializer, but do not on any path an untrusted user can reach.
Rails planned to hold details until August 28, but on July 31 it published them early because several researchers had already released proofs of concept. Treat the attack as public. The Hacker News separately reports a third-party proof of concept, which it "has not independently validated", alongside the chain one of the finding teams published.
Two scans, two halves of one bug
A code scan and an artifact scan are not the same control, and this bug shows why. My split:
| Question | Code scan (lockfile, config) | Artifact scan (built image) |
|---|---|---|
Is activestorage below a fixed version? | Yes | Yes |
Is the processor :vips? | Yes | Not usually |
| Which libvips is installed? | No | Yes |
| Which third-party libraries came with it? | No | Yes |
| Do untrusted users upload images? | No | No |
An SCA version match says the code is in range. It cannot say whether your workaround is even available, because that is decided by a libvips version your base image chose for you.
The image matters for exposure too. One of the finding teams, as relayed by The Hacker News, says exploitation needs a libvips build linked against certain third-party libraries, present by default in Debian, Ubuntu and Rails-generated Docker environments, and that other base images may not be exploitable. That is second-hand, and I would not use it to waive the finding. It describes the one reported chain, and Rails does not assume that chain is the only one.
Neither scan knows who uploads to your app.
Dwaar works on the code-and-image split by discovering what you ship from source control, registries and cloud accounts, scanning it, and putting the results in one findings list with EPSS and KEV signals. Before any tooling, take the image running your busiest Rails service, not the repository, and write down its activestorage version, its ruby-vips version, its libvips version and whether VIPS_BLOCK_UNTRUSTED is set. If the libvips number is below 8.13, you have just found the real work behind this upgrade.
References
- GHSA-xr9x-r78c-5hrm advisory, GitHub Security Advisories (rails/rails), 2026-07-29
- CVE-2026-66066 announcement, Ruby on Rails Discussions, 2026-07-29
- Attack details, and tools to perform a forensic investigation, Ruby on Rails Discussions, 2026-07-31
- CVE-2026-66066 Rails Active Storage, oss-security (Openwall), 2026-07-29
- CVE-2026-66066, NVD, 2026-07-30
- Disable libvips's unfuzzed image loaders and savers, GitHub (rails/rails), released 2026-07-29
- v8.1.3.1 release, GitHub (rails/rails), 2026-07-29
- rails-forensics-CVE-2026-66066, GitHub (rails), 2026-07-30
- The investigation guide, GitHub (rails), 2026-07-30
- crafted_mat_file.rb, GitHub (rails), 2026-07-30
- Critical Rails Flaw Could Let Unauthenticated Attackers Read Server Files via Image Uploads, The Hacker News, 2026-07-29, updated 2026-07-30 and 2026-07-31
