Slide 1

Slide 1 text

Android Developing Secure Application Harsh Dattani, GDG Baroda A learner like you all! No body is PRO in security

Slide 2

Slide 2 text

AboutMe.apk A Cyber Security Student @Gujarat Forensic Sciences University and a Learner! Always! :P Om Shanti Harsh Dattani

Slide 3

Slide 3 text

Secure Coding Guidelines ● Such guidelines even exists on Earth?? :D

Slide 4

Slide 4 text

Secure Coding Guidelines ● Such guidelines even exists on Earth?? :D ● Who cares! No one’s gonna hack my app :P

Slide 5

Slide 5 text

Secure Coding Guidelines ● Such guidelines even exists on Earth?? :D ● Who cares! No one’s gonna hack my app :P ● Lets finish this project anyhow!! ;)

Slide 6

Slide 6 text

Secure Coding Guidelines ● Computer Emergency Response Teams (CERT) are expert groups that handle Computer/IT security incidents. ● Issued Android Secure Coding Guidelines.

Slide 7

Slide 7 text

We all Know this!

Slide 8

Slide 8 text

And this! ● Activity ● Content Providers ● Intents ● Permissions ● Services ● Shared Prefs ● Views (Mostly WebView)

Slide 9

Slide 9 text

Also this!

Slide 10

Slide 10 text

Assets in Android

Slide 11

Slide 11 text

Assets in Android ● Device Information ● Personal Information (User’s) ● Friend’s Personal Information

Slide 12

Slide 12 text

Attack Vectors in Android

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

Attack Vectors in Android ● Mounting SD Card in PC

Slide 15

Slide 15 text

Attack Vectors in Android ● Mounting SD Card in PC ● Malicious App

Slide 16

Slide 16 text

Attack Vectors in Android ● Mounting SD Card in PC ● Malicious App ● Network Attack

Slide 17

Slide 17 text

Attack Vectors in Android ● Mounting SD Card in PC ● Malicious App ● Network Attack ● Malicious File Attack

Slide 18

Slide 18 text

Attack Vectors in Android ● Mounting SD Card in PC ● Malicious App ● Network Attack ● Malicious File Attack ● User’s Unawareness

Slide 19

Slide 19 text

Attack Vectors in Android ● Mounting SD Card in PC ● Malicious App ● Network Attack ● Malicious File Attack ● User’s Unawareness ● USB Debugging

Slide 20

Slide 20 text

Attack Vectors in Android ● Mounting SD Card in PC ● Malicious App ● Network Attack ● Malicious File Attack ● User’s Unawareness ● USB Debugging ● Root permissions!! (Can do anything)

Slide 21

Slide 21 text

Attack Vectors in Android ● Mounting SD Card in PC ● Malicious App ● Network Attack ● Malicious File Attack ● User’s Unawareness ● USB Debugging ● Root permissions!! (Can do anything)

Slide 22

Slide 22 text

Security Policies

Slide 23

Slide 23 text

Unix Security Policy 1. Process Isolation 2. Hardware Isolation 3. User Permission Model 4. R/W/X Permissions to file 5. Secure IPC

Slide 24

Slide 24 text

Android Security Policy 1. Application Isolation 2. Sandbox of Application 3. Secure Communication 4. Signing the Application 5. Permission model of Application

Slide 25

Slide 25 text

To Do’s to Secure Apps

Slide 26

Slide 26 text

1. Avoid Simple Logics

Slide 27

Slide 27 text

1: Avoid Simple logics if(LoginAccess==1){ ... ... } ---------------------------------------------------------------------------- if(Login.Access = True){ ... ... }

Slide 28

Slide 28 text

2. Test 3rd Party Libraries!

Slide 29

Slide 29 text

“Caution: Developers rely heavily on third-party libraries. It is important to thoroughly probe and test this as you test your code. Third-party libraries can contain vulnerabilities and weaknesses. Many developers assume third-party libraries are well-developed and tested, however, issues can and do exist in their code.

Slide 30

Slide 30 text

3. Use Encryption

Slide 31

Slide 31 text

“Caution: External storage can become unavailable if the user mounts the external storage on a computer or removes the media, and there's no security enforced upon files you save to the external storage. All applications can read and write files placed on the external storage and the user can remove them.” -- http://developer.android.com/guide/topics/data/data-storage.html

Slide 32

Slide 32 text

But How to Encrypt?

Slide 33

Slide 33 text

How to Encrypt or Encode? 1. Encode Shared Preferences 2. Encrypt SQLite: SQLCipher 3. Encrypt Network: TLS 4. Data Encryption: Facebook’s Conceal Library 5. MD5, SHA Sensitive Data

Slide 34

Slide 34 text

4. Handle Input Data

Slide 35

Slide 35 text

“Caution: An Android application can be coded in Java or native code, which is C++. When Java is used, many of the data validation issues like buffer overflow, format string issues, and others are eliminated, as the language itself is not vulnerable. When using native code, special care needs to be taken when data is read from an untrusted source because it is vulnerable to issues like buffer overflow, format string issues, and more.” -- White Paper by Mcafee

Slide 36

Slide 36 text

5. Secure Intents

Slide 37

Slide 37 text

Slide 38

Slide 38 text

6. Secure WebView

Slide 39

Slide 39 text

● setJavaScriptEnabled(): Default is False ● setPluginState(): Default is OFF ● setAllowFileAccess(): Default is True ● setAllowContentAccess(): Default is True ● setAllowFileAccessFromFileURLs(): Default value is True for API level 15 and below, and False for API level level 16 and above. ● setAllowUniversalAccessFromFileURLs(): Default value is True for API level 15 and below, and False for API level level 16 and above. --------------------------------------------------------------------------------------------------------------------------------------------- ● Don’t: Enable JavaScript for all pages. ● Do: If Enabled, make sure it’s a local address or trusted address. ● Use HTTPS, whenever possible

Slide 40

Slide 40 text

7. Secure Logs

Slide 41

Slide 41 text

Log.v("method", Login.TAG + ", username=" + name); Log.v("method", Login.TAG + ", password=" + pass); ---------------------------------------------------------------------------- -assumenosideeffects class android.util.Log { public static *** d(...); public static *** w(...); public static *** v(...); public static *** i(...); }

Slide 42

Slide 42 text

8. Secure Intent Leaks

Slide 43

Slide 43 text

● Don’t Broadcast Sensitive information in Intents ● Attacker can intercept the broadcasted data. (Demo) ● Broadcast Securely using: LocalBroadcastManager.getInstance(this).sendBroadcast(intent);

Slide 44

Slide 44 text

9. Code Obfuscation

Slide 45

Slide 45 text

● Proguard ● Don’t include unused Classes and Libraries ● Difficult to protect from Smali Decompilation

Slide 46

Slide 46 text

10. Use of Tokens for Authentication

Slide 47

Slide 47 text

11. Use of HTTPS!

Slide 48

Slide 48 text

Our Evils: 1. ADB 2. Malicious Applications 3. Unprotected Network 4. Sniffers

Slide 49

Slide 49 text

Our Friends: 1. Android Fuzzers 2. Xposed Framework 3. Drozer 4. APKtool or any other Static Analysis Tool 5. Penetration Tools for Android and Many more...

Slide 50

Slide 50 text

AskMe.apk?

Slide 51

Slide 51 text

ContactMe.apk! [email protected] github.com/harshdattani