SlideShare a Scribd company logo
CNIT 128


Hacking Mobile Devices
9. Writing Secure 

Android Apps
Updated 4-14-2021
Common Vulnerabilities
• Code injection


• Logic flaws


• Insecure storage


• Application configuration


• Insecure communication


• Logging
Topics
• Principle of Least Exposure


• Essential Security Mechanisms


• Advanced Security Mechanisms


• Slowing Down a Reverse Engineer
Principle of Least Exposure
Minimizing Attack Surface
• Find all entry points


• Code exposed to inputs from outside
sources


• Remove unnecessary entry points


• Perform security checks at necessary entry
points
App Components
• Don't export more components than required


• The safest case is shown below


• Most apps require some integration with other apps
Data Storage
• Avoid storing unnecessary data


• Such as passwords!


• Private directory is protected somewhat by the
sandboxing


• SD card is less protected
Untrusted Sources
• Inputs from SD card, Internet, Wi-Fi,
Bluetooth, etc.


• Verify authenticity with signature, encryption,
or some other validation


• Be careful loading classes or running
executables from untrusted locations


• Cryptographic protections are the best
Minimal Permissions
• Request the fewest permissions needed for
your app


• This is safer, and also avoids worrying careful
users


• Avoid risky permissions


• INSTALL_PACKAGES


• Using powerful shared users such as
android.uid.system
Bundling Files in the APK
• APK can contain extra files by accident


• May contain SSH credentials or other
secrets
Essential Security
Mechanisms
Review Entry Points
• Trace these functions
Permission Protection
• Exported components should be limited with
permissions


• Only available to apps with the same
signature


• If you really want to offer a component for
public use


• Great care is required in the implementation
Securing Activities
Task Manager Snooping
• Remove your app from the recent app list


• To avoid exposing private information on that image


• Put this code in OnCreate() to show a blank screen in
the list


getWindow().addFlags(WindowManager.LayoutParams.FLAG_SE
CURE)
;

• Set this attribute in an activity to remove it entirely
from the list


intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_

FROM_RECENTS);
Tapjacking
• Prevent touches from being sent through
elements with this attribute:


android:filterTouchesWhenObscured="true
"

• Or by using this method:


view.setFilterTouchesWhenObscured(true);
Dictionary
• Disable additions to the dictionary to keep
passwords and other secrets out


• Add this attribute to an EditText box:


android:inputType="textVisiblePassword"
Fragment Attacks
• Fragments are small UI elements that customize activities


• But fragment injection vulnerabilities were found


• Since Android 4.4, fragments are blocked by default


• Use this code to allow a whitelist of fragments:


@Override
 

protected boolean isValidFragment(String fragmentName)
{

String[] validFragments =
 

{"com.myapp.pref.frag1",
"com.myapp.pref.frag2"};
 

return Arrays.asList(validFragments).

contains(fragmentName);
 

}
Secure Trust Boundaries
• Make sure there's no way to open an
authenticated activity from unauthenticated
areas of the app


• One way: implement an app-wide
authentication variable
Masking Password Displays
• Add this attribute to an EditText box:


android:inputType="textPassword"
Browsable Activities
• Can be used directly from a web browser


• High-value targets for attackers


• Avoid using BROWSABLE


• If you use it, consider all possible intents that
could cause actions in your app
Securing Content Providers
Default Export Behavior
• Prior to API 17, content providers were
exported by default


• To prevent this, put this code in the manifest:


<provider
 

android:name=".ContentProvider"

android:authorities="com.myapp.ContentProvider"
android:exported="false" >
 

</provider>
SQL Injection
• Use prepared statements, like this:


String[] userInput = new String[] {"book",
"wiley"};
 

