Skip to content
File upload Write-up Advanced

Arbitrary file read and remote code execution in Active Storage

Active Storage did not disable libvips operations marked as unsafe for untrusted content, so a crafted uploaded file could invoke one of them when a variant was generated. This could let an unauthenticated attacker read arbitrary files from the server, including the process environment, which may allow escalation to remote code execution.

discuss.rubyonrails.org

Published on discuss.rubyonrails.org

Security Announcements

The author, on discuss.rubyonrails.org

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

Root cause

Active Storage did not disable libvips 'unfuzzed' operations, which are unsafe for untrusted content, so a crafted upload could invoke them during variant processing.

Impact

An unauthenticated attacker could read arbitrary files including the process environment, and the leaked secrets may in turn allow escalation to remote code execution or lateral movement; the advisory notes one specific attack chain was reported but does not assume it is the only one.

What the attacker needed

Libvips used for image variants; image uploads from untrusted users; attacker uploads a crafted file

The fix

It was fixed by upgrading activestorage, requiring libvips 8.13 or later, and rotating any secrets that may have been exposed.

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.

Rails apps can resize uploaded images using a library called libvips. That library has some file-reading features that are not safe for files from strangers, and the app did not switch them off. So someone could upload a specially made file and trick the server into reading other files on the machine, such as its configuration secrets.

What is File upload?

An upload feature accepts a file that the server or other users' browsers then treat as code or as something trusted.

Similar reports

View all

Same bug class and techniques, clearest first.

Unrestricted file upload

The lesson behind this report.

An upload feature accepts a file that the server or other users' browsers then treat as code or as something trusted.