Bluebox Security最新提報(bào)Android漏洞的初步探討(及后續(xù)跟蹤分析)
Bluebox Security最新提報(bào)Android漏洞的初步探討


關(guān)于ANDROID-8219321漏洞的后續(xù)補(bǔ)充說明。沒有后續(xù)補(bǔ)充說明,這篇文章是不完美的。因?yàn)閷?shí)際漏洞并不是上文分析的這個(gè)。
具體后續(xù)跟蹤,之前只在看雪論壇上發(fā)布,沒有更新過來。為了本文的完整性。先將看雪上我發(fā)的后續(xù)跟蹤分析的帖子一起貼在這里。
★ 2013.07.08 (http://bbs.pediy.com/showthread.php?t=174928)
更新補(bǔ)充說明:
目前已確認(rèn)本文所述問題與bluebox所說的漏洞不是同一個(gè)問題。大家可以繼續(xù)研究,但是與bluebox所稱的漏洞無關(guān)。
bluebox所述漏洞編號(hào):ANDROID-8219321。
Insertion of arbitrary code without changing package signature due to incorrect parsing of APKs (update to previous bulletin)
First published: March 4th, 2013
Last Updated: May 31st, 2013
ID: ANDROID-8219321
Severity: High
Affected Android Versions: all
由于可能涉及保密問題,更多信息在我確認(rèn)允許公布后才能公布。現(xiàn)在可以說的是,確實(shí)是對(duì)apk包進(jìn)行處理,無需操作權(quán)限。可能不是Google本身的問題,上傳應(yīng)用商店后下載即可直接安裝。我沒研究過這部分代碼,因?yàn)橐詾樗遣粫?huì)出問題的。。。
最后想說,出問題的代碼就一句話。。。

★ 2013.07.10 (http://bbs.pediy.com/showthread.php?t=175175)
這兩天這個(gè)問題基本已經(jīng)公之于眾了。所以不用再保密了。相關(guān)信息及自己研究的一些結(jié)果放上來,匯總一下。
首先是3月和5月google官方發(fā)出的補(bǔ)丁說明:
3月:
Improper installation of unsigned code
ID: ANDROID-8219321
Severity: High
Affected versions: Android 2.0 and greater
An inconsistency in the handling of zip files during application installation may lead to the installation and execution of unsigned code in a privileged context.
This issue will be publicly disclosed in 90 days. A CTS test will be included in the next CTS release.
5月:
Insertion of arbitrary code without changing package signature due to incorrect parsing of APKs (update to previous bulletin)
First published: March 4th, 2013
Last Updated: May 31st, 2013
ID: ANDROID-8219321
Severity: High
Affected Android Versions: all
Arbitrary code can be inserted into an APK and pass signature verification due to incorrect parsing of APKs. A maliciously crafted classes.dex can be inserted before a legitimately signed classes.dex in an APK. Signature verification will be performed on the second, legitimate classes.dex, but the first, malicious classes.dex is installed for application use.
Update: This issue will be publicly presented at Blackhat 2013. Please see http://www.blackhat.com/us-13/briefings.html#Forristal for more details. At that time, we expect active public exploitation of this issue outside of Google Play.
官方補(bǔ)丁:patch.rar.
---------------------------------------------------------------------------------
當(dāng)然大家關(guān)注這個(gè)問題是在7月3號(hào)bluebox在官網(wǎng)發(fā)文以后。
發(fā)文地址:http://bluebox.com/corporate-blog/bl...id-master-key/
由于問題的嚴(yán)重性,一時(shí)間大家開始研究起來。漏洞基本公之于眾是在7號(hào)cyanogenmod打上補(bǔ)丁之后。
詳見:http://review.cyanogenmod.org/#/c/45251/
根據(jù)打補(bǔ)丁的代碼,大家推測(cè)到是apk中存在兩個(gè)相同的classes.dex文件。于是大家又開始研究POC的問題。我也自己做了嘗試,由于打包順序問題沒弄出來(失之毫厘,謬以千里啊~)。今天上班沒法弄,之后大家關(guān)注到了這個(gè)網(wǎng)址:
https://gist.github.com/poliva/36b0795ab79ad6f14fd8
---------------------------------------------------------------------------------
到這本來應(yīng)該已經(jīng)完了。結(jié)果下午我網(wǎng)上下載了一個(gè)網(wǎng)易新聞Android客戶端按照上面網(wǎng)址的操作方法,卻怎么也安裝不上。我曾懷疑是我方法的問題,后來寫了一個(gè)簡(jiǎn)單的demo,發(fā)現(xiàn)通過這個(gè)方法又能成功安裝。
這個(gè)方法是將原始apk數(shù)據(jù)全部壓縮進(jìn)修改后的未簽名的apk中,體積直接增大了一倍!網(wǎng)站上自己對(duì)這個(gè)方法的描述也是“Quick & dirty PoC for Android bug 8219321 discovered by BlueboxSec”。所以確實(shí)存在問題。
經(jīng)過上述方法的啟發(fā),我明白之前的方法問題出在壓縮順序上。應(yīng)該是先壓縮修改后的dex文件,再壓縮原本的dex。
于是,比較完善的方法是:
1、將原本的apk中的文件解壓出來。分成兩個(gè)文件夾,orgin_dex和orgin_nodex。其中orgin_dex僅放解壓出來的classes.dex文件,orgin_nodex放剩余的所有文件。
2、創(chuàng)建第三個(gè)文件夾dirty_dex,放修改之后編譯出的classes.dex文件。
3、利用ant打包。build.xml如下:
<?xml version="1.0" encoding="UTF-8"?> <project name="MyProject" default="dist" basedir="."> <zip destfile="evil.apk" duplicate="add"> <fileset dir="D:\\ant\\orgin_nodex\\"/> <fileset dir="D:\\ant\\dirty_dex\\"/> <fileset dir="D:\\ant\\orgin_dex\\"/> </zip> </project>
Linux下可使用這個(gè)shell腳本:weir.rar.
---------------------------------------------------------------------------------
最后上傳兩個(gè)按此方法制作的apk包。一個(gè)是網(wǎng)易新聞,一個(gè)是微信。在啟動(dòng)的時(shí)候彈出自定義的Toast信息。可以直接覆蓋官方應(yīng)用安裝。(用之前那個(gè)POC的方法我試了不能成功安裝)
網(wǎng)易新聞下載 微信下載
轉(zhuǎn)載請(qǐng)注明出處:http://www.aygfsteel.com/zh-weir/archive/2013/07/06/401270.html
posted on 2013-07-06 16:58 zh.weir 閱讀(5925) 評(píng)論(6) 編輯 收藏 所屬分類: Android框架研究 、Android軟件安全