
Zero-click Bluetooth RCE exploit for Android 8-9 (CVE-2020-0022) with heap spraying, address leaking, and JOP chain execution for remote code execution via BlueFrag vulnerability.
Many thanks to Insinuator for their amazing blog post and code!
All the steps mentioned in the insinuator post have been completed, and more. These are a lot of steps to put in a README.md file, so feel free to check out the post from Insinuator mentioned above.
The exploit is fully complete up to the point where:
This exploit differs from Insinuator's implementation in the following ways:
libandroid_runtime.so rather than libicuuc.so, because that worked better on this phone/targetexecv directly and one that calls fork then execvlibandroid_runtime.so file and extracts the offsets of functions and gadgets (to ease porting the exploit to other targets)This is a video demo showing the exploit modifying the PC to point to a custom address:

The first iteration of the chain is the one that can be seen in the jop_experiment. This chain calls execv directly without calling fork. It can be found in commit ca28fdf This is what occurs when using this chain:

The second iteration of the chain is the one that calls fork then execv. Full details of this chain can be found here. This is what occurs when using this chain:

Thankfully, Pixel 3 XL has protections that prevent the bluetooth process from calling fork and/or execv. In terms of knowledge-sharing or showing-off, my work here is done. If I write and share anything more advanced, it may be too helpful for black-hats.
I consider this exploit to be complete. Future improvements may be:
dlsym then mprotect to run custom shellcodeAll of these things turn this project from a fun knowledge-sharing project to a black-hat exploit that can be weaponized, so this is where my journey ends, for now.... If you have any questions, feel free to get in touch.
To run the exploit, just run:
make build run ARGS="00:00:00:00:00:00"
Where 00:00:00:00:00:00 is the MAC address of the target/victim device. Other than make clean, the rest of the build targets are only helpful if you're trying to modify, improve, or reimplement the exploit, so there's no need to mention them in depth.
gdbserver binary can be found in the NDK folder# On target
/data/local/tmp/gdbserver 0.0.0.0:1234 --attach $(ps -A | grep -i "com.android.bluetooth" | awk '{print $2}')
# On host
adb forward tcp:1234 tcp:1234
gdb-multiarch -q -x ./gdbinit
# On host
adb push ./gdbinit /data/local/tmp/gdbinit
# On target
su
/data/data/com.termux/files/usr/bin/gdb -q -x /data/local/tmp/gdbinit -p $(ps -A | grep -i "com.android.bluetooth" | awk '{print $2}')
# OR
/data/data/com.termux/files/usr/bin/gdb -q -p $(ps -A | grep -i "com.android.bluetooth" | awk '{print $2}')
You can restart the bluetooth service on the attacker machine in case it stops working:
sudo systemctl restart bluetooth.service
This section explains some of the phenomena that were observed during the development of this exploit:

base::MessageLoop object used through get_message_loop:
partial_packets unordered_map. This was figured out using the map_experiment

