Rule Definition
The attacks and consequences of improperly exporting a component may depend on the exported component:
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.
Remediation
A permission is required for securing Services
Violation Code Sample
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.testapps.test1">
...
<service android:name=".MailListenerService"
android:enabled="true"
android:exported="true">
<intent-filter></intent-filter>
</service>
...
</manifest>
Fixed Code Sample
1- Define permission in the top of the manifest file as following one
<permission android:name="com.example.testapps.permission.BIND_TO_MAIL_LISTENER" android:protectionLevel="signature" />
2- Add the android:permission into service
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.testapps.test1">
...
<service android:name=".MailListenerService"
android:permission=
"com.example.testapps.permission.BIND_TO_MAIL_LISTENER"
android:enabled="true"
android:exported="true">
<intent-filter></intent-filter>
</service>
...
</manifest>
Reference
https://developer.android.com/topic/security/best-practices
https://developer.android.com/guide/topics/manifest/receiver-element.html#prmsn
https://cwe.mitre.org/data/definitions/926.html
Related Technologies
Technical Criterion
Secure Coding - Input Validation
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.