4

When using adb install something.apk, does the Android Package Manager verify the signature of the APK? adb install seems to bring up nothing up on the phone's screen, so it's hard for me to know if it does.

I like the idea of using APK mirror websites to download APK files with a phone that does not have Google Play Services, but because I can't trust any of those APK mirror websites, I want to make sure that the app's data is not at risk if using adb install when upgrading to a new APK version.

A couple of questions:

  • If adb install does do signature verification, what does it do if the signature does not match? Does it fail the install, pop up a question on the phone's screen, or automatically erase the app's existing data?
  • What if using the -r option with adb install?
  • If I use adb uninstall -k before installing the app upgrade, does signature verification occur from the previous installation before the old app data will be shared with the new install?
  • Bonus: We have the option adb install -l, where -l stands for "forward-lock the app". What does this "forward-lock" mean, and does it have anything to do with signature verification and app data access?
5

You are correct adb install verifies the signature of the app.

If the app has not been installed on the device before the package manager can only verify that the app has been signed - who has signed the app can't be verified by the package manager.

Only if you install an update for an app that has already been installed before the package manager can check if the signature of the new app matches the already installed app. In case the "update.apk" to be installed has a different signature you will get an error message after executing adb install like

signatures do not match the previously installed version

I am not sure if this also happens in case you have installed the old app before using adb uninstall -k. I would assume (but have never tested it) that the signature is also checked and compared and only an apk with a matching signature can be installed. Otherwise you could get access to any app-private data on your phone by replacing the app with a custom app. This would be a serious security vulnerability.

If you additionally want to verify your downloaded apk files you can use apksigner which is included in the Android SDK. The necessary steps are described in this answer I wrote some time ago. Especially the verification of the publisher (check what other apps have been signed by the same entity) using androidobservatory.org and apkmirror.com may be of interest to you.

forward-lock in my understanding is if you want to pin an app to the current device firmware version, hence mark an app as potentially not compatible with future Android versions.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.