Testing and Securing Android Studio Applications
上QQ阅读APP看书,第一时间看更新

An overview of Android security

Android provides a secure architecture to protect the system and its applications. Android architecture is structured like a software stack in which each component of a layer accepts that the layer following it is secure. The following figure shows a simplified version of the Android security architecture:

Android OS is a multiuser, Linux-based platform in which each app has a different user. Each app has its own user ID (UID) in the Linux kernel that is unique. The UID is assigned by the system and is unknown to the app. Because of the unique UID, Android apps run in separate processes with different permissions. This mechanism is known as application sandboxing. The Android Application Sandbox isolates each application's data and code execution to improve its security and prevent malware. This means that under normal circumstances, you cannot have access to other application's data and other applications do not have access to your application's data. As the Application Sandbox is implemented in the Linux kernel, the security provided by this mechanism is extended to all the layers above the kernel (such as libraries, Android runtime, application framework, and application runtime). For example, if a memory corruption error is generated, this error will only have consequences for the application in which the error was produced.

Application sandboxing is one of the main security features of Android, but we can also find the following features in the security model:

  • Application-defined permissions: If applications are isolated from each other, how can they share information when required? Applications can define permissions to allow other applications to control its data. There are also many predefined system-based permissions cover many situations and that will reduce the necessity of creating permissions, especially for your application.
  • Interprocess communication: Under normal circumstances, every component of an application runs in the same process. However, there are times when developers decide to run certain components in different processes. Android provides an interprocess communication method that is secure and robust.
  • Support for secure networking: Network transactions are especially risky on mobile devices that commonly use unsecured Wi-Fi networks in public spaces. Android supports the most commonly used protocols to secure connections under these extreme conditions.
  • Support for cryptography: Android provides a framework that developers can use with tested and robust implementations of commonly used cryptographic methods.
  • Encrypted file system: Android provides a full filesystem encryption. This means that the information stored on an Android device is encrypted and is therefore protected at any time against external entities. This option is not active by default and requires a username and a password.
  • Application signing: The installation package of every app must be signed with a certificate, which can be a self-signed certificate. An attacker can preserve their anonymity, since it's not necessary for a trusted third-party to sign the certificate. Certificates are mainly used to distinguish developers and allow the system to manage permissions. To prevent an attacker from modifying your application, you should keep your certificate safe. Furthermore, application updates must be signed with this same certificate.