利用Google Toolbar命令实现XSS攻击的技术分析

本文详细分析了Google Toolbar中存在的两个XSS漏洞,包括利用navigateto命令和参数解析缺陷实现攻击的技术细节,并分享了漏洞报告和奖励情况。

利用Google Toolbar命令实现XSS攻击

在这篇文章中,我想分享两个在toolbar.google.com中发现的XSS漏洞。这些漏洞于2015年6月发现,目前已被修复。

这些漏洞有些特殊,只能在安装了Google Toolbar的IE浏览器中利用。IE的Google Toolbar有一些特殊命令,我们可以通过toolbar.google.com的Web界面执行这些命令。

检查Toolbar命令

首先,为了找到这些命令,我探索了toolbar.google.com的内容和toolbar的二进制文件。然后,我注意到了navigateto命令。顾名思义,navigateto命令用于导航。当我在toolbar.google.com的IE开发者控制台中输入以下脚本时,它确实起作用了,将我带到了example.com。

(注意:这个命令似乎在最新版的Google Toolbar中已被移除)

1
location="http://toolbar.google.com/command?key="+document.googleToken+"&navigateto=http://example.com/"

我还测试了javascript: URL。

1
location="http://toolbar.google.com/command?key="+document.googleToken+"&navigateto=javascript:alert(1)"

然后我得到了一个警告对话框!但现在高兴还为时过早,因为我们无法从外部页面获取document.googleToken。换句话说,如果攻击者能够获取document.googleToken,这就直接变成了一个XSS漏洞。

XSS第一部分

我浏览了toolbar.google.com域的资源,发现了以下页面:

http://toolbar.google.com/dc/dcuninstall.html(WebArchive)

该页面有一个可以执行命令的按钮。如果点击按钮,它会通过OnYes()函数调用command("&uninstall-dc=anyway&DcClientMenu=false&EnableDC=false&navigateto=" + path + “dcuninstalled.html”)函数。

让我们先不管命令的细节,看看path变量。path变量由以下行设置:

1
var path = document.location.href.substring(0,document.location.href.lastIndexOf("/") + 1);

它切割location.href用作命令字符串。我相信编码者期望的是以下加粗的字符串:

https://toolbar.google.com/dc/dcuninstall.html

但这个代码并不好。如果URL在查询或哈希中有/,它会切割出意外的URL字符串。

https://toolbar.google.com/dc/dcuninstall.html?xxx/yyy

那么,如果我们输入以下字符串会发生什么?

https://toolbar.google.com/dc/dcuninstall.html?&navigateto=javascript:alert(1)//

这个URL被分配给path变量,并用作命令字符串的一部分,如下所示:

http://toolbar.google.com/command?key=[TOKEN]&uninstall-dc=anyway&DcClientMenu=false&EnableDC=false&navigateto=https://toolbar.google.com/dc/dcuninstall.html?&navigateto=javascript:alert(1)//dcuninstalled.html

在这个命令中有两个navigateto。在这种情况下,似乎后面的字符串被用作命令。因此,该命令将我们导航到javascript:alert(1)//dcuninstalled.html!!

通过这种方式,我实现了XSS而无需知道document.googleToken。

XSS第二部分

之后,我发现了另一个有趣的页面:

https://toolbar.google.com/buttons/edit/index.html

让我们看看这段代码。

首先,调用Load()函数:

Load()函数将document.URL字符串设置为url变量:

1
var url = window.document.URL.toString();

查询被分解,并取出参数名和值。然后,如以下加粗字符串所示,代码尝试查找custom_button_uri参数。如果找到该参数,它将参数值分配给document.custom_button_uid变量。

document.custom_button_uid变量通过command()函数传递:

1
2
3
4
if (document.custom_button_uid != "") {
    action.innerHTML = document.forms[0].edit_mode_title.value;
    command("&custom-button-load=" + document.custom_button_uid);
}

这意味着用户输入通过custom_button_uri查询参数传递到command中。

让我们再次查看赋值部分:

1
document.custom_button_uid = unescape(param_pieces[1]);

幸运的是,custom_button_uri值通过了unescape()方法!这意味着我们可以放入URL编码的&和=,如下所示:

https://toolbar.google.com/buttons/edit/index.html?custom_button_uri=%26navigateto%3Djavascript:alert(document.domain)

最终,命令字符串是:

http://toolbar.google.com/command?key=[TOKEN]&custom-button-load=&navigateto=javascript:alert(document.domain)

完成!

奖励

我通过Google VRP报告了这些漏洞,并获得了$3133.7 × 2的奖励。

找到并理解未文档化的命令并不容易,但这是一段有趣的时光。

最后,我想介绍一下去年从Google收到的节日礼物。 (你可以从以下链接找到过去的礼物:Chromebook、Nexus 10、Nexus 5、Moto 360) 它是USB Armory、Bug Bountopoly和明信片!

Google安全团队的Stephen给了我日文信息和漏洞猎人的插图。太可爱了! 今年我将继续报告漏洞。非常感谢!

comments powered by Disqus
使用 Hugo 构建
主题 StackJimmy 设计