Exploiting Android Zygote Injection Cve 2024 31317
The Android System Server did not escape newline characters in the hidden_api_blacklist_exemptions setting before passing it to the Zygote process, allowing an attacker with the WRITE_SECURE_SETTINGS permission to inject arbitrary Zygote commands. This enabled privilege escalation from the shell user to the system user on devices running Android 11 or older.
Published on infosecwriteups.com
Android’s Zygote process plays a crucial role in the operating system, responsible for forking new applications and system processes. However, CVE-2024–31317 exposes a critical vulnerability that allows attackers to exploit Zygote injection — a technique that enables code execution with system-wide privileges.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the System Server failed to sanitise newline characters in the hidden_api_blacklist_exemptions setting before including it in a Zygote command, allowing command injection.
Impact
An attacker with the WRITE_SECURE_SETTINGS permission could escalate privileges from the shell user to the system user on devices running Android 11 or older, potentially leading to system-wide code execution.
What the attacker needed
WRITE_SECURE_SETTINGS permission (e.g., ADB shell); USB debugging enabled; Android 11 or older
The fix
The vulnerability was fixed by escaping newline characters in the hidden_api_blacklist_exemptions setting before passing it to Zygote, as implied by the article's reference to Android 12 and above being patched.
How it was found
- Stop the settings app to ensure the payload takes effect when restarted.
- Inject a payload into the hidden_api_blacklist_exemptions setting using the settings command, including a newline and a malicious Zygote command.
- Start the settings app to trigger the System Server to forward the updated exemptions to Zygote.
- Connect to the netcat listener on localhost port 1234 to obtain a system-level shell.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Android's Zygote process is like a factory that starts all apps. A setting called hidden_api_blacklist_exemptions is passed to Zygote as a command, but the system didn't check for newline characters in that setting. An attacker who can change that setting (like via ADB shell) could add extra commands, making Zygote run a shell with system privileges.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.