Manipulating AES Traffic using a Chain of Proxies and Hardcoded Keys
The Android app encrypted its API traffic with AES using a key and IV hardcoded in the APK, so an attacker who decompiled the app could recover them. With those values, the attacker could decrypt, modify and re-encrypt requests, defeating the protection that was meant to stop tampering.
Published on blog.dixitaditya.com
Mobile applications are becoming more resilient to reverse engineering and tampering with all kinds of client and server-side protections, binary hardening, code obfuscations, SSL pinning, etc which makes it that much more difficult for good or bad hackers to dig deeper into these applications.
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 encryption key and IV were hardcoded in the client app, so anyone who decompiled the APK could recover them and decrypt or forge traffic.
Impact
An attacker who can intercept the app's traffic could read and modify API requests and responses in plaintext, bypassing the client-side encryption protection.
What the attacker needed
Ability to decompile the APK; ability to intercept app traffic (SSL pinning bypass); Android device with proxy configured
How it was found
- Decompile the APK and search for encryption functions.
- Find the AES cipher class and the call site that passes key and IV.
- Locate the hardcoded key and IV in the BaseMethod class.
- Set up a chain of proxies: Mitmproxy-1 decrypts, Burp tampers, Mitmproxy-2 re-encrypts.
- Install the Mitmproxy CA certificate on the Android device and configure the device proxy.
- Send a request from the app and confirm Burp sees and can modify plaintext.
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.
The app scrambled its messages with a secret code (AES) so that anyone watching the network would see gibberish. But the secret needed to unscramble them was stored inside the app itself, and anyone can unpack an Android app and read it. Once the secret was known, the protection was useless.
What is Crypto?
Encryption, signatures, randomness or certificate checks that do not protect what they claim to.