# Active Storage: Possible arbitrary file read and remote code execution in video previews, analysis and image processing

Active Storage names tempfiles with the uploader's extension, so ffmpeg/ffprobe/ImageMagick pick an attacker-chosen decoder; .avs yields file read and possible RCE.

- Payout: Research
- Severity: high
- Program: Rails Active Storage
- Found by: Pirikara
- Disclosed: 2026-11-10
- CVE: CVE-2026-126186
- Write-up quality: 7/10
- Original: https://github.com/advisories/GHSA-v924-7rp8-4mxh
- Library page: https://bugbountylibrary.com/r/ghsa%3AGHSA-v924-7rp8-4mxh
- Tags: area:web domain:web impact:data-leak impact:rce kind:research platform:ghsa sev:high tech:ruby technique:source-review vuln:file-upload vuln:info-disclosure vuln:rce

**Target:** ActiveStorage::Blob#open tempfile passed to ffprobe, ffmpeg and ImageMagick
**Root cause:** Blob#open writes the blob to a tempfile carrying the uploaded filename's extension and passes it to external tools, which select a decoder from the extension when content does not self-identify.
**Steps:**
1. Upload a file with an attacker-chosen extension (e.g. `.avs`) and a declared content type, to an app that analyzes video/audio, generates video previews, or processes images with ImageMagick.
2. Active Storage attaches the blob and runs VideoAnalyzer/AudioAnalyzer (ffprobe), VideoPreviewer (ffmpeg) or ImageAnalyzer (:mini_magick) on attach.
3. `ActiveStorage::Blob#open` writes the blob to a tempfile named with the uploaded extension.
4. ffmpeg built with `--enable-avisynth` treats the `.avs` file as an AviSynth script and evaluates it; ImageMagick selects coders/delegates from the extension likewise.
5. Read disclosed files via the generated preview image, or load an attacker-uploaded native library for possible RCE in the FFmpeg process.
**Exploitation:** Attacker controls filename extension and declared content type of an upload; the tempfile extension makes ffmpeg evaluate an AviSynth script, disclosing files readable by the app process through the preview image, or loading an uploaded native library toward RCE. Requires FFmpeg built with --enable-avisynth plus AviSynthPlus runtime (ffmpeg.org GPL Windows/Linux builds); other extension-selected decoders may be reachable without it.
**Escalation:** File read via preview image escalates to secret disclosure (secret_key_base, credentials master key, service/DB credentials) and possible native-library load to RCE in the FFmpeg process.
**Insight:** When a library hands user uploads to external tools, check whether the tempfile keeps the user-supplied extension: ffmpeg/ffprobe/ImageMagick fall back to extension-based decoder selection when content is ambiguous, so a mismatched extension picks the parser (AviSynth, delegates) rather than the real format.

