Upload an SVG with an inline script and check the response headers before calling it stored XSS

File uploadEscalation

If an avatar or attachment upload accepts .svg, upload this file and open the returned file URL directly in your browser:

code
<svg xmlns="http://www.w3.org/2000/svg"><script>alert(document.domain)</script></svg>

The app usually checks the extension or MIME type and assumes an image is harmless. But SVG is XML that can carry script, and a browser runs it when the file is loaded as a top-level document. Two response headers decide whether it fires: Content-Type: image/svg+xml with no Content-Disposition: attachment, and no Content-Security-Policy that blocks inline script.

Prove impact by checking where it runs. alert(document.domain) showing the application's own domain means script runs with access to its cookies and API. If the file is served from a separate sandbox or CDN domain, or only loads through an <img> tag, the script does not run and it is not worth reporting. Use your own test account and only upload to your own profile.

Follow #csp, #file-upload, #stored-xss or #svg for new tips like this one, on your notifications page and, if you choose, in a daily or weekly email.

Comments

No comments yet.