編輯:關於 Android 開發
XSS 是我們比較熟悉的一種攻擊方式,包括存儲型 XSS、反射型 XSS、DOM XSS 等。而 UXSS(通用型 XSS)是另一種不同的漏洞類型,主要體現在漏洞的載體與影響範圍上。
XSS 問題源於某一個 WEB 站點或應用存在安全問題,但受同源策略約束,攻擊者只能存取存在漏洞站點的回話資訊,無法存取其他域的回話資訊。
UXSS 則主要源於瀏覽器或瀏覽器擴充套件的安全缺陷,不需要網站本身存在漏洞也能觸發,攻擊者可以取得瀏覽器開啟和快取的所有頁面(不同域)的回話資訊,因此殺傷力極強。
由於 Google 把 WebKit 移植到了 Android 上,並作為 WebView 元件封裝在 SDK 中,但一些先前出現在 PC 版 Chrome 的 WebKit 漏洞在 SDK 中並未修復,因此歷史的悲劇在 Android 上再次上演:
相關漏洞可上 https://bugs.chromium.org/p/chromium/issues/list 搜尋,下文介紹幾個對應的漏洞。
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 = "https://google.com/";
document.body.appendChild(object);
object.onload = function() {
object.data = "javascript:alert(document.body.innerHTML)";
object.innerHTML = "foo";
}
}</script>
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;">
這類漏洞可以透過動態方式進行自動化檢測,相關檢測樣例可從 https://bugs.chromium.org/p/chromium/issues/detail?id=xxx(bugid)查詢到。
前面提到的這些 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) 定期使用漏洞工具檢測(如御安全的漏洞庫將依市場出現的樣本同步更新)。
https://drops.wooyun.org/tools/3186
https://bugs.chromium.org/p/chromium/issues/list
https://security.tencent.com/index.php/blog/msg/70
騰訊御安全
Android 多選按鈕 CheckBox 詳解與實戰
Android 多選按鈕 CheckBox 詳解與實戰 今天要介紹的是 CheckBox 多選框——它允許用戶在一組選項中同時勾選多個,是表單類界面的常見控件。 下面是
高仿人人網客戶端 Android 版開源源碼分享
高仿人人網客戶端 Android 版開源源碼分享 本文分享一份高仿人人網客戶端的 Android 專案源碼,裡面涵蓋了不少 UI 設計與人機交互的實作手法,很適合想研究社
Android 隱藏標題欄的三種常見做法
在 Android 開發中,若希望自訂畫面不被預設標題欄影響,可以透過程式碼或主題設定隱藏標題欄。方法一:requestWindowFeature在 Activity 中
Linux 死鎖排查實戰:用 pstack 與 gdb 精準定位交叉持鎖
死鎖(deadlock)指的是兩個或多個線程在執行過程中互相爭奪資源而形成的循環等待:沒有外力介入,誰都推不進去。最典型的就是交叉持鎖——線程 1 鎖住 A 等 B,線程