PeakyBinders: Android IPC exploitation
/ 3 min read / #android #mobile #ipc #binder
- Event
- Insomni'hack 2026
- Difficulty
- hard
- Points
- -
Summary
PeakyBinders exposes an unprotected Binder service. The one guard it has, a caller PID check, is defeated with a one-way transaction, and a signed bounds check lets us write past a global buffer into the adjacent server URL and file path. Chaining the two turns the app into an arbitrary file reader that POSTs the result to our own server.
Challenge
Welcome, hacker. I retrieved an app actively used by the Shelby, the famous Birmingham gang. A federal agent is able to install your exploit app on one of their devices. Show them their operations are insecure. I want all their information: names, how many drinks they take, everything.
We get PeakyBinders.apk and a submission page where we upload our own exploit APK. A bot installs it on a device that already runs PeakyBinders, starts the target, then starts ours. We have 30 seconds.
Reconnaissance
The manifest declares a service that any app can reach:
<service android:name="com.peaky.binders.PeakyService" android:exported="true"/>
The app also sets allowBackup="true" and usesCleartextTraffic="true". The AIDL interface exposes three Binder methods:
| Code | Method | PID check |
|---|---|---|
| 1 | DebugCheckFile(byte[]) | yes, rejects when getCallingPid() != 0 |
| 2 | isAchievementUnlocked(int) | no |
| 3 | enableDebugMode(boolean) | no |
When the PID check passes, DebugCheckFile parses the input with sscanf(input, "%15[^:]:%d:%c", name, &offset, &char) and then branches:
name == "FULL"reads the last 2048 bytes of the log file.name == "PARTIAL"writescharatbuffer[0x800 - offset], then reads the file.- It calls the native
RetrieveLog(name)which returns a server URL and the log content, then POSTs that content toserverUrl + "/logs/".
Disassembling libpeaky.so shows the interesting part, three globals laid out back to back in writable memory:
0x39D8 buffer[2049] global buffer, memset each call
0x41D9 "http://peakybinders.deadbeefcafebabe.insomnihack.ch" server URL
0x4219 "/data/data/com.peaky.binders/logs/logs.txt" file path
The buffer, the URL and the file path are contiguous. That is the whole game.
Vulnerability 1: the PID check
The PID check blocks any cross-process call because Binder.getCallingPid() returns the caller PID, which is non-zero. The subtlety is that for one-way (asynchronous) transactions the Binder driver does not propagate the caller PID, so getCallingPid() returns 0.
The generated AIDL proxy sends the call synchronously. Instead we craft a raw transaction with FLAG_ONEWAY:
Parcel data = Parcel.obtain();
data.writeInterfaceToken("com.peaky.binders.IPeakyService");
data.writeByteArray("FULL".getBytes());
binder.transact(1, data, null, IBinder.FLAG_ONEWAY);
Now getCallingPid() == 0 and the check passes.
Vulnerability 2: signed offset write
The PARTIAL:offset:char path writes buffer[0x800 - offset] = char. The bounds check is a signed comparison, if (offset >= 0x801), so any negative offset slips through because a negative value is less than 2049 in signed arithmetic.
With offset = -1 we write to buffer[0x801], which is byte 0 of the URL. With offset = -65 we reach byte 0 of the file path. That gives us two primitives at once: rewrite the destination server and rewrite the file that gets read.
Full exploit
The chain, every call sent one-way to keep the PID bypass:
- Break the URL scheme by writing
xat offset -1, so intermediate POSTs go nowhere. - Rewrite the file path to
/data/data/com.peaky.binders/shared_prefs/PeakyPrefs.xmlbyte by byte. - Rewrite the server URL to our own endpoint.
- Restore the scheme so the URL is valid again.
- Trigger
FULL, which reads the SharedPreferences file and POSTs it to us.
Our exploit is a minimal APK that binds to the service on launch and runs the transactions from a background thread. The listener receives the private preferences:
<map>
<string name="user_name">Tommy Shelby</string>
<int name="whiskey_clicks" value="42" />
<boolean name="achievement_1" value="true" />
<boolean name="achievement_2" value="true" />
<boolean name="achievement_3" value="false" />
</map>
The names, the drink counts and the achievements are exactly the information the challenge asked for.
Takeaways
An exported service with no permission is an open door, and a one-way transaction is enough to spoof a PID of zero. A signed bounds check on an offset that can go negative gives an out-of-bounds write, and when sensitive globals sit right after the target buffer that write becomes control over where data is read from and sent. Tools used: jadx, apktool, objdump, uber-apk-signer and ngrok.