← All articlesMobile applications

How to restrict Android Service access with a signature-level permission

If Android Service access is needed by apps from the same team, first define the technical access boundary. Team ownership does not replace signature verification: a signature-level permission checks that apps are signed with the same key and requires no user confirmation. Android recommends these permissions for sharing data between two apps you own. We will explain when a private Service is enough, how to configure access between apps, and how to verify the result using an entirely fictional integration.

Choose the access boundary first

If interaction between apps is unnecessary, explicitly set android:exported=false on the Service. In this mode, components in the same app or apps with the same UID can start or bind to the service. Having the same signature alone does not give a separate app access to a private service.

If a client app you own has a separate UID and needs to access the service, prepare a configuration with android:exported=true and a required signature-level permission. Here, the boundary separates calling apps that have been granted the required permission from all others. For the product owner, this is a concrete decision: does a separate app need access, and does the signature in use match the chosen interaction model?

Declare the permission and attach it to the Service

In an entirely fictional training integration, the Training Provider app contains DemoService, and the Training Client app accesses it. Both apps belong to the developer and use only synthetic data. In the provider, declare a permission once with the name com.example.training.provider.permission.RUN_DEMO and set its android:protectionLevel attribute to signature.

On DemoService, explicitly set android:exported=true and set android:permission to com.example.training.provider.permission.RUN_DEMO. The android:permission attribute specifies the permission the caller needs to start or bind to the service. If neither the Service nor the application specifies a permission, the service is not protected by a permission: declaring permission alone is insufficient.

Prepare the client and inspect the final manifest

In the training client's manifest, add uses-permission with exactly the same name: com.example.training.provider.permission.RUN_DEMO. Sign the provider and the authorized client with the same test key. The client requests the permission already declared; it should not define it again. Even for apps with the same certificate, the documentation recommends defining each permission only once.

Inspect the final manifest for the selected build variant. Gradle merges the source manifest files into a single manifest included in the app. Reviewing one source file therefore does not complete the check. The following checklist is an original editorial check, not an official Android procedure.

  • The provider declares the permission once, with protectionLevel explicitly set to signature.
  • The intended Service explicitly specifies exported=true and permission with the full name of the training permission.
  • The authorized client has uses-permission with the matching name and does not define that permission.

Positive control: the authorized operation works

For verification, we propose a fictional operation: DemoService changes the synthetic record demo-record from pending to done. This is a condition of the training example, not a built-in Android capability. Before each run, reset the record to its initial state and record its value so that results from separate attempts do not become mixed.

The authorized client, with a separate UID, the same test signature, and uses-permission, accesses the service through the interaction method chosen for the integration. The acceptance criterion is an observable change of demo-record specifically from pending to done. Record delivery of the request and the operation's result. Making the call alone does not confirm a data change; the positive control also ensures that the subsequent negative test does not pass because the integration is generally broken.

Negative control and access matrix

Create your own test app with a separate UID and a different test key. It requests the same permission through uses-permission, without declaring it again, and attempts the same operation through the same interaction method. If the required permission has not been granted, calls to startService(), bindService(), or stopService() do not work, and the Intent is not delivered to the service. Record how the denial actually manifests without assuming a specific exception type.

Below is an original editorial acceptance matrix for apps you own. A negative run requires all three conditions: access is denied, the Intent is not delivered, and the operation produces no result. If the integration uses several of the listed paths, check each one. For stopService(), separately define the expected observable stopping result in the training scenario.

  • Exported configuration with a signature-level permission: the client with the same key performs the operation; demo-record changes to done.
  • The same configuration: the client with a different key is denied access; the Intent is not delivered, and demo-record remains pending.
  • Private configuration with exported=false: an internal component performs the operation as a positive control.
  • Private configuration: a separate client with a different UID, even with the same signature, cannot start or bind to the service. A shared UID is outside the scope of this negative control.

What to fix first and where verification ends

First, resolve any mismatch between the configuration and the task: make the Service private if access between apps is unnecessary. For the selected exported configuration, check that the required permission is attached to the Service, its level is signature, the names match, and the client requests the permission. Then verify the final manifest and run both controls. Save the results together with details of the tested build and test signatures.

These observations apply to the tested configuration and selected interaction paths. They do not guarantee the app's overall security. To review the web part of your product, you can start with a free CheckMyApp website or web-product audit; perform the Android Service checks described here separately using your own training apps and synthetic data.

Sources and documentation

  1. Android security best practices
  2. Android service manifest reference
  3. Define a custom app permission
  4. Manage manifest files
CheckMyApp

Check your application’s security.

Enter your web application address and email. Get a free preliminary report and choose the depth of analysis.

Check for free