πŸ’₯
Android Penetration Testing
WEBSITEGITHUBLINKDININSTAGRAM
  • πŸ•΅οΈβ€β™‚οΈOWASP Mobile Top 10
    • OWASP Mobile Top 10 2014
    • OWASP Mobile Top 10 2016
    • OWASP Mobile Top 10 2023
      • Insecure Authentication/Authorization
      • Insecure Communication
      • Inadequate Supply Chain Security
      • Inadequate Privacy Controls
      • Insufficient Input/Output Validation
      • Security Misconfiguration
      • Insufficient Cryptography
      • Insecure Data Storage
      • Insufficient Binary Protections
  • "Let's Dive into the Theory"
  • 😍Theory of Android Penetration Testing
    • πŸ‘‘Basic - Advance
    • πŸ’₯Professional - Expert
    • 🟧Types of Mobile Applications
    • 🟣Android Architecture
    • 🟦Android Show
    • πŸš€Secrets of Android App Creation
    • ♦️Android's Data Treasure Chests
    • πŸ›‘Mysterious .apk File:
    • 🏹Android Pentesting with Cutting-Edge Tools
    • ⬛Android File System
  • "Let's Dive into the Practical"
  • πŸ˜‡Vulnerable Android Application with Practical.
    • πŸ˜‰InsecureShop
      • 😁Vulnerability #1: Insecure Logging
      • πŸ˜‚Vulnerability #2: Hardcoded Credentials
      • πŸ˜†Vulnerability #3: Insecure Data Storage
      • 🀣Vulnerability #4: Lack of SSL Certificate Validation
      • 😍Vulnerability #5: Insufficient URL Validation
      • πŸ˜„Vulnerability #6: Weak Host Validation
      • 😘Vulnerability #7: AWS Cognito Misconfiguration
      • πŸ˜ƒVulnerability #8: Insecure Broadcast Receiver
      • πŸ˜›Vulnerability #9: Use of Implicit intent to send a broadcast with sensitive data
      • 😎Vulnerability #10: Using Components with Known Vulnerabilities
      • 😜Vulnerability #11: Intent Redirection (Access to Protected Components)
      • πŸ˜‚Vulnerability #12: Insecure Webview Properties Enabled
      • πŸ˜†Vulnerability #13: Intercepting Implicit intent to load arbitrary URL
      • πŸ™ƒVulnerability #14: Insecure Content Provider
      • πŸ₯°Reading Material
  • "Let's Dive into the Interview Questions"
  • 😎Important Interview Questions for Android Application Penetration Testing.
    • πŸ₯‡Part - 1
    • πŸ₯ˆPart - 2
    • πŸ₯‰Part - 3
    • πŸ…Part - 4
    • πŸŽ–οΈPart - 5
  • 😘Notes
    • Tools to use
    • Important Reports from Hackerone
Powered by GitBook
On this page
  1. Vulnerable Android Application with Practical.
  2. InsecureShop

Vulnerability #3: Insecure Data Storage

If we go back to com.insecureshop.LoginActivity and analyze the code that follows after we successfully login (check lines 44-70), we see that the following code saves the username and password values into the app’s shared preferences.

Prefs prefs = Prefs.INSTANCE;
Context applicationContext = getApplicationContext();
Intrinsics.checkExpressionValueIsNotNull(applicationContext, "applicationContext");
prefs.getInstance(applicationContext).setUsername(username);
Prefs prefs2 = Prefs.INSTANCE;
Context applicationContext2 = getApplicationContext();
Intrinsics.checkExpressionValueIsNotNull(applicationContext2, "applicationContext");
prefs2.getInstance(applicationContext2).setPassword(password);
Util.saveProductList$default(Util.INSTANCE, this, null, 2, null);
startActivity(new Intent(this, ProductListActivity.class));
return;

proof-of-concept: since the app is debuggable, we can run-as the application in order to view the contents of its internal storage:

