Skip to content
Crypto Write-up Intermediate

Dev Said Its Encrypted It S Safe Security Said Think Again

An Android app stored passwords, usernames and tokens in SharedPreferences, with some fields encrypted using 3DES in ECB mode under a hardcoded key. Anyone who could obtain the APK and the preferences file could extract the key and decrypt the stored values, recovering credentials and session tokens in plaintext.

Blue_eye Follow

Published on infosecwriteups.com

During a mobile security assessment, I noticed something unsettling the app was parking passwords, usernames, and tokens in SharedPreferences. I flagged it.

Blue_eye, on infosecwriteups.com

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

The app used symmetric encryption with a hardcoded key embedded in the APK, so the key was available to anyone who could obtain the app package.

Impact

Anyone with access to the app package and the preferences file could decrypt stored passwords, tokens and session IDs, and because the key is symmetric they could also forge new encrypted values.

What the attacker needed

Access to the app package (APK); access to the app's SharedPreferences file

The fix

The app should stop relying on a hardcoded key and instead use secure key management, such as a hardware-backed keystore, together with encrypted storage.

How it was found

  1. Reverse the app code and locate where encryption is implemented.
  2. Identify the cipher as 3DES in ECB mode with PKCS7 padding.
  3. Find the hardcoded secret and the key derivation that hashes it and takes the first 24 bytes.
  4. Trace the data flow from UI to SharedPreferences through the encrypt and decrypt helper methods.
  5. Recreate the key derivation and cipher settings outside the app in a small script.
  6. Run the script on an encrypted value taken from SharedPreferences to recover the plaintext.

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.

The app saved sensitive data on the phone, and for some of it used a lock whose key was built into the app itself. Because the key travels with the app, anyone who copies the app and the saved data can open the lock and read the secrets. Encryption only helps if the key is kept somewhere an attacker cannot reach.

What is Crypto?

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.

More by Blue_eye

View all

2 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Cryptographic weaknesses

The lesson behind this report.

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.