android中通用拒絕服務漏洞

該漏洞的描述見鏈接文章:http://www.cnxhacker.com/2015/01/07/5603.html
主要的原因是使用了Intent中
getSerializableExtra() 的API,如果攻擊程序使用了app未定義的序列化類,該方法拋出異常,如果未捕獲該異常,則導致應用不斷crash。如果Activity不需要對外暴漏,則將exported置爲false即可。此外,就是針對API的所有使用都加入try catch。

但在上週的發佈中,差點因爲這個改動導致線上問題。當使用pendingIntent建立的notification拉起Activity時,如果將其設置爲false,則該Activity不會響應,因爲pendingIntent爲系統application。


Android下Activity通過UI總線對外暴露的三個層次



1
. 不對外暴露:應設置android:exported="false",如:
 
<activity android:name=".HomeActivity" android:exported="false">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <data android:scheme="http" android:host="m.taobao.com" android:path="/index.htm" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>
 
2. 對外部暴露:需要從非本app的其它App(含二方、三方)中通過URL方式喚起。應設置android:exported="true",且含有配置了URL規則的<intent-filter>,如:
 
<activity android:name=".HomeActivity" android:exported="true">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <data android:scheme="http" android:host="m.example.com" android:path="/index.htm" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>
 
3. 瀏覽器可跳入:在瀏覽器中訪問到與URL規則匹配的網址時,瀏覽器將彈出選擇提示,用戶可選擇使用本App或是繼續用瀏覽器打開。由於存在一定的用戶叨擾,所以須慎用,控制在儘可能小的範圍內。
設置 android:exported="true",並在URL規則 的<intent-filter> 中添加BROWSABLE這個category,如:
 
<activity android:name=".HomeActivity" android:exported="true">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <data android:scheme="http" android:host="m.example.com" android:path="/index.htm" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
    </intent-filter>
</activity>




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章