This project demonstrates mobile application vulnerabilities aligned with OWASP Mobile Top 10 - M10: Insufficient Cryptography, with special focus on:
- Scenario #4: Key Management Vulnerabilities
- Scenario #5: Crypto Implementation Flaws
The project showcases two versions:
- Vulnerable Version: Static key encryption inside JNI code with weak obfuscation, easily exploitable.
- Secure Version: Dynamic key generation at runtime based on SHA-256 checksums of APK components, with no static keys stored inside the APK.
- AES Encryption/Decryption of study materials.
- Vulnerable Version with Static Key (Weak XOR Obfuscation).
- Secure Version with Dynamic Key Generation.
- Native code handling for sensitive operations.
- Tamper detection through file checksum validation.
- Attack simulations included.
app/
├── src/main/java/com/herdsman.mobilesecure/ # Java/Kotlin Decryption Classes
├── src/main/cpp/ # Native C++ Key Derivation Logic
├── assets/data.enc # Encrypted study materials
├── build.gradle # Project configuration- AES key statically stored inside JNI native library.
- Decryption logic written in Java.
- Key obfuscated with simple XOR.
- Easily reversible using APK decompilation and dummy project techniques.
- APK opened at runtime using
libzip. - SHA-256 checksums collected for
AndroidManifest.xml,classes.dex, and.sofiles. - Combined checksum used to dynamically derive AES key.
- Key never stored statically.
- Any APK modification invalidates decryption key.
- Clone this repository.
- Open the project in Android Studio.
- Build and install the app on a real device or emulator.
- Observe secure decryption process.
Note: Ensure Android NDK and CMake are configured correctly.
- APK decompiled using JADX.
- JNI
getKey()extracted. - Static AES key recovered.
- Encrypted files decrypted offline.
- No static key.
- Tampering causes decryption failure.
- Key derivation tied to original APK integrity.
- Mobile app cryptography
- JNI integration and native security handling
- Reverse engineering analysis
- Secure application architecture
- Real-world OWASP M10 vulnerability simulation and mitigation
- Device-specific binding (e.g., using Android ID)
- Implement AES-GCM for authenticated encryption
- Enhanced control flow obfuscation in native code
- OWASP Mobile Security Testing Guide
- OWASP MASVS - Mobile Application Security Verification Standard
- NIST SP 800-57 Part 1 Revision 5 - Key Management Guidelines
Developer: HERDSMAN