1page.title=Android Security Overview 2@jd:body 3 4<!-- 5 Copyright 2013 The Android Open Source Project 6 7 Licensed under the Apache License, Version 2.0 (the "License"); 8 you may not use this file except in compliance with the License. 9 You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, software 14 distributed under the License is distributed on an "AS IS" BASIS, 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 See the License for the specific language governing permissions and 17 limitations under the License. 18--> 19<div id="qv-wrapper"> 20 <div id="qv"> 21 <h2>In this document</h2> 22 <ol id="auto-toc"> 23 </ol> 24 </div> 25</div> 26 27<h2 id="introduction">Introduction</h2> 28<p>Android is a modern mobile platform that was designed to be truly open. Android 29applications make use of advanced hardware and software, as well as local and 30served data, exposed through the platform to bring innovation and value to 31consumers. To protect that value, the platform must offer an application 32environment that ensures the security of users, data, applications, the device, 33and the network.</p> 34 35<p>Securing an open platform requires a robust security architecture and rigorous 36security programs. Android was designed with multi-layered security that 37provides the flexibility required for an open platform, while providing 38protection for all users of the platform.</p> 39 40<p>Android was designed with developers in mind. Security controls were designed 41to reduce the burden on developers. Security-savvy developers can easily work 42with and rely on flexible security controls. Developers less familiar with 43security will be protected by safe defaults.</p> 44 45<p>Android was designed with device users in mind. Users are provided visibility 46into how applications work, and control over those applications. This design 47includes the expectation that attackers would attempt to perform common 48attacks, such as social engineering attacks to convince device users to install 49malware, and attacks on third-party applications on Android. Android was 50designed to both reduce the probability of these attacks and greatly limit the 51impact of the attack in the event it was successful.</p> 52 53<p>This document outlines the goals of the Android security program, describes the 54fundamentals of the Android security architecture, and answers the most 55pertinent questions for system architects and security analysts. This document 56focuses on the security features of Android's core platform and does not 57discuss security issues that are unique to specific applications, such as those 58related to the browser or SMS application. Recommended best practices for 59building Android devices, deploying Android devices, or developing applications 60for Android are not the goal of this document and are provided elsewhere.</p> 61 62<h1 id="background">Background</h1> 63<p>Android provides an open source platform and application environment for mobile 64devices.</p> 65<p>The main Android platform building blocks are:</p> 66<ul> 67<li> 68<p><strong>Device Hardware</strong>: Android runs on a wide range of hardware configurations 69including smart phones, tablets, and set-top-boxes. Android is 70processor-agnostic, but it does take advantage of some hardware-specific 71security capabilities such as ARM v6 eXecute-Never.</p> 72</li> 73<li> 74<p><strong>Android Operating System</strong>: The core operating system is built on top of 75the Linux kernel. All device resources, like camera functions, GPS data, 76Bluetooth functions, telephony functions, network connections, etc. are 77accessed through the operating system.</p> 78</li> 79<li> 80<p><strong>Android Application Runtime</strong>: Android applications are most often written 81in the Java programming language and run in the Dalvik virtual machine. 82However, many applications, including core Android services and applications 83are native applications or include native libraries. Both Dalvik and native 84applications run within the same security environment, contained within the 85Application Sandbox. Applications get a dedicated part of the filesystem in 86which they can write private data, including databases and raw files.</p> 87</li> 88</ul> 89<p>Android applications extend the core Android operating system. There are two 90primary sources for applications:</p> 91<ul> 92<li> 93<p><strong>Pre-Installed Applications</strong>: Android includes a set of pre-installed 94applications including phone, email, calendar, web browser, and contacts. These 95function both as user applications and to provide key device capabilities that 96can be accessed by other applications. Pre-installed applications may be part 97of the open source Android platform, or they may be developed by an OEM for a 98specific device.</p> 99</li> 100<li> 101<p><strong>User-Installed Applications</strong>: Android provides an open development 102environment supporting any third-party application. Google Play offers 103users hundreds of thousands of applications.</p> 104</li> 105</ul> 106<p>Google provides a set of cloud-based services that are available to any 107compatible Android device. The primary services are:</p> 108<ul> 109<li> 110<p><strong>Google Play</strong>: Google Play is a collection of services that 111allow users to discover, install, and purchase applications from their Android 112device or the web. Google Play makes it easy for developers to reach Android 113users and potential customers. Google Play also provides community review, 114application <a href="https://developer.android.com/guide/publishing/licensing.html">license 115verification</a>, application security scanning, and other security services.</p> 116</li> 117<li> 118<p><strong>Android Updates</strong>: The Android update service delivers new capabilities and 119security updates to Android devices, including updates through the web or over 120the air (OTA).</p> 121</li> 122<li> 123<p><strong>Application Services</strong>: Frameworks that allow Android applications to use 124cloud capabilities such as (<a href="https://developer.android.com/guide/topics/data/backup.html">backing 125up</a>) application 126data and settings and cloud-to-device messaging 127(<a href="https://code.google.com/android/c2dm/index.html">C2DM</a>) 128for push messaging.</p> 129</li> 130</ul> 131<p>These services are not part of the Android Open Source Project and are out 132of scope for this document. But they are relevant to the security of most 133Android devices, so a related security document titled “Google Services for 134Android: Security Overview” is available.</p> 135<h2 id="android-security-program-overview">Android Security Program Overview</h2> 136<p>Early on in development, the core Android development team recognized that a 137robust security model was required to enable a vigorous ecosystem of 138applications and devices built on and around the Android platform and supported 139by cloud services. As a result, through its entire development lifecycle, 140Android has been subjected to a professional security program. The Android team 141has had the opportunity to observe how other mobile, desktop, and server platforms 142prevented and reacted to security issues and built a security 143program to address weak points observed in other offerings.</p> 144<p>The key components of the Android Security Program include:</p> 145<ul> 146<li><strong>Design Review</strong>: The Android security process begins early in the 147development lifecycle with the creation of a rich and configurable security 148model and design. Each major feature of the platform is reviewed by engineering 149and security resources, with appropriate security controls integrated into the 150architecture of the system.</li> 151<li><strong>Penetration Testing and Code Review</strong>: During the development of the 152platform, Android-created and open-source components are subject to vigorous 153security reviews. These reviews are performed by the Android Security Team, 154Google’s Information Security Engineering team, and independent security 155consultants. The goal of these reviews is to identify weaknesses and possible 156vulnerabilities well before the platform is open-sourced, and to simulate the 157types of analysis that will be performed by external security experts upon 158release.</li> 159<li><strong>Open Source and Community Review</strong>: The Android Open Source Project enables 160broad security review by any interested party. Android also uses open source 161technologies that have undergone significant external security review, 162such as the Linux kernel. Google Play provides a forum for users and companies 163to provide information about specific applications directly to users.</li> 164<li><strong>Incident Response</strong>: Even with all of these precautions, security issues 165may occur after shipping, which is why the Android project has created a 166comprehensive security response process. A full-time Android security team 167constantly monitors Android-specific and the general security community for 168discussion of potential vulnerabilities. Upon the discovery of legitimate 169issues, the Android team has a response process that enables the rapid 170mitigation of vulnerabilities to ensure that potential risk to all Android 171users is minimized. These cloud-supported responses can include updating the 172Android platform (over-the-air updates), removing applications from Google 173Play, and removing applications from devices in the field.</li> 174</ul> 175<h2 id="android-platform-security-architecture">Android Platform Security Architecture</h2> 176<p>Android seeks to be the most secure and usable operating system for mobile 177platforms by re-purposing traditional operating system security controls to:</p> 178<ul> 179<li>Protect user data</li> 180<li>Protect system resources (including the network)</li> 181<li>Provide application isolation</li> 182</ul> 183<p>To achieve these objectives, Android provides these key security features:</p> 184<ul> 185<li>Robust security at the OS level through the Linux kernel</li> 186<li>Mandatory application sandbox for all applications</li> 187<li>Secure interprocess communication</li> 188<li>Application signing</li> 189<li>Application-defined and user-granted permissions</li> 190</ul> 191<p>The sections below describe these and other security features of the Android 192platform. <em>Figure 1</em> summarizes the security components and considerations of 193the various levels of the Android software stack. Each component assumes that 194the components below are properly secured. With the exception of a small amount 195of Android OS code running as root, all code above the Linux Kernel is 196restricted by the Application Sandbox.</p> 197<p><img alt="Figure 1: Android software stack" src="images/image00.png" /></p> 198<p><em>Figure 1: Android software stack.</em></p> 199<h1 id="system-and-kernel-level-security">System and Kernel Level Security</h1> 200<p>At the operating system level, the Android platform provides the security of 201the Linux kernel, as well as a secure inter-process communication (IPC) 202facility to enable secure communication between applications running in 203different processes. These security features at the OS level ensure that even 204native code is constrained by the Application Sandbox. Whether that code is 205the result of included application behavior or a exploitation of an application 206vulnerability, the system would prevent the rogue application from harming 207other applications, the Android system, or the device itself.</p> 208<h2 id="linux-security">Linux Security</h2> 209<p>The foundation of the Android platform is the Linux kernel. The Linux kernel 210itself has been in widespread use for years, and is used in millions of 211security-sensitive environments. Through its history of constantly being 212researched, attacked, and fixed by thousands of developers, Linux has become a 213stable and secure kernel trusted by many corporations and security 214professionals.</p> 215<p>As the base for a mobile computing environment, the Linux kernel provides 216Android with several key security features, including:</p> 217<ul> 218<li>A user-based permissions model</li> 219<li>Process isolation</li> 220<li>Extensible mechanism for secure IPC</li> 221<li>The ability to remove unnecessary and potentially insecure parts of the kernel</li> 222</ul> 223<p>As a multiuser operating system, a fundamental security objective of the Linux 224kernel is to isolate user resources from one another. The Linux security 225philosophy is to protect user resources from one another. Thus, Linux:</p> 226<ul> 227<li>Prevents user A from reading user B's files</li> 228<li>Ensures that user A does not exhaust user B's memory</li> 229<li>Ensures that user A does not exhaust user B's CPU resources</li> 230<li>Ensures that user A does not exhaust user B's devices (e.g. telephony, GPS, 231bluetooth)</li> 232</ul> 233 234<h2 id="the-application-sandbox">The Application Sandbox</h2> 235<p>The Android platform takes advantage of the Linux user-based protection as a 236means of identifying and isolating application resources. The Android system 237assigns a unique user ID (UID) to each Android application and runs it as that user 238in a separate process. This approach is different from other operating systems 239(including the traditional Linux configuration), where multiple applications 240run with the same user permissions.</p> 241<p>This sets up a kernel-level Application Sandbox. The kernel enforces security 242between applications and the system at the process level through standard Linux 243facilities, such as user and group IDs that are assigned to applications. By 244default, applications cannot interact with each other and applications have 245limited access to the operating system. If application A tries to do something 246malicious like read application B's data or dial the phone without permission 247(which is a separate application), then the operating system protects against 248this because application A does not have the appropriate user privileges. The 249sandbox is simple, auditable, and based on decades-old UNIX-style user 250separation of processes and file permissions.</p> 251<p>Since the Application Sandbox is in the kernel, this security model extends to 252native code and to operating system applications. All of the software above the 253kernel in <em>Figure 1</em>, including operating system libraries, application 254framework, application runtime, and all applications run within the Application 255Sandbox. On some platforms, developers are constrained to a specific 256development framework, set of APIs, or language in order to enforce security. 257On Android, there are no restrictions on how an application can be written that 258are required to enforce security; in this respect, native code is just as 259secure as interpreted code.</p> 260<p>In some operating systems, memory corruption errors generally lead to 261completely compromising the security of the device. This is not the case in 262Android due to all applications and their resources being sandboxed at the OS 263level. A memory corruption error will only allow arbitrary code execution in 264the context of that particular application, with the permissions established by 265the operating system.</p> 266<p>Like all security features, the Application Sandbox is not unbreakable. 267However, to break out of the Application Sandbox in a properly configured 268device, one must compromise the security of the the Linux kernel.</p> 269<h2 id="system-partition-and-safe-mode">System Partition and Safe Mode</h2> 270<p>The system partition contains Android's kernel as well as the operating system 271libraries, application runtime, application framework, and applications. This 272partition is set to read-only. When a user boots the device into Safe Mode, 273only core Android applications are available. This ensures that the user can 274boot their phone into an environment that is free of third-party software.</p> 275 276<h2 id="filesystem-permissions">Filesystem Permissions</h2> 277<p>In a UNIX-style environment, filesystem permissions ensure that one user cannot 278alter or read another user's files. In the case of Android, each application 279runs as its own user. Unless the developer explicitly exposes files to other 280applications, files created by one application cannot be read or altered by 281another application.</p> 282 283<h2 id="se-linux">Security-Enhanced Linux</h2> 284 285<p>Android uses Security-Enhanced 286Linux (SELinux) to apply access control policies and establish an environment of 287mandatory access control (mac). See <a 288href="{@docRoot}devices/tech/security/se-linux.html">Validating 289Security-Enhanced Linux in 290Android</a> for details.</p> 291 292<h2 id="crypto">Cryptography</h2> 293 294<p> 295Android provides a set of cryptographic APIs for use by applications. These 296include implementations of standard and commonly used cryptographic primitives 297such as AES, RSA, DSA, and SHA. Additionally, APIs are provided for higher level 298protocols such as SSL and HTTPS. 299</p> 300 301<p> 302Android 4.0 introduced the 303<a href="http://developer.android.com/reference/android/security/KeyChain.html">KeyChain</a> 304class to allow applications to use the system credential storage for private 305keys and certificate chains. 306</p> 307 308<h2>Memory Management Security Enhancements</h2> 309 310Android includes many features that make common security issues harder to 311exploit. The Android SDK, compilers, and OS use tools to make common memory 312corruption issues significantly harder to exploit, including: 313 314<dl> 315<dt><strong>Android 1.5</strong></dt> 316<dd><ul> 317<li>ProPolice to prevent stack buffer overruns (-fstack-protector)</li> 318<li>safe_iop to reduce integer overflows</li> 319<li>Extensions to OpenBSD dlmalloc to prevent double free() vulnerabilities and 320to prevent chunk consolidation attacks. Chunk consolidation attacks are a 321common way to exploit heap corruption.</li> 322<li>OpenBSD calloc to prevent integer overflows during memory allocation</li> 323</ul> 324</dd> 325 326<dt><strong>Android 2.3</strong></dt> 327<dd><ul> 328<li>Format string vulnerability protections (-Wformat-security -Werror=format-security)</li> 329<li>Hardware-based No eXecute (NX) to prevent code execution on the stack and heap</li> 330<li>Linux mmap_min_addr to mitigate null pointer dereference privilege 331escalation (further enhanced in Android 4.1)</li> 332</ul> 333</dd> 334 335<dt><strong>Android 4.0</strong></dt> 336<dd>Address Space Layout Randomization (ASLR) to randomize key locations in memory 337</dd> 338 339<dt><strong>Android 4.1</strong></dt> 340<dd><ul> 341<li>PIE (Position Independent Executable) support</li> 342<li>Read-only relocations / immediate binding (-Wl,-z,relro -Wl,-z,now)</li> 343<li>dmesg_restrict enabled (avoid leaking kernel addresses)</li> 344<li>kptr_restrict enabled (avoid leaking kernel addresses)</li> 345</ul> 346</dd> 347 348<dt><strong>Android 4.2</strong></dt> 349<dd><code>FORTIFY_SOURCE</code> for system code</dd> 350 351</dl> 352 353<h2>Rooting of Devices</h2> 354<p> 355By default, on Android only the kernel and a small subset of the core 356applications run with root permissions. Android does not prevent a user or 357application with root permissions from modifying the operating system, kernel, 358and any other application. In general, root has full access to all 359applications and all application data. Users that change the permissions on an 360Android device to grant root access to applications increase the security 361exposure to malicious applications and potential application flaws. 362</p> 363<p> 364The ability to modify an Android device they own is important to developers 365working with the Android platform. On many Android devices users have the 366ability to unlock the bootloader in order to allow installation of an alternate 367operating system. These alternate operating systems may allow an owner to gain 368root access for purposes of debugging applications and system components or to 369access features not presented to applications by Android APIs. 370</p> 371<p> 372On some devices, a person with physical control of a device and a USB cable is 373able to install a new operating system that provides root privileges to the 374user. To protect any existing user data from compromise the bootloader unlock 375mechanism requires that the bootloader erase any existing user data as part of 376the unlock step. Root access gained via exploiting a kernel bug or security 377hole can bypass this protection. 378</p> 379<p> 380Encrypting data with a key stored on-device does not protect the application 381data from root users. Applications can add a layer of data protection using 382encryption with a key stored off-device, such as on a server or a user 383password. This approach can provide temporary protection while the key is not 384present, but at some point the key must be provided to the application and it 385then becomes accessible to root users. 386</p> 387<p> 388A more robust approach to protecting data from root users is through the use of 389hardware solutions. OEMs may choose to implement hardware solutions that limit 390access to specific types of content such as DRM for video playback, or the 391NFC-related trusted storage for Google wallet. 392</p> 393<p> 394In the case of a lost or stolen device, full filesystem encryption on Android 395devices uses the device password to protect the encryption key, so modifying 396the bootloader or operating system is not sufficient to access user data 397without the user’s device password. 398</p> 399<h2>User Security Features</h2> 400 401<h3 id="filesystem-encryption">Filesystem Encryption</h3> 402 403<p>Android 3.0 and later provides full filesystem encryption, so all user data can 404be encrypted in the kernel using the dmcrypt implementation of AES128 with CBC 405and ESSIV:SHA256. The encryption key is protected by AES128 using a key 406derived from the user password, preventing unauthorized access to stored data 407without the user device password. To provide resistance against systematic 408password guessing attacks (e.g. “rainbow tables” or brute force), the 409password is combined with a random salt and hashed repeatedly with SHA1 using 410the standard PBKDF2 algorithm prior to being used to decrypt the filesystem 411key. To provide resistance against dictionary password guessing attacks, 412Android provides password complexity rules that can be set by the device 413administrator and enforced by the operating system. Filesystem encryption 414requires the use of a user password, pattern-based screen lock is not supported.</p> 415<p>More details on implementation of filesystem encryption are available at 416<a href="/devices/tech/encryption/android_crypto_implementation.html">https://source.android.com/devices/tech/encryption/android_crypto_implementation.html</a></p> 417 418<h2 id="password-protection">Password Protection</h2> 419<p>Android can be configured to verify a user-supplied password prior to providing 420access to a device. In addition to preventing unauthorized use of the device, 421this password protects the cryptographic key for full filesystem encryption.</p> 422<p>Use of a password and/or password complexity rules can be required by a device 423administrator.</p> 424 425<h2 id="device-administration">Device Administration</h2> 426<p>Android 2.2 and later provide the Android Device Administration API, which 427provides device administration features at the system level. For example, the 428built-in Android Email application uses the APIs to improve Exchange support. 429Through the Email application, Exchange administrators can enforce password 430policies — including alphanumeric passwords or numeric PINs — across 431devices. Administrators can also remotely wipe (that is, restore factory 432defaults on) lost or stolen handsets.</p> 433<p>In addition to use in applications included with the Android system, these APIs 434are available to third-party providers of Device Management solutions. Details 435on the API are provided here: 436<a href="https://devel 437oper.android.com/guide/topics/admin/device-admin.html">https://developer.android.com/guide/topics/admin/device-admin.html</a>.</p> 438 439<h1 id="android-application-security">Android Application Security</h1> 440<h2 id="elements-of-applications">Elements of Applications</h2> 441<p>Android provides an open source platform and application environment for mobile 442devices. The core operating system is based on the Linux kernel. Android 443applications are most often written in the Java programming language and run in 444the Dalvik virtual machine. However, applications can also be written in native 445code. Applications are installed from a single file with the .apk file 446extension.</p> 447<p>The main Android application building blocks are:</p> 448<ul> 449<li> 450<p><strong>AndroidManifest.xml</strong>: The 451<a href="https://developer.android.com/guide/topics/manifest/manifes 452t-intro.html">AndroidManifest.xml</a> file is the control file that tells the system what to do with 453all the top-level components (specifically activities, services, broadcast 454receivers, and content providers described below) in an application. This also 455specifies which permissions are required.</p> 456</li> 457<li> 458<p><strong>Activities</strong>: An 459<a href="https://developer.android.com/guide/topics/fundamentals/activities.htm 460l">Activity</a> is, generally, the code for a single, user-focused task. It usually 461includes displaying a UI to the user, but it does not have to -- some 462Activities never display UIs. Typically, one of the application's Activities 463is the entry point to an application.</p> 464</li> 465<li> 466<p><strong>Services</strong>: A 467<a href="https://developer.android.com/guide/topics/fundamentals/services.html">Service</a> 468is a body of code that runs in the background. It can run in its own process, 469or in the context of another application's process. Other components "bind" to 470a Service and invoke methods on it via remote procedure calls. An example of a 471Service is a media player: even when the user quits the media-selection UI, the 472user probably still intends for music to keep playing. A Service keeps the 473music going even when the UI has completed.</p> 474</li> 475<li> 476<p><strong>Broadcast Receiver</strong>: A 477<a href="https://developer.android.com/reference/android/content/Broad 478castReceiver.html">BroadcastReceiver</a> is an object that is instantiated when an IPC mechanism 479known as an 480<a href="https://developer.android.com/reference/android/content/Intent.html">Intent</a> 481is issued by the operating system or another application. An application may 482register a receiver for the low battery message, for example, and change its 483behavior based on that information.</p> 484</li> 485</ul> 486 487<h2 id="the-android-permission-model-accessing-protected-apis">The Android Permission Model: Accessing Protected APIs</h2> 488<p>All applications on Android run in an Application Sandbox, described earlier in this document. 489By default, an Android application can only access a limited range of system 490resources. The system manages Android application access to resources that, if 491used incorrectly or maliciously, could adversely impact the user experience, 492the network, or data on the device.</p> 493<p>These restrictions are implemented in a variety of different forms. Some 494capabilities are restricted by an intentional lack of APIs to the sensitive 495functionality (e.g. there is no Android API for directly manipulating the SIM 496card). In some instances, separation of roles provides a security measure, as 497with the per-application isolation of storage. In other instances, the 498sensitive APIs are intended for use by trusted applications and protected 499through a security mechanism known as Permissions.</p> 500<p>These protected APIs include:</p> 501<ul> 502<li>Camera functions</li> 503<li>Location data (GPS)</li> 504<li>Bluetooth functions</li> 505<li>Telephony functions</li> 506<li>SMS/MMS functions</li> 507<li>Network/data connections</li> 508</ul> 509<p>These resources are only accessible through the operating system. To make use 510of the protected APIs on the device, an application must define the 511capabilities it needs in its manifest. When preparing to install an 512application, the system displays a dialog to the user that indicates the 513permissions requested and asks whether to continue the installation. If the 514user continues with the installation, the system accepts that the user has 515granted all of the requested permissions. The user can not grant or deny 516individual permissions -- the user must grant or deny all of the requested 517permissions as a block.</p> 518<p>Once granted, the permissions are applied to the application as long as it is 519installed. To avoid user confusion, the system does not notify the user again 520of the permissions granted to the application, and applications that are 521included in the core operating system or bundled by an OEM do not request 522permissions from the user. Permissions are removed if an application is 523uninstalled, so a subsequent re-installation will again result in display of 524permissions.</p> 525<p>Within the device settings, users are able to view permissions for applications 526they have previously installed. Users can also turn off some functionality 527globally when they choose, such as disabling GPS, radio, or wi-fi.</p> 528<p>In the event that an application attempts to use a protected feature which has 529not been declared in the application's manifest, the permission failure will 530typically result in a security exception being thrown back to the application. 531Protected API permission checks are enforced at the lowest possible level to 532prevent circumvention. An example of the user messaging when an application is 533installed while requesting access to protected APIs is shown in <em>Figure 2</em>.</p> 534<p>The system default permissions are described at 535<a href="https://developer.android.com/reference/android/Manifest.permission.html">https://developer.android.com/reference/android/Manifest.permission.html</a>. 536Applications may declare their own permissions for other applications to use. 537Such permissions are not listed in the above location.</p> 538<p>When defining a permission a protectionLevel attribute tells the system how the 539user is to be informed of applications requiring the permission, or who is 540allowed to hold a permission. Details on creating and using application 541specific permissions are described at 542<a href="https://develo 543per.android.com/guide/topics/security/security.html">https://developer.android.com/guide/topics/security/security.html</a>.</p> 544<p>There are some device capabilities, such as the ability to send SMS broadcast 545intents, that are not available to third-party applications, but that may be 546used by applications pre-installed by the OEM. These permissions use the 547signatureOrSystem permission.</p> 548<h2 id="how-users-understand-third-party-applications">How Users Understand Third-Party Applications</h2> 549<p>Android strives to make it clear to users when they are interacting with 550third-party applications and inform the user of the capabilities those 551applications have. Prior to installation of any application, the user is shown 552a clear message about the different permissions the application is requesting. 553After install, the user is not prompted again to confirm any permissions.</p> 554<p>There are many reasons to show permissions immediately prior to installation 555time. This is when user is actively reviewing information about the 556application, developer, and functionality to determine whether it matches their 557needs and expectations. It is also important that they have not yet 558established a mental or financial commitment to the app, and can easily compare 559the application to other alternative applications.</p> 560<p>Some other platforms use a different approach to user notification, requesting 561permission at the start of each session or while applications are in use. The 562vision of Android is to have users switching seamlessly between applications at 563will. Providing confirmations each time would slow down the user and prevent 564Android from delivering a great user experience. Having the user review 565permissions at install time gives the user the option to not install the 566application if they feel uncomfortable.</p> 567<p>Also, many user interface studies have shown that over-prompting the user 568causes the user to start saying "OK" to any dialog that is shown. One of 569Android's security goals is to effectively convey important security 570information to the user, which cannot be done using dialogs that the user will 571be trained to ignore. By presenting the important information once, and only 572when it is important, the user is more likely to think about what they are 573agreeing to.</p> 574<p>Some platforms choose not to show any information at all about application 575functionality. That approach prevents users from easily understanding and 576discussing application capabilities. While it is not possible for all users to 577always make fully informed decisions, the Android permissions model makes 578information about applications easily accessible to a wide range of users. For 579example, unexpected permissions requests can prompt more sophisticated users to 580ask critical questions about application functionality and share their concerns 581in places such as <a href="htts://play.google.com">Google Play</a> where they 582are visible to all users.</p> 583<table> 584<tr> 585<td><strong>Permissions at Application Install -- Google Maps</strong></td> 586<td><strong>Permissions of an Installed Application -- gMail</strong></td> 587</tr> 588<tr> 589<td> 590<img alt="Permissions at Application Install -- Google Maps" width=250 591src="images/image_install.png"/> 592</td> 593<td> 594<img alt="Permissions of an Installed Application -- gMail" width=250 595src="images/image_gmail_installed.png"/> 596</td> 597</tr> 598</table> 599 600<p><em>Figure 2: Display of permissions for applications</em></p> 601<h2 id="interprocess-communication">Interprocess Communication</h2> 602<p>Processes can communicate using any of the traditional UNIX-type mechanisms. 603Examples include the filesystem, local sockets, or signals. However, the Linux 604permissions still apply.</p> 605<p>Android also provides new IPC mechanisms:</p> 606<ul> 607<li> 608<p><strong>Binder</strong>: A lightweight capability-based remote procedure call mechanism 609designed for high performance when performing in-process and cross-process 610calls. Binder is implemented using a custom Linux driver. See 611<a href="https://developer 612.android.com/reference/android/os/Binder.html">https://developer.android.com/reference/android/os/Binder.html</a>.</p> 613</li> 614<li> 615<p><strong>Services</strong>: Services (discussed above) can provide interfaces directly 616accessible using binder.</p> 617</li> 618<li> 619<p><strong>Intents</strong>: An Intent is a simple message object that represents an 620"intention" to do something. For example, if your application wants to display 621a web page, it expresses its "Intent" to view the URL by creating an Intent 622instance and handing it off to the system. The system locates some other piece 623of code (in this case, the Browser) that knows how to handle that Intent, and 624runs it. Intents can also be used to broadcast interesting events (such as a 625notification) system-wide. See 626[https://developer.android.com/reference/android/content/Intent.html](https://developer.android.com/reference/android/content/Intent.html.</p> 627</li> 628<li> 629<p><strong>ContentProviders</strong>: A ContentProvider is a data storehouse that provides 630access to data on the device; the classic example is the ContentProvider that 631is used to access the user's list of contacts. An application can access data 632that other applications have exposed via a ContentProvider, and an application 633can also define its own ContentProviders to expose data of its own. See 634<a href="https://developer.android.com/reference/android/content/ContentProvider.html">https://developer.android.com/reference/android/content/ContentProvider.html</a>.</p> 635</li> 636</ul> 637<p>While it is possible to implement IPC using other mechanisms such as network 638sockets or world-writable files, these are the recommended Android IPC 639frameworks. Android developers will be encouraged to use best practices around 640securing users' data and avoiding the introduction of security vulnerabilities.</p> 641<h2 id="cost-sensitive-apis">Cost-Sensitive APIs</h2> 642<p>A cost sensitive API is any function that might generate a cost for the user or 643the network. The Android platform has placed cost sensitive APIs in the list of 644protected APIs controlled by the OS. The user will have to grant explicit 645permission to third-party applications requesting use of cost sensitive APIs. 646These APIs include:</p> 647<ul> 648<li>Telephony</li> 649<li>SMS/MMS</li> 650<li>Network/Data</li> 651<li>In-App Billing</li> 652<li>NFC Access</li> 653</ul> 654 655<p> Android 4.2 adds further control on the use of SMS. Android will provide a 656notification if an application attempts to send SMS to a short code that uses 657premium services which might cause additional charges. The user can choose 658whether to allow the application to send the message or block it. 659</p> 660 661<h2 id="sim-card-access">SIM Card Access</h2> 662<p>Low level access to the SIM card is not available to third-party apps. The OS 663handles all communications with the SIM card including access to personal 664information (contacts) on the SIM card memory. Applications also cannot access 665AT commands, as these are managed exclusively by the Radio Interface Layer 666(RIL). The RIL provides no high level APIs for these commands.</p> 667<h2 id="personal-information">Personal Information</h2> 668<p>Android has placed APIs that provide access to user data into the set of 669protected APIs. With normal usage, Android devices will also accumulate user 670data within third-party applications installed by users. Applications that 671choose to share this information can use Android OS permission checks to 672protect the data from third-party applications.</p> 673<p><img alt="Figure 3: Access to sensitive user data is only available through protected 674APIs" src="images/image03.png" /></p> 675<p><em>Figure 3: Access to sensitive user data is only available through protected 676APIs</em></p> 677<p>System content providers that are likely to contain personal or personally 678identifiable information such as contacts and calendar have been created with 679clearly identified permissions. This granularity provides the user with clear 680indication of the types of information that may be provided to the application. 681 During installation, a third-party application may request permission to 682access these resources. If permission is granted, the application can be 683installed and will have access to the data requested at any time when it is 684installed.</p> 685<p>Any applications which collect personal information will, by default, have that 686data restricted only to the specific application. If an application chooses to 687make the data available to other applications though IPC, the application 688granting access can apply permissions to the IPC mechanism that are enforced by 689the operating system.</p> 690<h2 id="sensitive-data-input-devices">Sensitive Data Input Devices</h2> 691<p>Android devices frequently provide sensitive data input devices that allow 692applications to interact with the surrounding environment, such as camera, 693microphone or GPS. For a third-party application to access these devices, it 694must first be explicitly provided access by the user through the use of Android 695OS Permissions. Upon installation, the installer will prompt the user 696requesting permission to the sensor by name.</p> 697<p>If an application wants to know the user's location, the application requires a 698permission to access the user's location. Upon installation, the installer will 699prompt the user asking if the application can access the user's location. At 700any time, if the user does not want any application to access their location, 701then the user can run the "Settings" application, go to "Location & Security", 702and uncheck the "Use wireless networks" and "Enable GPS satellites". This will 703disable location based services for all applications on the user's device.</p> 704<h2 id="device-metadata">Device Metadata</h2> 705<p>Android also strives to restrict access to data that is not intrinsically 706sensitive, but may indirectly reveal characteristics about the user, user 707preferences, and the manner in which they use a device.</p> 708<p>By default applications do not have access to operating system logs, 709browser history, phone number, or hardware / network identification 710information. If an application requests access to this information at install 711time, the installer will prompt the user asking if the application can access 712the information. If the user does not grant access, the application will not be 713installed.</p> 714<h2 id="application-signing">Application Signing</h2> 715<p>Code signing allows developers to identify the author of the application and to 716update their application without creating complicated interfaces and 717permissions. Every application that is run on the Android platform must be 718signed by the developer. Applications that attempt to install without being 719signed will rejected by either Google Play or the package installer on 720the Android device.</p> 721<p>On Google Play, application signing bridges the trust Google has with the 722developer and the trust the developer has with their application. Developers 723know their application is provided, unmodified to the Android device; and 724developers can be held accountable for behavior of their application.</p> 725<p>On Android, application signing is the first step to placing an application in 726its Application Sandbox. The signed application certificate defines which user 727id is associated with which application; different applications run under 728different user IDs. Application signing ensures that one application cannot 729access any other application except through well-defined IPC.</p> 730<p>When an application (APK file) is installed onto an Android device, the Package 731Manager verifies that the APK has been properly signed with the certificate 732included in that APK. If the certificate (or, more accurately, the public key 733in the certificate) matches the key used to sign any other APK on the device, 734the new APK has the option to specify in the manifest that it will share a UID 735with the other similarly-signed APKs.</p> 736<p>Applications can be signed by a third-party (OEM, operator, alternative market) 737or self-signed. Android provides code signing using self-signed certificates 738that developers can generate without external assistance or permission. 739Applications do not have to be signed by a central authority. Android currently 740does not perform CA verification for application certificates.</p> 741<p>Applications are also able to declare security permissions at the Signature 742protection level, restricting access only to applications signed with the same 743key while maintaining distinct UIDs and Application Sandboxes. A closer 744relationship with a shared Application Sandbox is allowed via the 745<a href="https://developer.android.com/guide/topics/manifest/manifest-element.html#uid">shared UID 746feature</a> where two or more applications signed with same developer key can 747declare a shared UID in their manifest.</p> 748 749<h2 id="app-verification">Application Verification</h2> 750<p> 751Android 4.2 and later support application verification. Users can choose to 752enable “Verify Apps" and have applications evaluated by an application verifier 753prior to installation. App verification can alert the user if they try to 754install an app that might be harmful; if an application is especially bad, it 755can block installation. 756</p> 757 758<h2 id="digital-rights-management">Digital Rights Management</h2> 759<p>The Android platform provides an extensible DRM framework that lets 760applications manage rights-protected content according to the license 761constraints that are associated with the content. The DRM framework supports 762many DRM schemes; which DRM schemes a device supports is left to the device 763manufacturer.</p> 764<p>The <a href="https://developer.android.com/reference/android/drm/package-summary.html">Android DRM 765framework</a> 766is implemented in two architectural layers (see figure below):</p> 767<ul> 768<li> 769<p>A DRM framework API, which is exposed to applications through the Android 770application framework and runs through the Dalvik VM for standard applications.</p> 771</li> 772<li> 773<p>A native code DRM manager, which implements the DRM framework and exposes an 774interface for DRM plug-ins (agents) to handle rights management and decryption 775for various DRM schemes</p> 776</li> 777</ul> 778<p><img alt="Figure 4: Architecture of Digital Rights Management on Android 779platform" src="images/image02.png" /></p> 780<p><em>Figure 4: Architecture of Digital Rights Management on Android platform</em></p> 781<h1 id="android-updates">Android Updates</h1> 782<p>Android provides system updates for both security and feature related purposes.</p> 783<p>There are two ways to update the code on most Android devices: over-the-air 784(OTA updates) or side-loaded updates. OTA updates can be rolled out over a 785defined time period or be pushed to all devices at once, depending on how the 786OEM and/or carrier would like to push the updates. Side-loaded updates can be 787provided from a central location for users to download as a zip file to their 788local desktop machine or directly to their handset. Once the update is copied 789or downloaded to the SD card on the device, Android will recognize the update, 790verify its integrity and authenticity, and automatically update the device.</p> 791<p>If a dangerous vulnerability is discovered internally or responsibly reported 792to Google or the Android Open Source Project, the Android security team will 793start the following process.</p> 794<ol> 795<li>The Android team will notify companies who have signed NDAs regarding the 796problem and begin discussing the solution.</li> 797<li>The owners of code will begin the fix.</li> 798<li>The Android team will fix Android-related security issues.</li> 799<li>When a patch is available, the fix is provided to the NDA companies.</li> 800<li>The Android team will publish the patch in the Android Open Source Project</li> 801<li>OEM/carrier will push an update to customers.</li> 802</ol> 803<p>The NDA is required to ensure that the security issue does not become public 804prior to availabilty of a fix and put users at risk. Many OHA members run their 805own code on Android devices such as the bootloader, wifi drivers, and the 806radio. Once the Android Security team is notified of a security issue in this 807partner code, they will consult with OHA partners to quickly find a fix for the 808problem at hand and similar problems. However, the OHA member who wrote the 809faulty code is ultimately responsible for fixing the problem.</p> 810<p>If a dangerous vulnerability is not responsibly disclosed (e.g., if it is 811posted to a public forum without warning), then Google and/or the Android Open 812Source Project will work as quickly as possible to create a patch. The patch 813will released to the public (and any partners) when the patch is tested and 814ready for use.</p> 815<p>At Google I/O 2011, many of the largest OHA partners committed to providing 816updates to devices for 18 months after initial shipment. This will provide 817users with access to the most recent Android features, as well as security 818updates.</p> 819<p>Any developer, Android user, or security researcher can notify the Android 820security team of potential security issues by sending email to 821security@android.com. If desired, communication can be encrypted using the 822Android security team PGP key available here: 823<a href="https://developer.android.com/security_at_android_dot_com.txt">https://developer.android.com/security_at_android_dot_com.txt</a>.</p> 824<h1 id="other-resources">Other Resources</h1> 825<p>Information about the Android Open Source Project is available at 826<a href="https://source.android.com">https://source.android.com</a>.</p> 827<p>Information for Android application developers is here: 828<a href="https://developer.android.com">https://developer.android.com</a>.</p> 829<p>The Android Security team can be reached at 830<a href="mailto:security@android.com">security@android.com</a>.</p> 831<p>Security information exists throughout the Android Open Source and Developer 832Sites. A good place to start is here: 833<a href="https://developer.android.com/guide/topics/security/security.html">https://developer.android.com/guide/topics/security/security.html</a>.</p> 834<p>A Security FAQ for developers is located here: 835<a href="https://developer.android.com/resources/faq/security.html">https://developer.android.com/resources/faq/security.html</a>.</p> 836<p>Security Best Practices for developers is located here: 837<a href="https://developer.android.com/guide/practices/security.html">https://developer.android.com/guide/practices/security.html</a>.</p> 838<p>A community resource for discussion about Android security exists here: 839<a href="https://groups.google.com/forum/?fromgroups#!forum/android-security-discuss">https://groups.google.com/forum/?fromgroups#!forum/android-security-discuss</a>.</p> 840