Arbitrary File Write On Client By ADB Pull
The ADB client's pull command does not validate filenames returned by the device, allowing a malicious ADB daemon to supply directory traversal sequences. An attacker could write arbitrary files to the client's filesystem, potentially leading to code execution.
Serafina Tonin Brocious Follow
Published on daeken.svbtle.com
The Android Debug Bridge, ADB, contains a long-standing vulnerability. It can have a rather severe impact, but only under some pretty unusual circumstances.
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
The ADB client does not validate filenames received from the device during a pull operation, allowing directory traversal sequences to be used in local file paths.
Impact
An attacker could write arbitrary files with the privileges of the user running the ADB client, potentially escalating to code execution, though exploitation requires unusual circumstances such as a malicious device or ADB daemon.
What the attacker needed
Malicious ADB daemon or device; user runs adb pull
The fix
The ADB client should validate filenames received from the device to prevent directory traversal, for example by rejecting names containing path separators or '..' components.
How it was found
- Run the malicious ADB daemon script that listens on port 5037.
- Run 'adb pull /exploit' to trigger the pull from the malicious daemon.
- Run 'cat /tmp/TESTING' to verify the file was written outside the intended directory.
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.
ADB is a tool used to communicate with Android devices. When you run 'adb pull' to copy a file from the device, the device tells your computer the file's name. The bug is that your computer trusts that name completely, so a malicious device can say the file is called something like '../../../../etc/passwd' and your computer will write the file outside the intended folder, potentially overwriting important files.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.