📋 What Is It?
Insufficient Cryptography is cryptography that is present but ineffective. The app encrypts - it simply does it in a way that an attacker can undo: a broken algorithm, an unauthenticated mode, a hardcoded key, a fixed IV, a home-made cipher, or a correct algorithm whose key sits in the same binary as the data it protects.
On mobile the killer detail is key management. The device belongs to the attacker, so any key compiled into the app, derived from a constant, or stored beside the ciphertext is recoverable. Encryption only moves the problem: the security of the data becomes exactly the security of the key.
⚠️ Common Exploits
- Hardcoded Keys: the key extracted from strings or bytecode in minutes
- Broken Primitives: MD5, SHA-1, DES, RC4 still in use
- ECB Mode: identical plaintext blocks produce identical ciphertext
- Static or Zero IV: reuse destroys the security of CBC and CTR modes
- No Authentication: unauthenticated ciphertext can be tampered with
- Bad Randomness:
Randomor a timestamp seeding key material - Home-Made Crypto: XOR, Base64, or custom "obfuscation" mistaken for encryption
- Weak Password Hashing: unsalted or single-round hashes for local secrets
🔴 Attack Flow
↓
2. Identify algorithm, mode, IV handling, and where the key comes from
↓
3. Recover the key from constants, resources, or a runtime hook
↓
4. Decrypt the stored data - or forge ciphertext where nothing is authenticated
↓
5. IMPACT: "Encrypted" data read and modified at will!
❌ Vulnerable Code
✅ Secure Code
✓ Prevention Checklist
- Use platform crypto libraries - never write your own primitive
- Prefer authenticated encryption: AES-GCM or ChaCha20-Poly1305
- Generate and store keys in the Keystore/Keychain or Secure Enclave
- Never hardcode a key, IV, or salt in code, resources, or config
- Use a fresh random IV/nonce for every message; never reuse one with a key
- Use a CSPRNG (
SecureRandom) for all key and nonce material - Use SHA-256+ for hashing and Argon2id/PBKDF2 with high iteration counts for passwords
- Retire MD5, SHA-1, DES, 3DES, RC4, and ECB mode
- Bind keys to user authentication where the data warrants it
- Plan key rotation and invalidation (logout, biometric re-enrolment, device loss)
- Remember: encryption on a device the attacker owns is only as strong as the key store
🔍 Detection & Tools
Analysis:
Libraries:
How to Test:
- Grep the decompiled app for
ECB,MD5,DES, and key-like constants - Hook
Cipher.initat runtime and print the key and IV - Encrypt the same plaintext twice - identical ciphertext means ECB or a fixed IV
- Flip a ciphertext byte; if it still decrypts, there is no authentication
- Confirm keys are Keystore-resident and non-exportable
🌍 Real-World
These are documented incident classes - recurring patterns rather than single CVEs.
- Hardcoded AES keys: extracted from the binary, turning "encrypted" local databases into plaintext for anyone with the app.
- ECB-encrypted content: structure visible through the ciphertext, and repeated blocks that reveal or allow reordering of data.
- Unauthenticated ciphertext: attackers flip bits to alter decrypted values, changing prices, roles, or flags.
- Predictable tokens: session or reset values seeded from the clock, reproduced offline by an attacker.
- Base64 as "encryption": data marked confidential that is simply encoded and trivially readable.
📌 Quick Tips
- DO NOT hardcode keys, IVs, or salts
- DO NOT use ECB, MD5, SHA-1, DES, or RC4
- DO NOT invent your own cipher
- DO use AES-GCM with Keystore-held keys
- DO use a fresh random IV per message
- DO derive local keys with Argon2id/PBKDF2
📜 Compliance
Related Standards:
- OWASP Mobile Top 10 2016 - M5
- Maps to M10:2024 Insufficient Cryptography
- OWASP MASVS CRYPTO-1 … CRYPTO-4
- CWE-327 Use of a Broken or Risky Cryptographic Algorithm
- CWE-321 Use of Hard-coded Cryptographic Key
- CWE-330 Use of Insufficiently Random Values
- NIST SP 800-175B / FIPS 140-3