Reputation: 1813
I have recently have been assigned new security fix for my Android App: This time Vulnerability Assessment and Penetration Testing (VAPT) team using Magisk and Magisk hide to bypass the Android root detection implementation.
Description given by VAPT team: Root detection is checked based on package name and availability of su binary.
Steps followed by VAPT team for Root detection bypass on Android device:
Root detection implementation on App:
I have also checked possible way to fix like SafetyNet’s Hardware Attestation but I found that it is also not enough. Here I found link which says they are able to bypass Safety net detection also:
Questions regarding this scenario:
In case if root detection is bypassed, As database is encrypted there should be no chance to any app data leak. If root detection is bypassed, is encypted database is secure enlugh to prevent app from data leak ?
Is there any currently known mitigations available to detect Magisk and Magisk hide on Android app?
If There is new method to bypass and hide root then there is need to integrate new Root detection library on Android App which in turn increases Android APK size each time. Is it always a good idea to integrate new library for root detection ?
Upvotes: 4
Views: 12347
Reputation: 17
You can use this piece of code to detect magisk hide, use it in combination with another root detection lib like root beer. Here we are just going through all of the apps installed and searching for magisk specific lib names such as "libstub.so".
private void searchForMagisk() {
PackageManager pm = getPackageManager();
@SuppressLint("QueryPermissionsNeeded") List<PackageInfo> installedPackages = pm.getInstalledPackages(0);
for (int i = 0; i < installedPackages.size(); i++) {
PackageInfo info = installedPackages.get(i);
ApplicationInfo appInfo = info.applicationInfo;
String nativeLibraryDir = appInfo.nativeLibraryDir;
String packageName = appInfo.packageName;
Log.i("Magisk Detection", "Checking App: " + nativeLibraryDir);
File f = new File(nativeLibraryDir + "/libstub.so");
if (f.exists()) {
ShowMessageBox("Magisk Detection", "Magisk was Detected!");
}
}
}
Upvotes: 0