C:\Users\Aniket\Downloads\InsecureShop>adb shell
2026:/ $ run-as com.insecureshop
2026:/data/user/0/com.insecureshop $ ls -la
total 72
drwx------   7 u0_a478 u0_a478        4096 2022-04-06 10:38 .
drwxrwx--x 357 system  system        20480 2022-04-06 10:23 ..
drwxrwx--x   2 u0_a478 u0_a478        4096 2022-04-06 10:38 app_textures
drwx------   3 u0_a478 u0_a478        4096 2022-04-06 10:38 app_webview
drwxrws--x   4 u0_a478 u0_a478_cache  4096 2022-04-06 10:38 cache
drwxrws--x   2 u0_a478 u0_a478_cache  4096 2022-04-06 10:22 code_cache
drwxrwx--x   2 u0_a478 u0_a478        4096 2022-04-06 10:38 shared_prefs
2026:/data/user/0/com.insecureshop $ cd shared_prefs/
2026:/data/user/0/com.insecureshop/shared_prefs $ ls
Prefs.xml  WebViewChromiumPrefs.xml
2026:/data/user/0/com.insecureshop/shared_prefs $ cat Prefs.xml
<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<map>
    <string name="password">!ns3csh0p</string>
    <string name="productList">[{&quot;id&quot;:1,&quot;imageUrl&quot;:&quot;https://images.pexels.com/photos/7974/pexels-photo.jpg&quot;,&quot;name&quot;:&quot;Laptop&quot;,&quot;price&quot;:&quot;80&quot;,&quot;qty&quot;:0,&quot;rating&quot;:1,&quot;url&quot;:&quot;https://www.insecureshopapp.com&quot;},{&quot;id&quot;:2,&quot;imageUrl&quot;:&quot;https://images.pexels.com/photos/984619/pexels-photo-984619.jpeg&quot;,&quot;name&quot;:&quot;Hat&quot;,&quot;price&quot;:&quot;10&quot;,&quot;qty&quot;:0,&quot;rating&quot;:2,&quot;url&quot;:&quot;https://www.insecureshopapp.com&quot;},{&quot;id&quot;:3,&quot;imageUrl&quot;:&quot;https://images.pexels.com/photos/343720/pexels-photo-343720.jpeg&quot;,&quot;name&quot;:&quot;Sunglasses&quot;,&quot;price&quot;:&quot;10&quot;,&quot;qty&quot;:0,&quot;rating&quot;:4,&quot;url&quot;:&quot;https://www.insecureshopapp.com&quot;},{&quot;id&quot;:4,&quot;imageUrl&quot;:&quot;https://images.pexels.com/photos/277390/pexels-photo-277390.jpeg&quot;,&quot;name&quot;:&quot;Watch&quot;,&quot;price&quot;:&quot;30&quot;,&quot;qty&quot;:0,&quot;rating&quot;:4,&quot;url&quot;:&quot;https://www.insecureshopapp.com&quot;},{&quot;id&quot;:5,&quot;imageUrl&quot;:&quot;https://images.pexels.com/photos/225157/pexels-photo-225157.jpeg&quot;,&quot;name&quot;:&quot;Camera&quot;,&quot;price&quot;:&quot;40&quot;,&quot;qty&quot;:0,&quot;rating&quot;:2,&quot;url&quot;:&quot;https://www.insecureshopapp.com&quot;},{&quot;id&quot;:6,&quot;imageUrl&quot;:&quot;https://images.pexels.com/photos/264819/pexels-photo-264819.jpeg&quot;,&quot;name&quot;:&quot;Perfumes&quot;,&quot;price&quot;:&quot;10&quot;,&quot;qty&quot;:0,&quot;rating&quot;:2,&quot;url&quot;:&quot;https://www.insecureshopapp.com&quot;},{&quot;id&quot;:7,&quot;imageUrl&quot;:&quot;https://images.pexels.com/photos/532803/pexels-photo-532803.jpeg&quot;,&quot;name&quot;:&quot;Bagpack&quot;,&quot;price&quot;:&quot;20&quot;,&quot;qty&quot;:0,&quot;rating&quot;:2,&quot;url&quot;:&quot;https://www.insecureshopapp.com&quot;},{&quot;id&quot;:8,&quot;imageUrl&quot;:&quot;https://images.pexels.com/photos/789812/pexels-photo-789812.jpeg&quot;,&quot;name&quot;:&quot;Jacket&quot;,&quot;price&quot;:&quot;20&quot;,&quot;qty&quot;:0,&quot;rating&quot;:2,&quot;url&quot;:&quot;https://www.insecureshopapp.com&quot;}]</string>
    <string name="username">shopuser</string>
</map>
2026:/data/user/0/com.insecureshop/shared_prefs $

If you’re using a rooted android device, you can just directly navigate to the app’s internal storage directory without executing the run-as command. The vulnerability could be avoided by simply trying to encrypt the data before saving.

PreviousVulnerability #2: Hardcoded CredentialsNextVulnerability #4: Lack of SSL Certificate Validation

Last updated 1 year ago

πŸ˜‡
πŸ˜‰
πŸ˜†