Go deepProStep 8 of 9

Check any Android app's permissions with adb and aapt2

Read any Android app's real permissions and signing certificate with adb, aapt2, apkanalyzer and apksigner, with Cachette (app.cachette) as the example.

To check an Android app's permissions with adb, turn on USB debugging, connect the phone and run adb shell dumpsys package followed by the app's package name. It prints what the app requested and what Android has granted on your phone. To read the permissions from the app file itself, pull the APK with adb shell pm path and adb pull, then run aapt2 dump permissions or apkanalyzer manifest permissions on your computer. apksigner verify --print-certs tells you which certificate signed it.

The worked example is Cachette, package app.cachette, an encrypted photo vault whose manifest has no android.permission.INTERNET. Everything here works the same for any app, and none of it relies on what an app says about itself.

Before you start

You need a computer, a USB cable and four command-line tools from Google's Android SDK:

ToolWhat it readsWhere it comes from
adbYour phone, liveSDK Platform Tools, also a standalone download
aapt2An APK fileAndroid SDK Build Tools 26.0.2 or later, in android_sdk/build-tools/version/
apkanalyzerAn APK fileAndroid SDK Command-Line Tools, in android_sdk/cmdline-tools/version/bin/
apksignerAn APK's signaturesAndroid SDK Build Tools 24.0.3 or later

Then let the phone talk to the computer, following Android's developer options guide:

  1. Find Build number: on a Pixel under Settings > About phone, on Samsung Galaxy phones from the S8 onwards under Settings > About phone > Software information. Tap it seven times, until the phone confirms that developer options are on.
  2. Turn on USB debugging in Developer options. Where that screen sits varies by Android version and phone maker.
  3. Connect the cable and run adb devices. The phone asks whether to allow debugging from this computer: accept, and it should appear in the list as a device.

That prompt is deliberate. The adb documentation says the RSA key check ensures that adb commands "cannot be executed unless you're able to unlock the device and acknowledge the dialog." On Android 11 and later you can use Wireless debugging and adb pair instead of a cable. When you've finished, turn USB debugging off again.

Ask the phone: what was requested, and what was granted

Find the package name

The package name is an app's unique ID. It's the value after id= in the app's Google Play web address, and pm, Android's package manager tool, can search for it:

adb shell pm list packages cachette

