2022-12-12 18:38:23 +01:00
|
|
|
|
Once an Android component has been exported, it can be used by attackers to
|
|
|
|
|
launch malicious actions and might also give access to other components
|
|
|
|
|
that are not exported.
|
2021-04-28 18:08:03 +02:00
|
|
|
|
|
2022-12-12 18:38:23 +01:00
|
|
|
|
As a result, sensitive user data can be stolen, and components can be launched
|
|
|
|
|
unexpectedly.
|
2021-04-28 18:08:03 +02:00
|
|
|
|
|
2022-12-12 18:38:23 +01:00
|
|
|
|
For this reason, the following components should be protected:
|
2021-04-28 18:08:03 +02:00
|
|
|
|
|
2022-12-12 18:38:23 +01:00
|
|
|
|
* Providers
|
|
|
|
|
* Activities
|
|
|
|
|
* Activity-aliases
|
|
|
|
|
* Services
|
2021-04-28 18:08:03 +02:00
|
|
|
|
|
2022-12-12 18:38:23 +01:00
|
|
|
|
To do so, it is recommended to either set `exported` to `false`, add
|
|
|
|
|
`android:readPermission` and `android:writePermission` attributes, or add a
|
|
|
|
|
`<permission>` tag.
|
2021-04-28 18:08:03 +02:00
|
|
|
|
|
2022-12-12 18:38:23 +01:00
|
|
|
|
**Warning**: When targeting Android versions lower than 12, the presence of intent filters will cause ``++exported++`` to be set to
|
|
|
|
|
``++true++`` by default.
|
|
|
|
|
|
|
|
|
|
If a component must be exported, use a `<permission>` tag and the
|
|
|
|
|
https://developer.android.com/guide/topics/manifest/permission-element#plevel[protection level]
|
|
|
|
|
that matches your use case and data confidentiality requirements. +
|
|
|
|
|
For example, https://developer.android.com/training/sync-adapters[Sync adapters]
|
|
|
|
|
should use a `signature` protection level to remain both exported **and** protected.
|
2020-06-30 12:50:28 +02:00
|
|
|
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
|
|
2022-12-12 18:38:23 +01:00
|
|
|
|
The following components are vulnerable because permissions are undefined or
|
|
|
|
|
partially defined:
|
|
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
|
[source,xml]
|
2020-06-30 12:50:28 +02:00
|
|
|
|
----
|
|
|
|
|
<provider
|
2021-10-13 13:40:11 +00:00
|
|
|
|
android:authorities="com.example.app.Provider"
|
|
|
|
|
android:name="com.example.app.Provider"
|
2021-02-11 16:56:46 +01:00
|
|
|
|
android:exported="true"
|
2022-12-12 18:38:23 +01:00
|
|
|
|
android:readPermission="com.example.app.READ_PERMISSION" /> <!-- Noncompliant: write permission is not defined -->
|
2021-10-13 13:40:11 +00:00
|
|
|
|
----
|
2022-02-04 17:28:24 +01:00
|
|
|
|
[source,xml]
|
2021-10-13 13:40:11 +00:00
|
|
|
|
----
|
2020-06-30 12:50:28 +02:00
|
|
|
|
<provider
|
2021-10-13 13:40:11 +00:00
|
|
|
|
android:authorities="com.example.app.Provider"
|
|
|
|
|
android:name="com.example.app.Provider"
|
2020-06-30 12:50:28 +02:00
|
|
|
|
android:exported="true"
|
2022-12-12 18:38:23 +01:00
|
|
|
|
android:writePermission="com.example.app.WRITE_PERMISSION" /> <!-- Noncompliant: read permission is not defined -->
|
2021-02-12 16:35:24 +01:00
|
|
|
|
----
|
|
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
|
[source,xml]
|
2021-02-12 16:35:24 +01:00
|
|
|
|
----
|
2022-12-12 18:38:23 +01:00
|
|
|
|
<activity android:name="com.example.activity.Activity"> <!-- Noncompliant: permissions are not defined -->
|
2021-02-12 16:35:24 +01:00
|
|
|
|
<intent-filter>
|
|
|
|
|
<action android:name="com.example.OPEN_UI"/>
|
|
|
|
|
<category android:name="android.intent.category.DEFAULT"/>
|
|
|
|
|
</intent-filter>
|
|
|
|
|
</activity>
|
2020-06-30 12:50:28 +02:00
|
|
|
|
----
|
|
|
|
|
|
2021-04-28 18:08:03 +02:00
|
|
|
|
|
2020-06-30 12:50:28 +02:00
|
|
|
|
== Compliant Solution
|
|
|
|
|
|
2021-10-13 13:40:11 +00:00
|
|
|
|
|
2022-12-12 18:38:23 +01:00
|
|
|
|
If the component's capabilities or data are not intended to be shared with
|
|
|
|
|
other apps, its ``++exported++`` attribute should be set to ``++false++``:
|
2020-06-30 14:49:38 +02:00
|
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
|
[source,xml]
|
2020-06-30 12:50:28 +02:00
|
|
|
|
----
|
|
|
|
|
<provider
|
2021-10-13 13:40:11 +00:00
|
|
|
|
android:authorities="com.example.app.Provider"
|
|
|
|
|
android:name="com.example.app.Provider"
|
|
|
|
|
android:exported="false" />
|
2020-06-30 12:50:28 +02:00
|
|
|
|
----
|
|
|
|
|
|
2022-12-12 18:38:23 +01:00
|
|
|
|
Otherwise, implement permissions:
|
2022-02-04 17:28:24 +01:00
|
|
|
|
[source,xml]
|
2020-06-30 12:50:28 +02:00
|
|
|
|
----
|
|
|
|
|
<provider
|
2021-10-13 13:40:11 +00:00
|
|
|
|
android:authorities="com.example.app.Provider"
|
|
|
|
|
android:name="com.example.app.Provider"
|
2020-06-30 12:50:28 +02:00
|
|
|
|
android:exported="true"
|
2022-12-12 18:38:23 +01:00
|
|
|
|
android:readPermission="com.example.app.READ_PERMISSION"
|
|
|
|
|
android:writePermission="com.example.app.WRITE_PERMISSION" />
|
2021-02-12 16:35:24 +01:00
|
|
|
|
|
2021-10-13 13:40:11 +00:00
|
|
|
|
<activity android:name="com.example.activity.Activity"
|
2022-12-12 18:38:23 +01:00
|
|
|
|
android:permission="com.example.app.PERMISSION" >
|
2021-02-12 16:35:24 +01:00
|
|
|
|
<intent-filter>
|
|
|
|
|
<action android:name="com.example.OPEN_UI"/>
|
2021-10-13 13:40:11 +00:00
|
|
|
|
<category android:name="android.intent.category.DEFAULT" />
|
2021-02-12 16:35:24 +01:00
|
|
|
|
</intent-filter>
|
|
|
|
|
</activity>
|
2020-06-30 12:50:28 +02:00
|
|
|
|
----
|
2021-04-28 18:08:03 +02:00
|
|
|
|
|
|
|
|
|
== See
|
|
|
|
|
|
2021-10-13 13:40:11 +00:00
|
|
|
|
* https://developer.android.com/guide/topics/providers/content-provider-creating#Permissions[developer.android.com] - Implementing content provider permissions
|
2021-06-10 10:04:10 +02:00
|
|
|
|
* https://mobile-security.gitbook.io/masvs/security-requirements/0x11-v6-interaction_with_the_environment[Mobile AppSec Verification Standard] - Platform Interaction Requirements
|
2021-10-13 13:40:11 +00:00
|
|
|
|
* https://owasp.org/www-project-mobile-top-10/2016-risks/m1-improper-platform-usage[OWASP Mobile Top 10 2016 Category M1] - Improper platform usage
|
2022-07-08 13:58:56 +02:00
|
|
|
|
* https://owasp.org/www-project-mobile-top-10/2016-risks/m2-insecure-data-storage[OWASP Mobile Top 10 2016 Category M2] - Insecure Data Storage
|
2022-04-07 08:53:59 -05:00
|
|
|
|
* https://cwe.mitre.org/data/definitions/926[MITRE, CWE-926] - Improper Export of Android Application Components
|
2021-04-28 18:08:03 +02:00
|
|
|
|
|
2021-09-20 15:38:42 +02:00
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
|
|
|
|
|
|
'''
|
|
|
|
|
== Implementation Specification
|
|
|
|
|
(visible only on this page)
|
|
|
|
|
|
|
|
|
|
include::message.adoc[]
|
|
|
|
|
|
|
|
|
|
endif::env-github,rspecator-view[]
|