android應用安全——元件通訊安全(Intent)
這裡主要涉及到了Activity、Content Provider、Service、Broadcast Receiver等。這些如果在Androidmanifest.xml配置不當,會被其他應用呼叫,引起風險。android應用內部的Activity、Service、Broadcast Receiver等,他們通過Intent通訊,元件間需要通訊就需要在Androidmanifest.xml檔案中暴露元件,前面提到的風險就有可能是不恰當的元件暴露引起的。
一、Intent基礎知識
Intent啟動不同元件的方法如下:
元件名稱
方法名稱
Activity
startActivity()
startActivityForResult()
Service
startService()
bindService()
Broadcasts
sendBroadcast()
sendOrderedBroadcast()
sendStickyBroadcast()
Intent的兩種基本用法:一種是顯式的Intent,即在構造Intent物件時就指定接收者;
另一種是隱式的Intent,即Intent的傳送者在構造Intent物件時,並不知道也不關心接收
者是誰,有利於降低傳送者和接收者之間的耦合。
顯示呼叫例子:
Intent intent = new Intent(); intent.setClassName( "com.samples.intent.simple" , "com.samples.intent.simple.TestActivity" ); startActivity(intent); Intent intent = new Intent(A.activity,B.class); startActivity(intent);
隱式呼叫例子
Intent intent = new Intent(Intent. ACTION_DIAL ); startActivity(intent); Intent intent = new Intent("com.test.broadcast"); intent.putString("PASSWORD","123456"); sendBroadcast(intent); Intent intent = new Intent("com.test.service"); intent.putString("USERNAME","test"); startService(intent);
顯示呼叫和隱式呼叫都能過在不同應用間傳遞資料。
二、可能產生的風險:
1、惡意呼叫
2、惡意接受資料
3、仿冒應用,例如(惡意釣魚,啟動登入介面)
4、惡意傳送廣播、啟動應用服務。
5、呼叫元件,接受元件返回的資料
6、攔截有序廣播
上面也是想到了一部分,應用中應該會有更多的例子。
三、怎樣避歸風險:
1、最小化元件暴露
不參與跨應用呼叫的元件新增android:exported=”false”屬性,這個屬性說明它是私有的,只有同一個應用程式的元件或帶有相同使用者ID的應用程式才能啟動或繫結該服務。
<activity android:name=".LoginActivity" android:label="@string/app_name" android:screenOrientation="portrait" android:exported="false">
2、設定元件訪問許可權
參與跨應用呼叫的元件或者公開的廣播、服務設定許可權。設定許可權如下:
(1)元件新增android:permission屬性。
<activity android:name=".Another" android:label="@string/app_name" android:permission="com.test.custempermission"> </activity>
(2)宣告< permission>屬性
<permission android:description="test" android:label="test" android:name="com.test.custempermission" android:protectionLevel="normal"> </permission>
protectionLevel有四種級別normal、dangerous、signature、signatureOrSystem。signature、signatureOrSystem時,只有相同簽名時才能呼叫。
(3)呼叫元件者宣告<uses-permission>
<uses-permission android:name="com.test.custempermission" />
3、暴露元件的程式碼檢查
Android 提供各種 API 來在執行時檢查、執行、授予和撤銷許可權。這些 API
是 android.content.Context
類的一部分,這個類提供有關應用程式環境的全域性資訊。
if (context.checkCallingOrSelfPermission("com.test.custempermission") != PackageManager.PERMISSION_GRANTED) { // The Application requires permission to access the // Internet"); } else { // OK to access the Internet }
http://www.ibm.com/developerworks/cn/opensource/os-cn-android-sec/
本文轉自xyz_lmn51CTO部落格,原文連結:http://blog.51cto.com/xyzlmn/1230744,如需轉載請自行聯絡原作者
相關文章
- 騰訊安全:超98%的Android應用存有安全風險Android
- Android基礎及應用 Intent的呼叫AndroidIntent
- 安全通訊
- 騰訊安全:2022年Android應用網路欺詐安全報告(附下載)Android
- 你釋出的Android 應用安全嗎?Android
- Android O 讓安裝應用更安全Android
- Android安全防護之旅---幾行程式碼讓Android應用變得更加安全Android行程
- 安卓應用安全指南5.4.1通過HTTPS的通訊示例程式碼安卓HTTP
- 騰訊安全釋出《應用安全開發能力圖譜》
- Android應用安全防護的點點滴滴Android
- 應用安全
- Android Intent ServiceAndroidIntent
- Android 應用安全性改進: 全面助力打造 "零漏洞" 應用Android
- 通訊安全重重考驗,阿里雲通訊如何打造企業級“安全感”?阿里
- Android應用安全常見問題及解決方案Android
- 海雲安應用安全測試、移動應用安全、開發安全再次上榜
- 更安全的Web通訊HTTPSWebHTTP
- HTTPS的安全通訊機制HTTP
- 每日安全資訊:搜 Wi-Fi 熱點 Android 應用資料洩露Android
- Android中的intentAndroidIntent
- 鴻蒙Next安全之應用加密:保障應用程式碼安全鴻蒙加密
- 應用程式基礎知識:activity和intent——Android開發祕籍IntentAndroid
- 移動應用安全常用元件Soot、Flowdroid簡介&基本使用元件
- 應用安全淺談
- Android 應用程式元件介紹Android元件
- 區塊鏈加密社交應用讓資訊更加安全區塊鏈加密
- 應用程式安全的看法
- 無線應用安全剖析
- 系統安全及應用
- ArkWeb高階安全模式 - 提升應用安全性Web模式
- 移動應用安全:2021年的安全漏洞
- Android 音訊應用框架Android音訊框架
- 使用 Frida 逆向分析 Android 應用與 BLE 裝置的通訊Android
- Android 元件化之通訊(多模組,多程式)Android元件化
- 網路和通訊安全有哪些要求?
- Android端實現多人音視訊聊天應用(二):多人視訊通話Android
- 騰訊安全聯邦學習應用服務白皮書聯邦學習
- Web應用安全防護-WAFWeb
- 詳解Web應用安全系列(7)使用具有已知漏洞的元件Web元件