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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using jazzer on junit4 / Android tests #865

Open
ubiratansoares opened this issue Oct 11, 2023 · 4 comments
Open

Using jazzer on junit4 / Android tests #865

ubiratansoares opened this issue Oct 11, 2023 · 4 comments

Comments

@ubiratansoares
Copy link

Hey folks! New jazzer user here 馃憢馃徎

I'm reaching out to you to discuss how we could have even better support to fuzzing on Android projects.

Particularly it seems that junit5-only support is a deal breaker for this use case, since junit5 was never officially supported by the Android tooling. 馃挃

The Android community has being using this Gradle plugin for ages in order to enable junit-platform and write tests over Android-free code within Android projects. On the other hand, libraries like Robolectric - which we use to unit-test code coupled with Android framework classes - support only junit4.

That means that we have a hard time to use jazzer to fuzz abstractions over Intents, URIs, and other non-ui stuff we grab from the Android framework.

Not sure if I missed something, but in any case : do you folks have plans to add support for junit4 on jazzer?

Thanks in advance, and congrats on the great work you folks have being doing in the JVM/fuzzing space 馃檪

@fmeum
Copy link
Contributor

fmeum commented Oct 17, 2023

Thanks for your interest in Jazzer. Fuzzing Android applications is a pretty exciting application. @TheCoryBarker has made a number of contributions to Jazzer with the aim of making this possible, but that work doesn't seem to cover the Robolectric use case.

Supporting JUnit 5 well already requires substantial effort, which is why I think it's unlikely that we will take on supporting another test framework in the foreseeable future. We are however thinking of ways to add "second-class support" for any kind of framework via e.g. a fuzz function accepting a lambda. I will leave this issue open and post an update when we get to this.

@TheCoryBarker
Copy link
Contributor

Right now there is no way to fuzz intents. The only fuzzing is through building your Java as a library and fuzzing that library. The current sanitizers also are not well equipped for finding vulnerabilities on Android, because of this you should still target code that uses heavy native code, since the native code is where you be finding your vulns.

To start fuzzing this code, write you fuzz target for a Java library that heavily uses native code. Build this code, then instrument the .class files offline. Then use d8 tool to DEX your .jar file, push to your Android device and start fuzzing. If this sounds like your case, I would first recommend trying to fuzz your native code directly first.

I'll add though that since Robolectric uses a normal JVM and normal Java bytecode, I suspect that if junit4 was ever supported you could just build Jazzer normally and run on Robolectric with full runtime instrumentation. This wouldn't work for my case since I was mostly interested in the java->native code that ships on an Android device, which Robolectric doesn't have.

@ajgay
Copy link

ajgay commented Oct 27, 2023

@TheCoryBarker can you elaborate a bit? When building for Android via bazel build //launcher/android:jazzer_android I get an empty APK. Additionally the prebuilt releases do not contain an Android-compatible driver bin. I've also built via AOSP but their current blueprint files only build for the API -- not the driver. How can I get a working driver for Android? I've also tried loading the Java driver Jazzer.java via app_process but this fails, presumably because they are not dex'd. Attempting to dex the prebuilt jazzer_standaline.jar fails.

@ghost
Copy link

ghost commented Feb 26, 2024

@ubiratansoares @ajgay Thanks for the questions and feedback. Did you all figure out a workaround?
Please ping me to discuss.
david[dot]merian [at] code-intelligence[dot]com

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

4 participants