Skip to main content

Unauthorized access to files - APK Content Provider

Description

The Content Provider API allows third party applications installed in the device to retrieve data stored by the application. Access to this data must not be allowed to all applications by default. Instead, (and only if required) specific allow-lists must be used.

Impact

Leak application information to all applications installed in the device through the Content Provider API.

Recommendation

Deny access to all Content Providers with: android:exported=false and android:grantUriPermissions=false. If required you can allow specific Content Providers by using grant-uri-permission.

Threat

Unauthorized local attacker owner of a third party application installed in the device.

Expected Remediation Time

⌚ 30 minutes.

Score

Default score using CVSS 3.1. It may change depending on the context of the vulnerability.

Base

  • Attack vector: L
  • Attack complexity: H
  • Privileges required: N
  • User interaction: R
  • Scope: U
  • Confidentiality: L
  • Integrity: N
  • Availability: N

Temporal

  • Exploit code madurity: U
  • Remediation level: O
  • Report confidence: X

Result

  • Vector string: CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:U/C:L/I:N/A:N/E:U/RL:O/RC:X
  • Score:
    • Base: 2.5
    • Temporal: 2.2
  • Severity:
    • Base: Low
    • Temporal: Low

Code Examples

Compliant code

Ideally, there should be no access allowed to third party content providers

<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:sharedUserId="android.uid.system" android:versionCode="4" android:versionName="1.0" package="com.android.zerosms">
<uses-permission android:name="android.permission.SEND_SMS"/>
<application android:label="@7F040001" android:icon="@7F020002">
<provider
android:authorities="com.andriod.databasetest.contentprovider"
android:name=".db.ContentProviderDb"
android:exported="false"
android:grantUriPermissions="false">
</provider>
</application>
</manifest>

Non compliant code

The application allows external content providers with an export and Uri permissions set to true

<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:sharedUserId="android.uid.system" android:versionCode="4" android:versionName="1.0" package="com.android.zerosms">
<uses-permission android:name="android.permission.SEND_SMS"/>
<application android:label="@7F040001" android:icon="@7F020002">
<provider
android:authorities="com.andriod.databasetest.contentprovider"
android:name=".db.ContentProviderDb"
android:exported="true"
android:grantUriPermissions="true">
</provider>
</application>
</manifest>

Requirements