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