CWE-926: Improper Export of Android Application Components

Description:
The Android application exports a component for use by other applications, but does not properly restrict which applications can launch the component or access the data it contains.

Extended Description:
The attacks and consequences of improperly exporting a component may depend on the exported component: 
                
                   If access to an exported Activity is not restricted, any application will be able to launch the activity. This may allow a malicious application to gain access to sensitive information, modify the internal state of the application, or trick a user into interacting with the victim application while believing they are still interacting with the malicious application. 
                   If access to an exported Service is not restricted, any application may start and bind to the Service. Depending on the exposed functionality, this may allow a malicious application to perform unauthorized actions, gain access to sensitive information, or corrupt the internal state of the application. 
                   If access to a Content Provider is not restricted to only the expected applications, then malicious applications might be able to access the sensitiv

Affected languages: Not Language-Specific
Affected technologies: Mobile
Parent weaknesses: CWE-285

Consequences:
  - Availability: Unexpected State
  - Availability: Unexpected State
  - Confidentiality: Read Application Data

Detection methods:
  - Automated Static Analysis: Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without havin

Mitigations:
  - [Build and Compilation] If they do not need to be shared by other applications, explicitly mark components with android:exported="false" in the application manifest.
  - [Build and Compilation] If you only intend to use exported components between related apps under your control, use android:protectionLevel="signature" in the xml manifest to restrict access to applications signed by you.
  - [Build and Compilation] Limit Content Provider permissions (read/write) as appropriate.
  - [Build and Compilation] Limit Content Provider permissions (read/write) as appropriate.

Demonstrative examples:
This application is exporting an activity and a service in its manifest.xml:
Because these components have intent filters but have not explicitly set 'android:exported=false' elsewhere in the manifest, they are automatically exported so that any other application can launch them. This may lead to unintended behavior or exploits.
<activity android:name="com.example.vulnerableApp.mainScreen"> 
                         
                            
                            ... 
                            <intent-filter> <action android:name="com.example.vulnerableApp.OPEN_UI" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> 
                            ... 
                            
                         
                      </activity> <service andr

This application has created a content provider to enable custom search suggestions within the application:
Because this content provider is only intended to be used within the application, it does not need to be exported. However, in Android before 4.2, it is automatically exported thus potentially allowing malicious applications to access sensitive information.
<provider> android:name="com.example.vulnerableApp.searchDB" android:authorities="com.example.vulnerableApp.searchDB"> </provider>