๐ I Found a Hardcoded Google API Key in a Popular Food App (and It Was Too Easy ๐๐)
โ โWoke up, scanned an APK, found a secret. Just hacker things.โ
While playing around with my custom APK vulnerability scanner (yes, I made one โ because why not?), I stumbled upon a pretty critical bug in a popular food delivery app with millions of downloads. The kind of bug that would make a security triager say:
โBro, are you serious?โ
Letโs walk through the finding, how I automated it, and why hardcoding secrets is a huge no-no.
๐จ Vulnerability: Hardcoded Google API Key
Yup. Plaintext. In the APK. Just chilling in strings.xml
like it pays rent.
๐ Pattern:
AIza[0-9A-Za-z\\-_]{35}
Thatโs the signature of a Google API Key. If it isnโt properly restricted, it can lead to:
- Free rides for attackers on your Google Cloud bill
- Firebase access (in worst cases)
- Quota exhaustion
- And chaos in general
โ๏ธ My Scanner Did This (in Seconds)
Hereโs how my automated scanner flagged it:
grep -Eo 'AIza[0-9A-Za-z\-_]{35}' res/values/strings.xml
Output:
[Critical] Hardcoded Google API Key found
File: res/values/strings.xml
Key: AIzaSyD4XxY1xYwJpK0lm2nQdW9aB3s_KmBkT-AE
(๐ Redacted here. Iโm not that guy.)
๐งช Manual PoC
- Decompile the APK:
apktool d appname.apk -o app_decompiled
2. Navigate to:
app_decompiled/res/values/strings.xml
3. Search for the pattern:
grep -Eo 'AIza[0-9A-Za-z\-_]{35}' strings.xml
Thatโs it. No root. No MITM. Just some CLI magic. ๐
๐ง Impact: Itโs Not Just a String
- ๐ฅ API key abuse (Maps, Directions, Places, Firebase, etc.)
- ๐ธ Financial loss (you pay, attacker plays)
- ๐งต Data leakage (if tied to Firebase, oh boy)
- ๐ Brand damage (especially when the bug bounty report says: โFound in 5 minutes.โ)
๐ก๏ธ How Devs Should Fix This
- Never store secrets in client-side code โ ever.
- Use a backend proxy to sign and forward requests securely.
- If you must keep it on the device, use Android Keystore, encrypt it, and restrict access.
- Restrict the API key via:
- SHA-1 + package name (for Android)
- IP or referrer (for web/server)
๐ก Bonus: Automate Like a Pro
This is literally the kind of bug you can automate 100%:
- Create a regex dictionary of common secrets
- Recursively scan all decompiled XML and Smali files
- Flag and log anything juicy
- Add severity rating based on regex hit + file path
(I can share the full scanner code if this post gets enough love. ๐)
โ Hackerโs Note:
Itโs not about finding random bugs โ itโs about finding real-world exploitable issues that an attacker can abuse, and that a triager wonโt ignore. This one was:
- Easy to find
- Realistically dangerous
- And absolutely avoidable
๐ง Security is not a feature. Itโs a process. One grep at a time.