隐式导出的 Android 组件¶
ID: java/android/implicitly-exported-component
Kind: problem
Security severity: 8.2
Severity: warning
Precision: high
Tags:
- security
- external/cwe/cwe-926
Query suites:
- java-code-scanning.qls
- java-security-extended.qls
- java-security-and-quality.qls
Android 清单文件定义了 Android 应用程序的配置设置。在此文件中,组件可以使用意图过滤器进行声明,该过滤器指定组件可以做什么以及组件可以响应哪些类型的意图。如果在包含意图过滤器时从组件中省略了 android:exported
属性,则该组件将被隐式导出。
隐式导出的组件可能允许不当访问该组件及其数据。
建议¶
为每个组件显式设置 android:exported
属性,或使用权限来限制对该组件的访问。
示例¶
在下面的示例中,在使用意图过滤器时省略了 android:exported
属性。
<manifest ... >
<application ...
<!-- BAD: this component is implicitly exported -->
<activity>
android:name=".Activity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>
</application>
</manifest>
更正版本将 android:exported
属性设置为 false
。
<manifest ... >
<application ...
<!-- GOOD: this component is not exported due to 'android:exported' explicitly set to 'false'-->
<activity>
android:name=".Activity">
android:exported="false"
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>
</application>
</manifest>
参考¶
Android 开发人员:应用清单概述。
Android 开发人员:`
` 元素 。Android 开发人员:`android:exported` 属性。
Android 开发人员:`android:permission` 属性。
Android 开发人员:更安全的组件导出。
常见弱点枚举:CWE-926。