Skip to content
RCE Write-up Advanced

KindaRails2Shell - Critical RCE in Rails via Active Storage

A crafted MATLAB file, accepted by libvips because its header text claims MATLAB 5.0 while its version word makes libmatio parse it as HDF5, uses HDF5 external datasets to read arbitrary files on the server. Combined with ActiveStorage trusting a client-declared content type and a replayable variation key, an attacker could read secrets such as secret_key_base and then forge a variant transform to run code.

ethiack.com

Published on ethiack.com

Ruby on Rails runs a large slice of the modern web: GitHub, Shopify, Basecamp, and a very long tail of self-hosted products and open-source projects. When we published the initial advisory for KindaRails2Shell (CVE-2026-66066), we withheld the technical details.

Ethiack, on ethiack.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Impact

An attacker could read any file the image worker can access and, where the signing secret is recoverable, escalate to remote code execution; the chain only works when ActiveStorage uses the vips processor, libvips is built with libmatio, untrusted loaders are not blocked, and a trigger such as a harvestable variation key exists.

What the attacker needed

ActiveStorage variant_processor is vips; libvips built with libmatio; untrusted loaders not blocked; a trigger such as a variation key

The fix

ActiveStorage should block libvips untrusted loaders whenever it uses the vips processor, and the text says this was fixed in ActiveStorage [redacted] / [redacted] / 7.2.3.2.

How it was found

  1. Upload a blob through the direct-upload endpoint, declaring the content type as an image and supplying the checksum of the crafted file.
  2. Send the crafted bytes to the storage URL returned by that endpoint.
  3. Obtain a variation key from any legitimate representation URL the application has emitted.
  4. Request a representation for the uploaded blob using the harvested variation key, reading one byte per request with a 1x1 image.
  5. Read the application's key and credentials files, or the process environment, to recover the signing secret.
  6. Forge a variation key with a transform that evaluates Ruby, request it, and read the output back through the same file-read primitive.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

When you upload a picture, the server makes a small thumbnail of it. The software doing that, libvips, can also open unusual file types, including MATLAB data files, and those files can point at other files on the disk and pull their contents in. Because the upload code believed the attacker's label saying 'this is a PNG', the attacker got the server to read its own secret files and then turn that into running their own code.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.