Link to this headingAndroid_Checklist.md
Link to this headingAndroid Insecure Sockets
Link to this headingOverview
All
Link to this headingRemediation Procedure
Link to this headingBlackbox
Link to this headingWhitebox
Check for the HttpURLConnection class
Check for the Socket Class
Link to this headingCertificate Pinning
Link to this headingOverview
Link to this headingRemediation Procedure
If you are using a new version of Android (API 24) then you can use the Network Security Configuration.
Add a similar configuration to your AndroidManifest.xml or the res/xml/network_security_config.xml file. For more information see the Official Android Documentation
Using OKHTTP framework. Use newer versions of the framework as older versions are vulnerable to a Public Vulnerability
Set a single Certificate Authority
Link to this headingBlackbox
Install Certificate and set up proxy.
Verify that no traffic is intercepted.
Link to this headingWhitebox
Do a Check for Key classes like the ones below
- SSLContext
- CertificateFactory
- X509Certificate
- KeyStore
Link to this headingSQL Injection Android
Link to this headingOverview
Without proper access control, an attacker can obtain data from a SQLite databases using SQL Injection.
Link to this headingRemediation Procedure
Use SQL Parameterized Queries and validate ids using a valid access control.
Link to this headingBlackbox
Link to this headingWhitebox
Link to this headingAndroid Messaging
Link to this headingOverview
The program performs SMS operations without verifying the phone number.
Link to this headingRemediation Procedure
SMS operations must not be performed without cause or consideration. Malicious software exploits these APIs to steal money and data from unwary users.
Link to this headingBlackbox
Link to this headingWhitebox
Look for the sendTextMessage function
Link to this headingAndroid Application has debugable set
Link to this headingOverview
When debugging is enabled
Debugging messages help attackers learn about the system and plan a form of attack.
Link to this headingRemediation Procedure
Make sure that debug flags are not set in production applications.
Link to this headingBlackbox
Link to this headingWhitebox
Look for the debuggable=true flag in the AndroidManifest.xml. It should be an element in the application tag.
Link to this headingAndroid Application has backup set
Link to this headingOverview
The program uses Android’s backup service to save persistent application data to a remote cloud storage or locally depending on the backup Agent.
Android applications can be configured with this backup service by setting the allowBackup attribute to true (the default value) and defining the backupAgent attribute on the <application> tag.
Android however, does not guarantee the security of your data while using backup, as the cloud storage and transport vary from device to device.
Link to this headingRemediation Procedure
Make sure that backup flags are not set in production applications.
Link to this headingBlackbox
Link to this headingWhitebox
Look for the allowbackup=true flag in the AndroidManifest.xml. It should be an element in the application tag.
Link to this headingAndroid Application stores data in the external storage
Link to this headingOverview
The program requests permission to write data to Android’s external storage and stores sensitive data to the external storage.
Link to this headingRemediation Procedure
Files written to external storage are readable and writeable by arbitrary programs and users. Programs must never write sensitive information, for instance personally identifiable information, to external storage. When you connect the Android device via USB to a PC or other device it enables USB mass storage mode. Any file written to external storage can be read and modified in this mode. In addition, files in external storage will remain there even after the application that wrote them is uninstalled, further increasing the risk that any sensitive information stored in them will be compromised.
Link to this headingBlackbox
Link to this headingWhitebox
Check for this line in the AndroidManifest.xml file.
Check for Mentions of getExternalStorageDirectory
Link to this headingInsecure SSL
Link to this headingOverview
The application implements a custom SSL interface.
When making a custom SSL interface there are many things to consider and implementing it without a library will introduce flaws into the application.
When applications that use custom SSL implementations applications may be vulnerable to vulnerable to a man-in-the-middle attack or other SSL vulnerabilities.
Android Hostname Verification Disabled
The use of AllowAllHostnameVerifier() or SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER turns off hostname verification when using SSL connections. This prevent SSLExceptions from triggering and could allow man-in-the-middle attacks.
Link to this headingRemediation Procedure
Link to this headingBlackbox
Link to this headingWhitebox
Example 1: The application sets the hostname verifier as below.
When Android calls createSocket() make sure that there is a hostname verification of the SSL Certificate.
Look for Calls to getInsecure(). This disables all SSL Certificate Checks
Link to this headingAndroid Insecure use of Shared Preferences
Link to this headingOverview
Saving private information, such as customer passwords, secret keys, and session tokens in to the Android Shared Preferences is insecure.
By default the Android Shared Preferences can only be accessed by the same application or an application in the same user group. The file itself is an unencrypted file in the Application directory and could be accessed if an attacker has physical access to the device.
Many developers trust the file system as a safe storage location for data, but it should not be trusted implicitly, particularly when privacy is a concern.
Link to this headingRemediation Procedure
Link to this headingBlackbox
Link to this headingWhitebox
Example 1: The following code stores user preferences using Android’s SharedPreferences class. Among other values that are stored, the user supplied password is stored on the device in plain text.
Link to this headingAndroid Exported Activity
Link to this headingOverview
By default the value of Activity, Receiver or a Service that contains a intent-filter is exported. When the explored flag is enabled the specified component is accessible to other applications on the Android device.
If target API is set to 16 or lower then the default exported activity is set to true
Receiver without broadcastPermission:
When a receiver is registered in code without a broadcast Permission all broadcast will be captured by the receiver.
The code below shows an registerReceiver without the broadcastPermission.
Broadcast without receiverPermission:
When a Broadcast is sent without a receiver Permission it can be intercepted by a malicious application.
The code below shows an registerReceiver without the receiverPermission.
Sticky Broadcast:
A Sticky Broadcast can not have a permission to specify with it and will always
Link to this headingRemediation Procedure
Use the registerReceiver function with a broadcastPermission.
Use the sendBroadcast function with a receiverPermission.
Link to this headingBlackbox
Link to this headingWhitebox
Link to this headingPermission Protection level set to Normal
Link to this headingOverview
When declaring a custom permission, there are four protection Levels normal, dangerous, signature, and signature or system.
- Normal permissions are granted to any application that requests them. (Depending on API level only after user confirmation)
- Signature permissions are granted only to applications signed by the same developer key as the package that defines the permission.
- Signature or system permissions are similar to signature permissions, but are also granted to packages in the Android system image.
Example 1: Below is an example of a custom permission declared with the normal protection level.
Link to this headingRemediation Procedure
Set protectionLevel to “signature” or “signature or system” depending on the needs of the application