Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NativeFunction does not promote variadic arguments smaller than sizeof(int) #401

Closed
0x410c opened this issue Mar 19, 2020 · 8 comments
Closed

Comments

@0x410c
Copy link

0x410c commented Mar 19, 2020

Environment: Android 28 (9.0) Google API x86_64 emulator image.

frida latest build

in a specific application after hooking when calling the real constructor, app crashes with :

03-19 13:29:59.813 12420 12499 F com.package: runtime.cc:566] JNI DETECTED ERROR IN APPLICATION: unexpected jboolean value: -1473958912
03-19 13:29:59.814 12420 12499 F com.package: runtime.cc:566]     in call to CallNonvirtualVoidMethod

with example code :

db1.$init.overload(...).implementation = function (){
	return this.$init(...);
}

this is not related to a constructor hook i guess, but a invalid jboolean memory.

constructor contains multiple values with boolean parameters also

@muhzii
Copy link
Contributor

muhzii commented Mar 19, 2020

Hi @0x410c ,

Try calling Java.deoptimizeEverything() before applying the hook.

@0x410c
Copy link
Author

0x410c commented Mar 20, 2020

same behavior, also crash is not on hooking but when i call the original function!

@0x410c
Copy link
Author

0x410c commented Mar 20, 2020

this is from the android source
the origination of the error :

bool CheckBoolean(jboolean z) {
    if (z != JNI_TRUE && z != JNI_FALSE) {
      AbortF("unexpected jboolean value: %d", z);
      return false;
    }
    return true;
  }

@0x410c
Copy link
Author

0x410c commented Mar 21, 2020

also working fine on arm64 android 9

@oleavr oleavr transferred this issue from frida/frida-java-bridge Mar 22, 2020
@oleavr oleavr changed the title JNI DETECTED ERROR IN APPLICATION: unexpected jboolean value NativeFunction does not promote variadic arguments smaller than sizeof(int) Mar 22, 2020
@oleavr oleavr closed this as completed in e42d952 Mar 22, 2020
@oleavr
Copy link
Member

oleavr commented Mar 22, 2020

@0x410c Thanks so much for reporting! You found a fundamental flaw in how NativeFunction handles varargs 🎉

@0x410c
Copy link
Author

0x410c commented Mar 22, 2020

how can i test this?

@oleavr
Copy link
Member

oleavr commented Mar 24, 2020

@0x410c Grab 12.8.15, just released.

@oleavr oleavr reopened this Mar 24, 2020
@0x410c
Copy link
Author

0x410c commented Mar 24, 2020

working! thanks!

@0x410c 0x410c closed this as completed Mar 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants