Bypassing AppLock Pattern via Shared Preferences Analysis
The AppLock app stored the lock pattern as a Base64-encoded SHA-1 hash in SharedPreferences, and the hash was computed from a simple transformation of the pattern positions. An attacker with access to the device's app data could brute-force the pattern offline and recover the lock pattern.
medium.com
Published on medium.com
AppLock is a popular Android application used to secure apps with a pattern lock. While analyzing an installation, I found that the lock pattern is stored in SharedPreferences.
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 app stored a weakly protected representation of the lock pattern (a SHA-1 hash of a simple transformation) in SharedPreferences, allowing offline brute-force recovery.
Impact
An attacker with access to the app's private data could recover the lock pattern, potentially bypassing the app lock.
What the attacker needed
Access to app's private data (root or backup)
The fix
The app should not store security-sensitive data in SharedPreferences and should use a secure keystore with salted hashing.
How it was found
- Explore the app's shared_prefs directory and find the image_lock_pattern value.
- Decompile the APK and locate the decryption function for image_lock_pattern.
- Understand that the pattern is transformed into bytes, hashed with SHA-1, and stored in Base64.
- Write a Python script to generate all possible patterns, compute their SHA-1 hashes, and compare to the stored hash.
- Run the script to recover the correct pattern.
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.
AppLock is an app that lets you put a pattern lock on other apps. The app saved a scrambled version of your pattern in a file that other apps or someone with access to the phone's storage could read. Because the scrambling was weak, the author wrote a program to try every possible pattern until one matched, and so learned the original pattern.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.