SVG SSRF Cheatsheet
Hosts that process SVG can potentially be vulnerable to SSRF, LFI, XSS, RCE because of the rich feature set of SVG.
All of these methods specify a URI, which can be absolute or relative. File and HTTP protocol are important to test, but it could also support other protocols depending on the implementation (e.g. PHP stream schemes), including javascript: and data:.
This document contains a list of the ways about to abuse this functionality in SVG files.
For uploads, send a JPEG/PNG mime type and filename.
For downloads, have a JPEG/PNG filename and mime type. If refused, check for TOCTOU on the URL (double fetch) and if it follows redirects.
Mime sniffing confusion is probably also possible. Mime sniffing confusion as SVG is difficult to sniff because it can start with extra XML garbage. In fact, the standard
filecommand doesn't include any SVG magic, so it's likely up to the individual implementations.
Images
SVG can include external images directly via the <image> tag.
<svg width="200" height="200" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<image xlink:href="https://example.com/image.jpg" height="200" width="200"/>
</svg>Most simple:
<svg xmlns="http://www.w3.org/2000/svg">
<image href="http://example.com/image.jpg" />
</svg>URL Encoded:
<svg xmlns="http://www.w3.org/2000/svg">
<image href="http://example.com/%69mage.jpg" />
</svg>The <use> tag
<use> tagSVG can include external SVG content via the <use> tag.
Option 1:
Option 2:
Option 3
CSS
CSS Stylesheet <link>
<link>SVG can include external stylesheets via the <link> tag, just like html.
CSS stylesheet via @include
@includeCSS Stylesheet via <?xml-stylesheet?>
<?xml-stylesheet?>IP in Hexadecimal
Redirect with data URI
XSLT
SVGs can include XSLT stylesheets via <?xml-stylesheet?>. Surprisingly, this does seem to work in chrome.
Also, because this template just wholesale replaces the entire "old" image with the new one.
Javascript
Inline
SVG can natively include inline javascript, just like HTML.
External
SVG can also include external scripts.
Inline in event
SVG can also have inline event handlers that get executed onload.
You can also bind handlers to animations and some other events. Read the SVG spec.
Last updated