Weak Cryptography in the Application
The application encrypts, hashes or generates random values with weak algorithms, insecure modes, fixed keys or predictable randomness, so its protection can be undone.
| Severity | Medium |
| CVSS 3.1 | 5.1 CVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N Open in the calculator |
| CVSS 4.0 | 5.9 CVSS:4.0/AV:L/AC:L/AT:P/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N Open in the calculator |
| CWE | CWE-327: Use of a Broken or Risky Cryptographic Algorithm |
| OWASP Top 10 | A04:2025 Cryptographic Failures |
| Category | Cryptographic Failures |
Description
The application uses cryptography in a way that does not provide the protection intended. Typical cases in mobile applications include obsolete algorithms such as DES, 3DES or RC4; AES in ECB mode, which reveals patterns in the data and is what common providers apply when Cipher.getInstance("AES") is called without a mode; fixed or all-zero initialisation vectors and reused GCM nonces; keys written into the code or derived from constants or device identifiers; MD5 or SHA-1 used for integrity checks or to protect passwords; RSA without OAEP padding; and non-cryptographic random number generators, such as java.util.Random, used for keys, tokens or nonces. Custom schemes, such as XOR with a fixed value or Base64 encoding presented as encryption, are also common.
Data protected in these ways is exposed to an attacker who obtains it from the device's storage, a backup or intercepted traffic: they can decrypt it when the key is fixed or recoverable from the package, or infer its content from repeated patterns when ECB mode is used. Weak hashes and integrity checks may let an attacker alter data or messages without detection, and predictable random values may let them guess tokens or keys. Obtaining the protected data usually requires access to the device, its backups or the network path, which limits the risk.
The weakness is identified by reviewing the decompiled code for the algorithms, modes and key sources passed to the platform's cryptographic APIs, which static analysers such as MobSF often flag, and confirmed at runtime by hooking those APIs with Frida to capture the keys, initialisation vectors and plaintext actually used. A key that is the same on every installation, or that can be recomputed from public values, shows that the protection can be reversed by anyone who has the application package, and once extracted, such a key typically affects every user of the application.
Remediation
Replace custom and weak constructions with current algorithms provided by the platform, and keep keys out of the application package:
- Use authenticated encryption, AES-GCM or ChaCha20-Poly1305, with a unique random nonce for every encryption. On Android, use the Android Keystore or a vetted library such as Tink; on iOS, use CryptoKit.
- Generate keys on the device inside the Android Keystore, or the iOS Keychain or Secure Enclave, so that they cannot be extracted, rather than embedding them in code. Where a key must be shared with the server, issue it per user over an authenticated channel.
- Use SHA-256 or stronger for integrity, HMAC for message authentication, and Argon2id or PBKDF2 with the parameters in the OWASP Password Storage Cheat Sheet where a key is derived from a password.
- Use
SecureRandomon Android andSecRandomCopyByteson iOS for every security-relevant random value. - Use OAEP padding with RSA keys of at least 2048 bits.
- Re-encrypt existing stored data with the new scheme when the application updates, and treat any key that has shipped in a package as exposed.
Confirm the fix by repeating the code review and runtime hooking, checking that keys differ between installations and cannot be read from the package, and that no weak algorithm or mode remains.
References
Add This Finding to Your Library
In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.
Free trialYour trial starts when your portal goes live, not when you sign up, so the time you spend setting up does not count. · No card required
Only need the reporting? Our reporting tool is free and open source, with the same library.