scottyab / rootbeer

Simple to use root checking Android library and sample app
Apache License 2.0
2.48k stars 440 forks source link

Root detection not working on android 14 #221

Open pravinlondhe opened 9 months ago

pravinlondhe commented 9 months ago

Root detection not working on android 14 emulator google API's system image while on android 13 emulator google API's system image it is working.

NityaSantosh26 commented 1 month ago

@pravinlondhe, Yes I also have this issue. The root detection doesn't work from Android 14 emulator onwards (Also tested on Android 15 Emulator). I have digged deeper into the code and the failure is seems to be with https://github.com/scottyab/rootbeer/blob/master/rootbeerlib/src/main/java/com/scottyab/rootbeer/RootBeer.java, checkForDangerousProps() method. The properties ro.debuggable, ro.secure are not part of the properties list of the emulator (Android 14) Leaving that aside, I expected checkForBinary(BINARY_SU) method to return true but this fails in verifying if the su file exists. The file indeed exists in the device explorer but the Line 191 of Rootbeer.java fails due to permission is not granted. I am not sure about the real rooted device scenario, but on the Android 14 & 15 rooted emulators are not been detected! "android.system.ErrnoException: access failed: EACCES (Permission denied)" is the Exception that we get and returns false. @scottyab, Please look into it. Atleast the checkForBinary going fine. Even tried checkSuExists() which also fails detecting rooted device.

scottyab commented 1 month ago

Thanks both for flagging this. Just so I'm clear what your are reporting. The only reason Android 13 emulator was flagging as rooted was the checkForDangerousProps() check specifically ro.debuggable, ro.secure and new on android 14/15 emulator the properties are not set/accessible? Or were there other root checks that returned false on Android 13?

The file indeed exists in the device explorer

@NityaSantosh26 What path in the su binary that you're seeing is not detected? I'm unclear if this is a file you've added for test purposes or something that's part of the emulator

NityaSantosh26 commented 1 month ago

Thanks for your reply @scottyab. That's correct only with the check for ro.debuggable, ro.secure the root detection is being done on Android 13 Emulator. All the other properties/methods return false. For Android 14 and above, the two properties are not available in the list of all properties maybe they are removed (i am not sure). So even this checkForDangerousProps() also fails resulting in no root detection.

scottyab commented 1 month ago

I'm seeing ro.force.debuggable rather than ro.debuggable in system properties from Android 14 and Android 15, it could be this changed in Android 14 although not found any proof of that yet. Even if we changed it to also check for ro.force.debuggable, this is [0] so it would still pass the check and not be detected as rooted.

When I test the Default Android System image (i.e not the recommended Google one) emulator I'm setting test keys flagged and so rooted check fails.

image

I'm not sure of the best solution here, potentially it's a clarification about the expected root check result of the emulator for the default system image vs google system images?

NityaSantosh26 commented 1 month ago

Yeah. But how about checkForBinary?