52
Common Security Pitfalls in Android Apps Aditya Gupta Attify

Android Security - Common Security Pitfalls in Android Applications

Embed Size (px)

DESCRIPTION

Aditya Gupta from Attify talking about what are the common security pitfalls in android apps

Citation preview

Page 1: Android Security - Common Security Pitfalls in Android Applications

Common Security Pitfalls in

Android Apps

Aditya Gupta Attify

Page 2: Android Security - Common Security Pitfalls in Android Applications

Who Am i

• Founder, Attify

• Mobile Security Researcher

• Developing a secure BYOD solution for enterprises

• Co-creator of AFE (Android Framework for Exploitation)

• Upcoming tool : DroidSE

• Speaker/Trainer at BlackHat, Toorcon, ClubHack, Nullcon, OWASP AppSec, Syscan etc.

Page 3: Android Security - Common Security Pitfalls in Android Applications

Agenda

• Security Overview of Android Apps

• Some vulnerabilities in Android Apps

• Secure Coding

Page 4: Android Security - Common Security Pitfalls in Android Applications

Android Security Model

• Based on Linux

• Security features are derived mostly from Linux

• Application Isolation

• Each app in its own DVM

Page 5: Android Security - Common Security Pitfalls in Android Applications

Security Overview of Android Apps

• Application Sandboxing

• Data stored in /data/data/[package-name]/

• AndroidManifest.xml plays an important role

• Permissions while accessing activities, services, content providers

Page 6: Android Security - Common Security Pitfalls in Android Applications

Hard Coding Sensitive Info

• Have seen some apps hardcode sensitive info

• Reversing applications

• Encrypting passwords : really common

• Use protection to prevent apps from reversing

• Don't ever hardcode a sensitive info in an app.

Page 7: Android Security - Common Security Pitfalls in Android Applications

Protecting against Reversing

Page 8: Android Security - Common Security Pitfalls in Android Applications

Logging Sensitive Information

Page 9: Android Security - Common Security Pitfalls in Android Applications

Logging Sensitive Information

Log.d("Facebook-authorize", "Login Success! access_token=" + getAccessToken() + " expires=" + getAccessExpires());

Page 10: Android Security - Common Security Pitfalls in Android Applications

Leaking Content Providers

• Content Providers

• What can one application do to another

• Leakage of content providers

• By default exported

Page 11: Android Security - Common Security Pitfalls in Android Applications

Leaking Content Providers

Page 12: Android Security - Common Security Pitfalls in Android Applications
Page 13: Android Security - Common Security Pitfalls in Android Applications
Page 14: Android Security - Common Security Pitfalls in Android Applications

Dropbox

Page 15: Android Security - Common Security Pitfalls in Android Applications
Page 16: Android Security - Common Security Pitfalls in Android Applications
Page 17: Android Security - Common Security Pitfalls in Android Applications

Insecure Data Storage

Page 18: Android Security - Common Security Pitfalls in Android Applications
Page 19: Android Security - Common Security Pitfalls in Android Applications
Page 20: Android Security - Common Security Pitfalls in Android Applications
Page 21: Android Security - Common Security Pitfalls in Android Applications
Page 22: Android Security - Common Security Pitfalls in Android Applications

Android WebView vuln

• What's a Webview?

Page 23: Android Security - Common Security Pitfalls in Android Applications

• Framing Web components into application

• Could be really useful while building applications

• Does it also allows Javascript?

Android WebView vuln

Page 24: Android Security - Common Security Pitfalls in Android Applications

Javascript in Webviews

• Javascript is allowed in Webviews

• Javascript could be used to interact with the app's interface

• Malicious functions could be executed

Page 25: Android Security - Common Security Pitfalls in Android Applications

Malicious functions with JS

• Could be used to send SMS or place calls

• Or to install another application

• Get a reverse shell to a remote location

• Modify file system or steal something from the device

Page 26: Android Security - Common Security Pitfalls in Android Applications
Page 27: Android Security - Common Security Pitfalls in Android Applications
Page 28: Android Security - Common Security Pitfalls in Android Applications

Ad Libraries, anyone?• InMobi

• List of Exposed methods :

• makeCall

• postToSocial

• sendMail

• sendSMS

• takeCameraPicture

• getGalleryImage

Page 29: Android Security - Common Security Pitfalls in Android Applications

Ad Libraries, anyone?

Page 30: Android Security - Common Security Pitfalls in Android Applications

Fix it

setJavascriptEnabled(false)

Page 31: Android Security - Common Security Pitfalls in Android Applications

SQLite Injection

• SQLite databases for storing application's data

• Storing sensitive information in databases

• Do you sanitize user input before applying SQL queries

Page 32: Android Security - Common Security Pitfalls in Android Applications

!uname = (EditText) findViewById(R.id.username); pword = (EditText) findViewById(R.id.password); !!String getSQL = "SELECT * FROM " + tableName + " WHERE " + username + " = '" + uname + "' AND " + password + " = '" + pword + "'"; !Cursor cursor = dataBase.rawQuery(getSQL , null);

Sample Code

Page 33: Android Security - Common Security Pitfalls in Android Applications

Insecure File Permissions

• File storing sensitive data need to have proper permissions

• Should be accessible only by the application

Page 34: Android Security - Common Security Pitfalls in Android Applications
Page 35: Android Security - Common Security Pitfalls in Android Applications
Page 36: Android Security - Common Security Pitfalls in Android Applications
Page 37: Android Security - Common Security Pitfalls in Android Applications

Android Backup Vulnerability

• Allows backup of application's data

• No root needed in the device

• Attacker could read/modify app's data and restore it back

• Default behaviour in AndroidManifest.xml

Page 38: Android Security - Common Security Pitfalls in Android Applications
Page 39: Android Security - Common Security Pitfalls in Android Applications
Page 40: Android Security - Common Security Pitfalls in Android Applications
Page 41: Android Security - Common Security Pitfalls in Android Applications

android:allowBackup="false"

Preventing Backup vulnerability

Page 42: Android Security - Common Security Pitfalls in Android Applications

Network Traffic

Page 43: Android Security - Common Security Pitfalls in Android Applications
Page 44: Android Security - Common Security Pitfalls in Android Applications
Page 45: Android Security - Common Security Pitfalls in Android Applications

Securing Android

Applications

Page 46: Android Security - Common Security Pitfalls in Android Applications

Activities

<activity android:name=".SecureActivity" android:permission="com.example.secure.permission.START_ACTIVITY1"> </activity>

Page 47: Android Security - Common Security Pitfalls in Android Applications

Services

<service android:name=".SecureService" android:permission="com.example.secure.permission.SecurePerm" android:enabled="true" android:exported="true"> </service>

Page 48: Android Security - Common Security Pitfalls in Android Applications

Content Providers

<provider android.name="com.example.secure.SecureProvider" android.authorities="com.example.secure.mailprovider" android.readPermission="com.example.testapps.test1.permission.READ_DATE" android.writePermission="com.example.secure.permission.WRITE_DATA" android:grantUriPermissions="true"> !</provider>

Page 49: Android Security - Common Security Pitfalls in Android Applications

If you don't need

android:exported = "false"

Page 50: Android Security - Common Security Pitfalls in Android Applications

Summary

• Avoid common mistakes

• Store data in encrypted form

• Sending data through HTTP/insecure HTTPs

Page 51: Android Security - Common Security Pitfalls in Android Applications
Page 52: Android Security - Common Security Pitfalls in Android Applications

`

• Drop a mail at [email protected]