Root Detection

Detecting that an app runs on a rooted device is a key RASP feature. An Android device that has been rooted gives users and apps higher privileges and enables them to perform otherwise restricted actions. Such device does not provide a secure environment for a production app because device users or other apps can affect the application runtime in an unexpected way, potentially compromising its integrity.

Malwarelytics for Android is able to detect that the app is running on a rooted device and can be configured to terminate the app in such case.


This feature can be configured during the Malwarelytics initialization phase:

val raspConfig = RaspConfig.Builder()
    .exitOnRootMinConfidence(Float) // value between 0.0 and 1.0
    // configuration of other RASP features
Method Description
checkRoot(Boolean) indicates whether rooted device should be detected automatically. Defaults to true.
exitOnRoot(Boolean) indicates whether the app should be terminated when a rooted device is automatically detected. Defaults to false.
exitOnRootMinConfidence(Float) gives the minimum confidence value of a heuristic root detection that triggers app termination. Works only if exitOnRoot is true. Possible values are between 0.0 (inclusive) and 1.0 (inclusive). The default value is 1.0.


After initialization, the rooted device detection feature can be accessed via RaspManager. This can be used to register an observer or to trigger a manual root detection check.

Registering an Observer

Rooted device detection can trigger a certain action. To achieve that, an observer needs to be configured and registered.

Observer configuration:

val raspObserver = object : RaspObserver {
    override fun onRootDetected(rootDetection: RootDetection) {
        // handle root detection
    // handle detection of other RASP features

The observer can be registered in RaspManager. When it is no longer needed, it can be unregistered again.


Triggering a Manual Check

Rooted device detection check can be triggered manually in RaspManager. Two methods are available – isDeviceRooted() gives a simple boolean answer, whereas getRootDetection() provides more details.

val rootDetection = raspManager.getRootDetection()
val isRooted = raspManager.isDeviceRooted()

More information on general RASP feature configuration and usage can be found in this overview.

Last updated on May 02, 2022 (20:53) View product


Malwarelytics for Android