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 a 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 a case.

Configuration

This feature can be configured during the Malwarelytics initialization phase:

val raspConfig = RaspConfig.Builder()
    .root(RootDetectionConfig)
    // configuration of other RASP features
    .build()

Available values of RootDetectionConfig:

Value Description
NoAction indicates that the root will not be automatically detected. A manual check is still possible.
Notify indicates that the root will be automatically detected and observers will be notified.
Exit(
exitUrl:String?,
exitOnRootMinConfidence:Float)
indicates that the root will be automatically detected and the app will be terminated when the root is automatically detected.

Root detection defaults to RootDetectionConfig.Notify.

List of available parameters for some config values:

Parameter Description
exitUrl:String? defines the URL to be opened when the app is terminated because of the automatic detection. Defaults to null.
exitOnRootMinConfidence:Float gives the minimum confidence value of a heuristic root detection that triggers app termination. 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 Nov 21, 2023 (12:06) View product
Search

1.0.x

Malwarelytics for Android