Cursor c = database.rawQuery("SELECT * FROM
Products WHERE type=?
 

AND brand=?", userInput);
Directory Traversal
• The getCanonicalPath() method removes ..
characters and provides the absolute path to a
file


• The code on the next page uses this to limit
paths to the /files/ subdirectory of the app's
private data directory
CNIT 128 9. Writing Secure Android Applications
Pattern Matching
• Pattern-
matching
checks may
fail for
variations of
the path


• Link Ch 9a
Securing Broadcast
Receivers
• Secret codes are
easily
enumerated
using apps on
the Play Store


• Don't trust them
Storing Files Securely
Creating Files and Folders
Securely
• Explicitly set permissions
Encryption
• Use AES for symmetric encryption, avoid ECB


• Use RSA-2048 for asymmetric encryption


• Password hashing advice in textbook is wrong


• You need salting and stretching; better to
avoid doing it yourself
Random Numbers
• Random() produces the same series of
numbers each time it's run from the same seed


• SecureRandom is better


• Java provides methods to seed it from a
source of entropy
Random()
import java.util.Random;


class Main {


public static void main(String[] args) {


// create instance of Random class


Random rand = new Random(1);




// Generate random integers in range 0 to 999


int rand_int1 = rand.nextInt(1000);


int rand_int2 = rand.nextInt(1000);




// Print random integers


System.out.println("Random Integers: "+rand_int1);


System.out.println("Random Integers: "+rand_int2);


}


}
• replit.com


• Every run produces the same numbers
Online Java Tester
Key Generation
• PBKDF2 uses many rounds of hashing to
derive a key from a password


• Key should be stored in Android Keystore
Exposing Files
• To allow specified other apps to see a file


• Those apps need com.myapp.docs.READWITE
permission


• They can only access the /document/ folder
Secure Communications
HTTPS
• HTTP is very unsafe


• HTTPS is much better, but depends on trusted
Certificate Authorities (CAs)


• Certificate pinning makes HTTPS even more
secure


• Requiring a specific certificate or CA
Local Communications
• Transferring data from one app to another


• Android API is the best method


• Activities with intent-filters


• In more recent Android versions


• ChooserTargets, Shortcuts, direct share
targets


• Using network sockets or the clipboard is less
safe
Securing WebViews
WebView
• Lets you display a Web page in an activity


• Often leads to security problems


• If loaded over HTTP, subject to interception
and modification


• More recommendations at


• https://www.checkmarx.com/blog/android-
webview-secure-coding-practices/
Con
fi
guring the


Android Manifest
Backups and Debugging
• If android:allowBackup is false, an attacker
can't back up files with physical access to the
device


• android:debuggable allows debugging
API Version Targeting
• minSdkVersion should be as large as
possible


• Lower values remove new security fixes


• Values below 17 export content providers by
default
Android 9
• Targeting SDK 28+ gives you


• DNS over TLS


• Network TLS by default


• Cleartext traffic must be explicitly set


• Separate WebView directories for each
process


• Can't steal cookies
• https://blog.cloudflare.com/enable-private-dns-with-1-1-1-1-on-android-9-pie/
Logging
• Should be disabled in release builds


• Use a centralized logging class


• So it can be easily disabled


• ProGuard can remove logging code
Native Code
• Notoriously difficult to secure


• Limit its exposure to the outside world


• Enable exploit mitigations


• Use latest NDK version
Exploit Mitigations
• RELRO: Relocation Read-Only


• Prevents GOT rewrites


• RPATH / RUNPATH


• Allows attacker to load modified libraries
from a user-controlled path


• Link Ch 9f
Advanced Security
Mechanisms
Protection Level
Downgrade
• A malicious app can define a permission first
with an insecure protection level


• So your app inherits that level


• Your app can check to make sure the
protection levels are intact at each entry point
Protecting Non-Exported
Components
• Attacker with root permissions can interact
with them


• You can add a request token to prevent that


• Randomly generated


• Stored in a static variable in memory


• Intents must have this token to run
Slowing Down a Reverse
Engineer
Obfuscation
• ProGuard -- free
but very ineffective


• DexGuard -- paid
version of
ProGuard


• Dash-O is good but
expensive ($3000)


• Arxan is another
Root Detection
• Search for su


• See if default.prop allows ADB shell to run as
root


• See if adbd is running as root


• Look for packages with names like


• SuperSU or Superuser
Emulator Detection
• Check for emulator build properties
Debugger Detection
• Attacker may have modified your app or the
environment to allow debugging
Tamper Detection
• Check signature
CNIT 128 9. Writing Secure Android Applications

More Related Content

PDF
CNIT 129S: Ch 12: Attacking Users: Cross-Site Scripting
PDF
CNIT 128: 3. Attacking iOS Applications (Part 2)
PDF
CNIT 128 8. Android Implementation Issues (Part 3)
PDF
CNIT 128 7. Attacking Android Applications (Part 3)
PDF
CNIT 128: Android Implementation Issues (Part 2)
PDF
CNIT 128 9. Writing Secure Android Applications
PDF
CNIT 128 7. Attacking Android Applications (Part 2)
PDF
CNIT 129S Ch 7: Attacking Session Management
CNIT 129S: Ch 12: Attacking Users: Cross-Site Scripting
CNIT 128: 3. Attacking iOS Applications (Part 2)
CNIT 128 8. Android Implementation Issues (Part 3)
CNIT 128 7. Attacking Android Applications (Part 3)
CNIT 128: Android Implementation Issues (Part 2)
CNIT 128 9. Writing Secure Android Applications
CNIT 128 7. Attacking Android Applications (Part 2)
CNIT 129S Ch 7: Attacking Session Management

What's hot (20)

PDF
CNIT 128 7. Attacking Android Applications (Part 1)
PDF
CNIT 128 6. Analyzing Android Applications (Part 2 of 3)
PDF
CNIT 128 8. Android Implementation Issues (Part 2)
PDF
CNIT 128 6. Analyzing Android Applications (Part 3 of 3)
PDF
CNIT 129S: 10: Attacking Back-End Components
PDF
CNIT 128 8. Identifying and Exploiting Android Implementation Issues (Part 2)
PDF
Shellcoding in linux
PDF
CNIT 128 7. Attacking Android Applications (Part 3)
PDF
CNIT 129S: 9: Attacking Data Stores (Part 1 of 2)
PDF
CNIT 128: 7. Attacking Android Applications (Part 1 of 3)
PDF
CNIT 129: 6. Attacking Authentication
PPTX
Secure Coding 101 - OWASP University of Ottawa Workshop
PDF
CNIT 128 3. Attacking iOS Applications (Part 1)
PDF
CNIT 128 2. Analyzing iOS Applications (Part 1)
PDF
Ch 1: Web Application (In)security & Ch 2: Core Defense Mechanisms
PDF
CNIT 128 3. Attacking iOS Applications (Part 2)
PDF
The Dark Side of PowerShell by George Dobrea
PDF
CNIT 128 7. Attacking Android Applications (Part 2)
PDF
CNIT 128 8. Identifying and Exploiting Android Implementation Issues (Part 1)
PDF
CNIT 129S - Ch 6a: Attacking Authentication
CNIT 128 7. Attacking Android Applications (Part 1)
CNIT 128 6. Analyzing Android Applications (Part 2 of 3)
CNIT 128 8. Android Implementation Issues (Part 2)
CNIT 128 6. Analyzing Android Applications (Part 3 of 3)
CNIT 129S: 10: Attacking Back-End Components
CNIT 128 8. Identifying and Exploiting Android Implementation Issues (Part 2)
Shellcoding in linux
CNIT 128 7. Attacking Android Applications (Part 3)
CNIT 129S: 9: Attacking Data Stores (Part 1 of 2)
CNIT 128: 7. Attacking Android Applications (Part 1 of 3)
CNIT 129: 6. Attacking Authentication
Secure Coding 101 - OWASP University of Ottawa Workshop
CNIT 128 3. Attacking iOS Applications (Part 1)
CNIT 128 2. Analyzing iOS Applications (Part 1)
Ch 1: Web Application (In)security & Ch 2: Core Defense Mechanisms
CNIT 128 3. Attacking iOS Applications (Part 2)
The Dark Side of PowerShell by George Dobrea
CNIT 128 7. Attacking Android Applications (Part 2)
CNIT 128 8. Identifying and Exploiting Android Implementation Issues (Part 1)
CNIT 129S - Ch 6a: Attacking Authentication
Ad

Similar to CNIT 128 9. Writing Secure Android Applications (20)

PDF
9 Writing Secure Android Applications
PDF
Mitigating Java Deserialization attacks from within the JVM
PDF
Mitigating Java Deserialization attacks from within the JVM (improved version)
PDF
Unsafe Deserialization Attacks In Java and A New Approach To Protect The JVM ...
PDF
Bypass_AV-EDR.pdf
PDF
Breaking Secure Mobile Applications - Hack In The Box 2014 KL
PPTX
From java to android a security analysis
PDF
RIoT (Raiding Internet of Things) by Jacob Holcomb
ODP
CISSP Week 14
PPTX
How to do Cryptography right in Android Part Two
PDF
Yow connected developing secure i os applications
PPTX
Decompiling Android
PPTX
metaploit framework
PDF
how-to-bypass-AM-PPL
PDF
Higher Level Malware
PPTX
Started In Security Now I'm Here
PDF
Captain Hook: Pirating AVs to Bypass Exploit Mitigations
PDF
Piratng Avs to bypass exploit mitigation
PPTX
Safe and secure programming practices for embedded devices
9 Writing Secure Android Applications
Mitigating Java Deserialization attacks from within the JVM
Mitigating Java Deserialization attacks from within the JVM (improved version)
Unsafe Deserialization Attacks In Java and A New Approach To Protect The JVM ...
Bypass_AV-EDR.pdf
Breaking Secure Mobile Applications - Hack In The Box 2014 KL
From java to android a security analysis
RIoT (Raiding Internet of Things) by Jacob Holcomb
CISSP Week 14
How to do Cryptography right in Android Part Two
Yow connected developing secure i os applications
Decompiling Android
metaploit framework
how-to-bypass-AM-PPL
Higher Level Malware
Started In Security Now I'm Here
Captain Hook: Pirating AVs to Bypass Exploit Mitigations
Piratng Avs to bypass exploit mitigation
Safe and secure programming practices for embedded devices
Ad

More from Sam Bowne (20)

PDF
Introduction to the Class & CISSP Certification
PDF
Cyberwar
PDF
3: DNS vulnerabilities
PDF
8. Software Development Security
PDF
4 Mapping the Application
PDF
3. Attacking iOS Applications (Part 2)
PDF
12 Elliptic Curves
PDF
11. Diffie-Hellman
PDF
2a Analyzing iOS Apps Part 1
PDF
12 Investigating Windows Systems (Part 2 of 3)
PDF
10 RSA
PDF
12 Investigating Windows Systems (Part 1 of 3
PDF
9. Hard Problems
PDF
8 Android Implementation Issues (Part 1)
PDF
11 Analysis Methodology
PDF
8. Authenticated Encryption
PDF
7. Attacking Android Applications (Part 2)
PDF
7. Attacking Android Applications (Part 1)
PDF
5. Stream Ciphers
PDF
6 Scope & 7 Live Data Collection
Introduction to the Class & CISSP Certification
Cyberwar
3: DNS vulnerabilities
8. Software Development Security
4 Mapping the Application
3. Attacking iOS Applications (Part 2)
12 Elliptic Curves
11. Diffie-Hellman
2a Analyzing iOS Apps Part 1
12 Investigating Windows Systems (Part 2 of 3)
10 RSA
12 Investigating Windows Systems (Part 1 of 3
9. Hard Problems
8 Android Implementation Issues (Part 1)
11 Analysis Methodology
8. Authenticated Encryption
7. Attacking Android Applications (Part 2)
7. Attacking Android Applications (Part 1)
5. Stream Ciphers
6 Scope & 7 Live Data Collection

Recently uploaded (20)

PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
Cell Structure & Organelles in detailed.
PPTX
GDM (1) (1).pptx small presentation for students
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
Pharma ospi slides which help in ospi learning
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Insiders guide to clinical Medicine.pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
Lesson notes of climatology university.
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
RMMM.pdf make it easy to upload and study
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
102 student loan defaulters named and shamed – Is someone you know on the list?
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Anesthesia in Laparoscopic Surgery in India
Microbial disease of the cardiovascular and lymphatic systems
Cell Structure & Organelles in detailed.
GDM (1) (1).pptx small presentation for students
TR - Agricultural Crops Production NC III.pdf
Pharma ospi slides which help in ospi learning
human mycosis Human fungal infections are called human mycosis..pptx
Insiders guide to clinical Medicine.pdf
Supply Chain Operations Speaking Notes -ICLT Program
PPH.pptx obstetrics and gynecology in nursing
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Lesson notes of climatology university.
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
O7-L3 Supply Chain Operations - ICLT Program
RMMM.pdf make it easy to upload and study
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Renaissance Architecture: A Journey from Faith to Humanism

CNIT 128 9. Writing Secure Android Applications

  • 1. CNIT 128 Hacking Mobile Devices 9. Writing Secure 
 Android Apps Updated 4-14-2021
  • 2. Common Vulnerabilities • Code injection • Logic flaws • Insecure storage • Application configuration • Insecure communication • Logging
  • 3. Topics • Principle of Least Exposure • Essential Security Mechanisms • Advanced Security Mechanisms • Slowing Down a Reverse Engineer
  • 5. Minimizing Attack Surface • Find all entry points • Code exposed to inputs from outside sources • Remove unnecessary entry points • Perform security checks at necessary entry points
  • 6. App Components • Don't export more components than required • The safest case is shown below • Most apps require some integration with other apps
  • 7. Data Storage • Avoid storing unnecessary data • Such as passwords! • Private directory is protected somewhat by the sandboxing • SD card is less protected
  • 8. Untrusted Sources • Inputs from SD card, Internet, Wi-Fi, Bluetooth, etc. • Verify authenticity with signature, encryption, or some other validation • Be careful loading classes or running executables from untrusted locations • Cryptographic protections are the best
  • 9. Minimal Permissions • Request the fewest permissions needed for your app • This is safer, and also avoids worrying careful users • Avoid risky permissions • INSTALL_PACKAGES • Using powerful shared users such as android.uid.system
  • 10. Bundling Files in the APK • APK can contain extra files by accident • May contain SSH credentials or other secrets
  • 12. Review Entry Points • Trace these functions
  • 13. Permission Protection • Exported components should be limited with permissions • Only available to apps with the same signature • If you really want to offer a component for public use • Great care is required in the implementation
  • 15. Task Manager Snooping • Remove your app from the recent app list • To avoid exposing private information on that image • Put this code in OnCreate() to show a blank screen in the list getWindow().addFlags(WindowManager.LayoutParams.FLAG_SE CURE) ; • Set this attribute in an activity to remove it entirely from the list intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_
 FROM_RECENTS);
  • 16. Tapjacking • Prevent touches from being sent through elements with this attribute: android:filterTouchesWhenObscured="true " • Or by using this method: view.setFilterTouchesWhenObscured(true);
  • 17. Dictionary • Disable additions to the dictionary to keep passwords and other secrets out • Add this attribute to an EditText box: android:inputType="textVisiblePassword"
  • 18. Fragment Attacks • Fragments are small UI elements that customize activities • But fragment injection vulnerabilities were found • Since Android 4.4, fragments are blocked by default • Use this code to allow a whitelist of fragments: @Override protected boolean isValidFragment(String fragmentName) { String[] validFragments = {"com.myapp.pref.frag1", "com.myapp.pref.frag2"}; return Arrays.asList(validFragments).
 contains(fragmentName); }
  • 19. Secure Trust Boundaries • Make sure there's no way to open an authenticated activity from unauthenticated areas of the app • One way: implement an app-wide authentication variable
  • 20. Masking Password Displays • Add this attribute to an EditText box: android:inputType="textPassword"
  • 21. Browsable Activities • Can be used directly from a web browser • High-value targets for attackers • Avoid using BROWSABLE • If you use it, consider all possible intents that could cause actions in your app
  • 23. Default Export Behavior • Prior to API 17, content providers were exported by default • To prevent this, put this code in the manifest: <provider android:name=".ContentProvider"
 android:authorities="com.myapp.ContentProvider" android:exported="false" > </provider>
  • 24. SQL Injection • Use prepared statements, like this: String[] userInput = new String[] {"book", "wiley"}; Cursor c = database.rawQuery("SELECT * FROM Products WHERE type=? AND brand=?", userInput);
  • 25. Directory Traversal • The getCanonicalPath() method removes .. characters and provides the absolute path to a file • The code on the next page uses this to limit paths to the /files/ subdirectory of the app's private data directory
  • 27. Pattern Matching • Pattern- matching checks may fail for variations of the path • Link Ch 9a
  • 28. Securing Broadcast Receivers • Secret codes are easily enumerated using apps on the Play Store • Don't trust them
  • 30. Creating Files and Folders Securely • Explicitly set permissions
  • 31. Encryption • Use AES for symmetric encryption, avoid ECB • Use RSA-2048 for asymmetric encryption • Password hashing advice in textbook is wrong • You need salting and stretching; better to avoid doing it yourself
  • 32. Random Numbers • Random() produces the same series of numbers each time it's run from the same seed • SecureRandom is better • Java provides methods to seed it from a source of entropy
  • 33. Random() import java.util.Random; class Main { public static void main(String[] args) { // create instance of Random class Random rand = new Random(1); // Generate random integers in range 0 to 999 int rand_int1 = rand.nextInt(1000); int rand_int2 = rand.nextInt(1000); // Print random integers System.out.println("Random Integers: "+rand_int1); System.out.println("Random Integers: "+rand_int2); } }
  • 34. • replit.com • Every run produces the same numbers Online Java Tester
  • 35. Key Generation • PBKDF2 uses many rounds of hashing to derive a key from a password • Key should be stored in Android Keystore
  • 36. Exposing Files • To allow specified other apps to see a file • Those apps need com.myapp.docs.READWITE permission • They can only access the /document/ folder
  • 38. HTTPS • HTTP is very unsafe • HTTPS is much better, but depends on trusted Certificate Authorities (CAs) • Certificate pinning makes HTTPS even more secure • Requiring a specific certificate or CA
  • 39. Local Communications • Transferring data from one app to another • Android API is the best method • Activities with intent-filters • In more recent Android versions • ChooserTargets, Shortcuts, direct share targets • Using network sockets or the clipboard is less safe
  • 41. WebView • Lets you display a Web page in an activity • Often leads to security problems • If loaded over HTTP, subject to interception and modification • More recommendations at • https://www.checkmarx.com/blog/android- webview-secure-coding-practices/
  • 43. Backups and Debugging • If android:allowBackup is false, an attacker can't back up files with physical access to the device • android:debuggable allows debugging
  • 44. API Version Targeting • minSdkVersion should be as large as possible • Lower values remove new security fixes • Values below 17 export content providers by default
  • 45. Android 9 • Targeting SDK 28+ gives you • DNS over TLS • Network TLS by default • Cleartext traffic must be explicitly set • Separate WebView directories for each process • Can't steal cookies
  • 47. Logging • Should be disabled in release builds • Use a centralized logging class • So it can be easily disabled • ProGuard can remove logging code
  • 48. Native Code • Notoriously difficult to secure • Limit its exposure to the outside world • Enable exploit mitigations • Use latest NDK version
  • 49. Exploit Mitigations • RELRO: Relocation Read-Only • Prevents GOT rewrites • RPATH / RUNPATH • Allows attacker to load modified libraries from a user-controlled path • Link Ch 9f
  • 51. Protection Level Downgrade • A malicious app can define a permission first with an insecure protection level • So your app inherits that level • Your app can check to make sure the protection levels are intact at each entry point
  • 52. Protecting Non-Exported Components • Attacker with root permissions can interact with them • You can add a request token to prevent that • Randomly generated • Stored in a static variable in memory • Intents must have this token to run
  • 53. Slowing Down a Reverse Engineer
  • 54. Obfuscation • ProGuard -- free but very ineffective • DexGuard -- paid version of ProGuard • Dash-O is good but expensive ($3000) • Arxan is another
  • 55. Root Detection • Search for su • See if default.prop allows ADB shell to run as root • See if adbd is running as root • Look for packages with names like • SuperSU or Superuser
  • 56. Emulator Detection • Check for emulator build properties
  • 57. Debugger Detection • Attacker may have modified your app or the environment to allow debugging