Android security tags, read closely by Lightrion

CVE-2023-40088 AI-generated analysis

platform/packages/modules/Bluetooth, android/app/jni (AdapterService JNI callback thread / CallbackEnv)

AI-generated: written from the bulletin and the fixing diffs by claude-fable-5-1, then checked against the code by claude-opus-5-5 (6 corrections). Verify against the commit before relying on it.

Adds `callbackEnv = NULL;` after `vm->DetachCurrentThread()` in the DISASSOCIATE_JVM branch of callback_thread_event in the Bluetooth AdapterService JNI. After the callback thread is detached, the code no longer keeps a dangling JNIEnv pointer.

Root cause

In android/app/jni/com_android_bluetooth_btservice_AdapterService.cpp, callback_thread_event(ASSOCIATE_JVM) attaches the callback thread with vm->AttachCurrentThread(&callbackEnv, &args). This stores the thread's JNIEnv* in the file-scope variable callbackEnv. On DISASSOCIATE_JVM, the code called vm->DetachCurrentThread() and cleared sHaveCallbackThread, but it left callbackEnv pointing at the environment. Per the commit message, detaching frees that environment context. The commit message says the stale variable allows a UAF 'under certain conditions', and its title ('Fix UAF in ~CallbackEnv') names the CallbackEnv destructor as the place where the UAF happens.

How the fix works

Completeness

Behavior changes

Per major

Unknowns

Back to December 2023 · Findings