CodeQL 文档

隐式导出的 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

单击以在 CodeQL 存储库中查看查询

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>

参考

  • ©GitHub, Inc.
  • 条款
  • 隐私