How My First Android Pentest Led To An Exposed Aws Secret Key And How I Verified It
An Android app built with React Native contained a hardcoded AWS secret access key in its JavaScript bundle, which was compiled to Hermes bytecode. An attacker who extracted the APK could decompile the bundle and obtain the key, potentially gaining unauthorised access to the client's cloud infrastructure.
Published on infosecwriteups.com
We often find our greatest challenges — and lessons — in the most unexpected places. For me, it was during a casual, personal engagement with a client.
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 developers hardcoded an AWS secret access key directly into the React Native JavaScript bundle instead of storing it securely on a backend.
Impact
The exposed key could have allowed unauthorised access to the client's cloud infrastructure, potentially leading to data breaches, financial loss, and reputational damage.
What the attacker needed
Access to the APK file
How it was found
- Disassemble the APK using apktool.
- Locate the index.android.bundle file in the assets folder.
- Identify that the bundle is Hermes bytecode.
- Decompile the Hermes bytecode to pseudo-JavaScript using hermes-dec.
- Search the decompiled JavaScript for secretAccessKey using grep.
- Confirm the exposed AWS secret access key.
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.
Mobile apps sometimes store secret keys inside the app itself. If someone downloads the app, they can unpack it and read those secrets. Here, a cloud access key was left in the app's code, so anyone with the app could find it and use it to access the cloud account.
What is Leaked secrets?
Keys, tokens or passwords left in public code, apps, logs or responses, that grant real access.