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.

Configuration

This feature can be configured during the Malwarelytics initialization phase:

val raspConfig = RaspConfig.Builder()
    .checkRoot(Boolean)
    .exitOnRoot(Boolean)
    .exitOnRootUrl(String)
    .exitOnRootMinConfidence(Float) // value between 0.0 and 1.0
    // configuration of other RASP features
    .build()
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.
exitOnRootUrl(String) defines a URL to be opened when the app is terminated because of root detection. Defaults to null.
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.

Usage

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.

raspManager.registerRaspObserver(raspObserver)
raspManager.unregisterRaspObserver(raspObserver)

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 Sep 28, 2022 (14:47) View product
Search

0.22.x

Malwarelytics for Android