Android靜態安全檢測 -> Fragment注入攻擊漏洞

Fragment注入攻擊漏洞 - PreferenceActivity


一、API


1. 繼承關係


【1】java.lang.Object

【2】android.content.Context

【3】android.content.ContextWrapper

【4】android.view.ContextThemeWrapper

【5】android.app.Activity

【6】android.app.ListActivity

【7】android.preference.PreferenceActivity


2. 主要方法


【1】isValidFragment(String fragmentName) 

         返回Boolean(子類應當重寫這個方法,並對fragment進行校驗判斷)


【2】onCreate(Bundle savedInstanceState),onDestroy(),onStop()


【3】參考鏈接


https://developer.android.com/reference/android/preference/PreferenceActivity.html#isValidFragment(java.lang.String)


3. PreferenceActivity兩個重要的Intent Extra


【1】extra域包含PreferenceActivity要動態加載的Fragment

PreferenceActivity.EXTRA_SHOW_FRAGMENT (’:android:show_fragment’)


【2】extra域包含傳給該Fragment的參數

PreferenceActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS(’:android:show_fragment_arguments’)


4. Fragment與Activity的關係


【1】一個Activity提供了一個單一的屏幕和一些功能(例如,瀏覽器的書籤管理器)

          一個Fragment可以被認爲是sub-activity,這是應用程序UI的一個小部分


【2】Fragments能夠靈活的允許在不同的activities重用,當一個Fragment實例在Activity裏面駐留耦合時,不同實例可以嵌入到不同的Activity中


【3】Fragment和Activity的關係圖




【4】參考鏈接


http://wolfeye.baidu.com/blog/android-fragment-injection/


http://bbs.pediy.com/showthread.php?t=183459&highlight=fragment


二、觸發條件


1. 繼承自PreferenceActivity類


【1】對應到smali語句中的特徵

.super Landroid/preference/PreferenceActivity;


2. 判斷子類中是否重寫isValidFragment方法


【1】對應到smali語句中的特徵

r'\.method.+isValidFragment\(Ljava/lang/String;\)Z'


3. 判斷Activity是否對外暴露(exported屬性爲true)


三、漏洞原理


【1】導出的PreferenceActivity的子類中,沒有加入isValidFragment方法,進行fragment名的合法性校驗,攻擊者可能會繞過限制,訪問未授權的界面


【2】更多內容


http://drops.xmd5.com/static/drops/mobile-8165.html


四、修復建議


【1】如果應用的Activity組件不必要導出,或者組件配置了intent filter標籤,建議顯示設置組件的“android:exported”屬性爲false


【2】重寫isValidFragment方法,驗證fragment來源的正確性


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