In this article, we will look at the techniques being used by Android developers to detect if a device on which the app is running is rooted or not. There are good number of advantages for an application in detecting if it is running on a rooted device or not. Most of the techniques we use to pentest an Android application require root permission to install various tools and hence to compromise the security of the application.

Many Android applications do not run on rooted devices for security reasons. I have seen some banking applications check for root-access and stop running if the device is rooted. In this article, I will explain the most common ways being implemented by developers to detect if the app is rooted and some of the bypassing techniques to run the app on a rooted device.

Fill out the form below to download the files associated with this article. 

Common techniques to detect if the device is rooted

Let’s begin with the most common techniques being used in the most popular applications to detect if the device is rooted.

Once a device is rooted, some new files may be placed on the device. Checking for those files and packages installed on the device is one way of finding out if a device is rooted or not. Some developers may execute the commands which are accessible only to root users, and some may look for directories with elevated permissions. I have listed few of these techniques below.

  1. Superuser.apk is the most common package many apps look for in root detection. This application allows other applications to run as root on the device.

  2. Many applications look for applications with specific package names. An example is show below.

    The above screenshot shows a package named “eu.chainfire.supersu”. I have seen some apps from the Android market verifying if any application by “chainfire” is running on the device.

  3. There are some specific applications which run only on rooted devices. Checking for those applications would also be a good idea to detect if the device is rooted.

    Example: Busybox.

    Busybox is an application which provides a way to execute the most common Linux commands on your Android device.

  4. Executing “su” and “id” commands and looking at the UID to see if it is root.

  5. Checking the BUILD tag for test-keys: This check is generally to see if the device is running with a custom ROM. By default, Google gives ‘release-keys’ as its tag for stock ROMs. If it is something like “test-keys”, then it is most likely built with a custom ROM.

    Looking at the above figure, it is pretty clear that I am using a stock Android ROM from Google.

    The above mentioned techniques are just a few examples of what a developer may look for in order to identify if a device is rooted. But there could be other ways around for root detection which are not mentioned here in this article.

Bypassing root detection — Demo

Want to learn more?? The InfoSec Institute CISSP Training course trains and prepares you to pass the premier security certification, the CISSP. Professionals that hold the CISSP have demonstrated that they have deep knowledge of all 10 Common Body of Knowledge Domains, and have the necessary skills to provide leadership in the creation and operational duties of enterprise wide information security programs.

InfoSec Institute's proprietary CISSP certification courseware materials are always up to date and synchronized with the latest ISC2 exam objectives. Our industry leading course curriculum combined with our award-winning CISSP training provided by expert instructors delivers the platform you need in order to pass the CISSP exam with flying colors. You will leave the InfoSec Institute CISSP Boot Camp with the knowledge and domain expertise to successfully pass the CISSP exam the first time you take it. Some benefits of the CISSP Boot Camp are:

  • Dual Certification - CISSP and ISSEP/ISSMP/ISSAP
  • We have cultivated a strong reputation for getting at the secrets of the CISSP certification exam
  • Our materials are always updated with the latest information on the exam objectives: This is NOT a Common Body of Knowledge review-it is intense, successful preparation for CISSP certification.
  • We focus on preparing you for the CISSP certification exam through drill sessions, review of the entire Common Body of Knowledge, and practical question and answer scenarios, all following a high-energy seminar approach.

In this section, we will see how one can bypass one of the root detection mechanisms mentioned above. Before we begin, let’s understand the background.

Download the application from the download section of this article and run the app on your device and click the button “Is my device rooted?” Since I am running it on a rooted device, it says “Device Rooted”. Now, our job is to fool the application that this device is not rooted.

Now, let’s begin.

Understanding the app’s functionality

Let’s first understand how this app is checking for the root access. The code inside this application is performing a simple check for Superuser.apk file as shown in the screenshot below.

As we can see in the above figure, the app is checking if there is a file named “Superuser.apk” inside the “/system/app/” directory. If it exists, then we are displaying the message “Device Rooted”. There are various ways to bypass this detection.

  1. Let us first reconfirm manually if the device is rooted by executing “su” and “id” commands.

  2. Let’s see if the “Superuser.apk” file is located in the path being checked by our target app.

  3. To bypass this check, let’s rename the application “Superuser.apk” to “Superuser0.apk” as shown in the figure below.

    As we see in the above figure, we may get an error message saying it’s a read-only file system. We can change it to read-write as shown in the next step.

  4. Changing permissions from Read-Only to Read-Write:

    The following command will change the file system permissions to “Read-Write”.

  5. Now, if we rename the file to “Superuser0.apk”, it works fine as shown in the figure below.

  6. If we now go back to the application and click the button “Is my device rooted?”, it shows a message as shown in the figure below.

This is just an example of how one can bypass root detection if it is not properly implemented. Applications may use some complex techniques to stop attackers from bypassing root detection. The techniques will change depending on how the developer is checking for root access.

For example, if a developer uses the following code snippet to check for root, the procedure to bypass the detection is different:


In this case, we would need to make our own “su” binary and “superuser” apk.


Developers who stop users from running their apps on rooted devices could be a good idea from a security perspective, but this is really annoying to a techie user who is not able to execute the app only due to the reason that he has rooted his device. Rooting techniques can be bypassed easily most of the time, and it is highly recommended that developers should use complex techniques in order to stop attackers from bypassing their validation controls.