frida / frida-java-bridge

Java runtime interop from Frida
318 stars 118 forks source link

fix(android): set DexFile to read-only in Java.registerClass() #318

Closed pandasauce closed 2 months ago

pandasauce commented 2 months ago

As of Android 14, apps with targetSdk >= 34 are not allowed to have writable permissions on dynamically loaded Dex files.

https://developer.android.com/about/versions/14/behavior-changes-14#safer-dynamic-code-loading

Attempting to call Java.registerClass() with such apps results in an exception being thrown:

java.lang.SecurityException: Writable dex file '/data/data/my.ebin.app/frida4706282976511766825.dex' is not allowed.

This removes writable permissions from the temporary DexFile created by Java.registerClass() after writing to it and before it gets loaded.

oleavr commented 2 months ago

Nice!! Thanks! 🙌