pm list packages prints the packages whose name contains the text you give it (adb documentation), one per line, each starting with package: (the prefix comes from the command's source). Add -3 to show only third-party apps, or -i to see the installer for each one. If you also have Cachette Pro, the search matches two packages: app.cachette and app.cachette.pro.

Read the package record

adb shell dumpsys package app.cachette

dumpsys prints diagnostic output from Android's system services, and the dumpsys documentation itself uses adb shell dumpsys package to look up an app. The package service holds the package manager's record for the app. The output is long, so narrow it to the permission lines, with grep on macOS or Linux or findstr on Windows:

adb shell dumpsys package app.cachette | grep -i permission
adb shell dumpsys package app.cachette | findstr /i permission

Three headings matter. Their labels come from Android's own package manager code:

  • requested permissions: everything the app's manifest asks for.
  • install permissions: permissions granted at install. The permissions overview says the system grants install-time permissions automatically, and normal permissions are one kind. INTERNET is a normal permission, so an app that requested it would show it here.
  • runtime permissions: the ones you allow or deny, each with granted=true or granted=false and a list of flags. Google's Android 11 permission notes show a sample and explain two flags: USER_SET means you denied the permission once, and USER_FIXED means you denied it twice, so Android no longer shows the request.

One entry may surprise you. When an app requests READ_MEDIA_IMAGES or READ_MEDIA_VIDEO, the permission reference says READ_MEDIA_VISUAL_USER_SELECTED "will be automatically added to an app's manifest," whatever version the app targets. It's the permission behind the Select photos and videos choice, not an extra request by the developer.

What to expect for app.cachette. Cachette asks for nothing at install, so on a fresh install no runtime permission should show granted=true. The camera shows as granted only after you've taken a photo inside the vault and allowed it; photos and videos only after you've turned on Delete originals after import and allowed it; notifications only after a large import has continued in the background and you allowed them. Search the whole output for android.permission.INTERNET: it shouldn't appear in any section.

Ask the file: pull the APK and read its manifest

The phone's record shows what's installed and granted now. The APK shows what the app was built to ask for, and a saved copy lets you compare versions after an update. OWASP's Mobile Application Security Testing Guide recommends taking the APK from the device itself, rooted or not, because then you know no third party has modified it.

Pull the APK

adb shell pm path app.cachette

This prints the path to each APK file the app is installed from, again prefixed with package:. Since August 2021, new apps on Google Play have had to be published as app bundles, and Play turns each bundle into a base APK plus configuration APKs for your device's language, screen density and processor type. The base APK, named base.apk by Android's package parser, carries the app's main manifest. Copy its path without the package: prefix and pull it:

adb pull <path-to-base.apk> cachette.apk

adb pull copies a file from the phone to your computer; its syntax is adb pull remote local.

List the permissions

aapt2 dump permissions cachette.apk
apkanalyzer manifest permissions cachette.apk

Both read the compiled manifest inside the APK. In the documentation's words, aapt2 dump permissions "prints the permissions extracted from the APK's manifest," and apkanalyzer manifest permissions "prints the list of permissions." Neither touches your phone, so what they show doesn't depend on anything you've allowed.

Two kinds of entry puzzle people the first time:

  • A permission named after the app itself, ending in DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION. The AndroidX Core library declares it with protection level signature, and the permissions overview explains that Android grants a signature permission only to apps signed with the same certificate as the app that defines it. Its source calls it "the permission required to unexport receivers on pre Tiramisu versions of Android": it keeps receivers that the app registers while running private on Android 12L and earlier. It has nothing to do with the network.
  • READ_MEDIA_VISUAL_USER_SELECTED, added automatically next to the photo and video permissions, as above.

If any other entry is unfamiliar, the permission reference describes each one, with its protection level.

What to expect for app.cachette. A short list. The entries behind the features on Cachette's security page, the camera, photos and videos for Delete originals, and notifications for long imports, will be there. android.permission.INTERNET won't.

Read the whole merged manifest

apkanalyzer manifest print cachette.apk
aapt2 dump xmltree --file AndroidManifest.xml cachette.apk

apkanalyzer manifest print "prints the APK manifest in XML format." aapt2 dump xmltree prints a tree of the APK's compiled XML, and --file chooses which file.

Why "merged"? A project can contain several manifests: one for the main app, one per build variant and one from each library. At build time, Gradle merges them into the single manifest that's packaged into the app, as Android's guide to manifest merging explains. Each library can bring its own <uses-permission> entries; as the permissions overview puts it, "When you include a library, you also inherit its permission requirements." The merger can even add implicit system permissions for libraries that target very old Android versions. A developer strips an unwanted entry with tools:node="remove", and those markers are removed from app modules after the merge, so you won't see them in the APK. The manifest in the APK is the one the app actually ships with.

Things worth reading in it:

  • <uses-permission>: each permission the app can be granted. Some carry android:maxSdkVersion, which the element reference defines as "the highest API level at which this permission is granted to your app."
  • <permission>: permissions the app defines, like the AndroidX one above.
  • <queries>: other apps this app may see. For apps targeting Android 11 or later, Android filters the list of installed apps by default, and an app declares <queries> to see specific others (package visibility).

For Cachette there's one more safeguard further upstream: its build fails if any library tries to add android.permission.INTERNET.

Check who signed it

apksigner verify --print-certs cachette.apk

The apksigner documentation says the tool confirms that "an APK's signature will be verified successfully on all versions of the Android platform supported by that APK," and that --print-certs shows "information about the APK's signing certificates." Among the lines it prints is each signer's certificate SHA-256 digest, written as one unbroken run of lowercase hexadecimal, as apksigner's source shows.

The certificate matters because of how updates work. When Android installs an update, "it compares the certificate(s) in the new version with those in the existing version," and it allows the update only if they match (app signing). So the digest identifies the key behind every update you'll be offered. It changes only if the developer upgrades the signing key, which Google Play supports for installs and updates on Android 13 and later.

Keep a note of the digest. Tools format the same digest differently: apksigner prints lowercase hex with no separators, while other tools put colons between pairs or use capitals, so compare the characters and ignore case and colons. After an update, pull the APK again and compare. A match tells you the new version comes from the same signer as the one you checked.

If Cachette Pro (app.cachette.pro) is installed, pull it the same way. Its digest should match too, because Cachette checks on the phone that Pro is installed and signed with the same key.

A second opinion on trackers

Exodus Privacy publishes reports on Android apps listing the trackers and permissions it finds. Its Android app, from what its listing calls "the French non-profit organization Exodus Privacy," shows those reports for the apps on your phone. To check the exact APK you pulled, exodus-standalone is a "CLI client for local APK static analysis":

./exodus_analyze.py cachette.apk

Run it from a clone of the repository after installing its requirements, or use the Docker command in its README. Static analysis means reading the file without running it, so a match shows that a library's code is in the app, not that it runs or sends anything. Read a tracker report next to the permission list: code inside an app without the INTERNET permission still can't open a connection of its own.

What these checks prove, and what they don't

CheckCommandWhat it answers
The phone's recordadb shell dumpsys package app.cachetteWhat the app requested, and what's granted right now
The APK's permissionsaapt2 dump permissions or apkanalyzer manifest permissionsWhat the app was built to ask for
The whole manifestapkanalyzer manifest printEvery permission, component and query in the final merged manifest
The signerapksigner verify --print-certsWhich certificate signed this APK
Trackers./exodus_analyze.pyWhich known tracker libraries the file contains

A missing INTERNET permission is the strongest single fact on that list. Android's permission reference defines it in one line: "Allows applications to open network sockets." Without it, an app can't open a connection of its own.

Android's own description of the permission also states its limit: "The browser and other applications provide means to send data to the internet, so this permission is not required to send data to the internet" (Android source). An app without it can still hand something to another app, such as a link you open in your browser or a file you save to a cloud app. What it can't do is open a connection quietly in the background.

Three more things to keep in mind:

  • Re-check after updates. Install-time permissions are granted automatically, so an update can add one without a prompt. Keep each version's permission list and compare.
  • Permissions describe ability, not behaviour. A granted permission says what an app may do, not what it does with it.
  • The phone has to be honest. A rooted or infected phone can defeat any app, and checks that run on a phone are only as trustworthy as the phone.

Where Cachette fits

Every check above runs without Cachette's help: your computer, Google's tools and Android's own records. That's what makes them worth doing. A missing INTERNET permission in dumpsys, in aapt2's output and in the merged manifest is one fact confirmed three ways, and none of them takes the app's word for it. For more on the network side, read what it means for an app to have no internet permission. For the quick version in Android Settings, see how to check if an Android app can access the internet, and the security page collects the other ways to check.

Check yourself

  1. You run adb shell pm path for an app from Google Play and get several paths. Which file holds the app's main manifest?

    Show the answer

    The base APK, the one named base.apk. The others are configuration APKs that carry resources for your device, such as language, screen density or processor type.

Questions

How do I check an app's permissions with adb?

Turn on USB debugging, connect the phone and run adb shell dumpsys package followed by the package name. The output lists requested permissions, install permissions and runtime permissions, and each runtime permission shows granted=true or granted=false.

How do I find an Android app's package name?

Run adb shell pm list packages with part of the name, such as adb shell pm list packages cachette, or read the value after id= in the app's Google Play web address. Cachette's package name is app.cachette.

Do I need root to pull an app's APK from my phone?

No. OWASP's Mobile Application Security Testing Guide describes pulling an installed app with adb shell pm path and adb pull on rooted or non-rooted devices. aapt2, apkanalyzer and apksigner then run on your computer.

What does apksigner verify --print-certs show?

It checks that the APK's signatures verify and prints details of each signing certificate, including its SHA-256 digest. You can compare that digest with the one an app or its developer shows you.