android:exported
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
OWASP 类别:MASVS-PLATFORM:平台互动
概览
android:exported
属性用于设置某个组件(activity、服务、广播接收器等)是否可以由其他应用的组件启动:
- 如果设为
true
,则任何应用都可以访问相应的 activity,并通过其确切类名称启动它。
- 如果设为
false
,则只有同一应用的组件、具有相同用户 ID 的应用或具有特权的系统组件可以启动该 activity。
此属性的默认值背后的逻辑会随时间的推移而发生变化,且会因组件类型和 Android 版本而异。例如,在 API 级别 16 (Android 4.1.1) 或更低版本中,<provider>
元素的值默认设为 true
。如果未明确设置此属性,便存在某些设备之间具有不同默认值的风险。
影响
具有不同默认值的情况意味着可能会意外地公开内部应用组件。下面列出了几种后果作为示例:
拒绝服务攻击。
其他应用通过不当方式访问内部组件以修改应用的内部功能。
敏感数据泄露。
在易受攻击的应用环境中执行代码。
缓解措施
始终明确设置 android:exported
属性。这样便不必进行任何解释,因为已经明确表达了您对组件可见性的意图。
为您推荐
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2023-12-13。
[null,null,["最后更新时间 (UTC):2023-12-13。"],[],[],null,["# android:exported\n\n\u003cbr /\u003e\n\n**OWASP category:** [MASVS-PLATFORM: Platform Interaction](https://mas.owasp.org/MASVS/09-MASVS-PLATFORM)\n\nOverview\n--------\n\nThe `android:exported` [attribute](/guide/topics/manifest/activity-element#exported) sets whether a component (activity, service, broadcast receiver, etc.) can be launched by components of other applications:\n\n- If `true`, any app can access the activity and launch it by its exact class name.\n- If `false`, only components of the same application, applications with the same user ID, or privileged system components can launch the activity.\n\nThe logic behind the default value of this attribute changed over time and was different depending on the component types and Android versions. For example, on API level 16 (Android 4.1.1) or lower the value for `\u003cprovider\u003e` elements is set to `true` by default. Not setting this attribute explicitly carries the risk of having different default values between some devices.\n\nImpact\n------\n\nThe situation with different default values means you could accidentally expose internal application components. A few examples of the consequences could be the following:\n\nDenial of service attacks.\nOther apps inappropriately accessing internal components to modify your app's internal functionality.\nLeaking of sensitive data.\nCode execution in the context of the vulnerable application.\n\nMitigations\n-----------\n\nAlways explicitly set the `android:exported` attribute. This will leave no room for interpretation and clearly signal your intention with regard to a component's visibility.\n\nRecommended for you\n-------------------\n\n- Note: link text is displayed when JavaScript is off\n- [# Key management {:#key-management}](/topic/security/data)\n- [Run embedded DEX code directly from APK](/topic/security/dex)\n- [Tapjacking](/topic/security/risks/tapjacking)"]]