blob: 5a795986dbb6ab4d1e99f7dc5ce428e851c4ddd5 [file] [log] [blame]
Robert Ly35f2fda2013-01-29 16:27:05 -08001page.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-->
Robert Ly9ca43692013-04-16 13:10:20 -070019
Robert Ly35f2fda2013-01-29 16:27:05 -080020<h2 id="introduction">Introduction</h2>
21<p>Android is a modern mobile platform that was designed to be truly open. Android
22applications make use of advanced hardware and software, as well as local and
23served data, exposed through the platform to bring innovation and value to
24consumers. To protect that value, the platform must offer an application
25environment that ensures the security of users, data, applications, the device,
26and the network.</p>
Robert Ly9ca43692013-04-16 13:10:20 -070027
Robert Ly35f2fda2013-01-29 16:27:05 -080028<p>Securing an open platform requires a robust security architecture and rigorous
29security programs. Android was designed with multi-layered security that
30provides the flexibility required for an open platform, while providing
31protection for all users of the platform.</p>
Robert Ly9ca43692013-04-16 13:10:20 -070032
Robert Ly35f2fda2013-01-29 16:27:05 -080033<p>Android was designed with developers in mind. Security controls were designed
34to reduce the burden on developers. Security-savvy developers can easily work
35with and rely on flexible security controls. Developers less familiar with
36security will be protected by safe defaults.</p>
Robert Ly9ca43692013-04-16 13:10:20 -070037
Robert Ly35f2fda2013-01-29 16:27:05 -080038<p>Android was designed with device users in mind. Users are provided visibility
39into how applications work, and control over those applications. This design
40includes the expectation that attackers would attempt to perform common
41attacks, such as social engineering attacks to convince device users to install
42malware, and attacks on third-party applications on Android. Android was
43designed to both reduce the probability of these attacks and greatly limit the
44impact of the attack in the event it was successful.</p>
Robert Ly9ca43692013-04-16 13:10:20 -070045
Robert Ly35f2fda2013-01-29 16:27:05 -080046<p>This document outlines the goals of the Android security program, describes the
47fundamentals of the Android security architecture, and answers the most
48pertinent questions for system architects and security analysts. This document
49focuses on the security features of Android's core platform and does not
50discuss security issues that are unique to specific applications, such as those
51related to the browser or SMS application. Recommended best practices for
52building Android devices, deploying Android devices, or developing applications
53for Android are not the goal of this document and are provided elsewhere.</p>
Robert Ly9ca43692013-04-16 13:10:20 -070054
Robert Ly35f2fda2013-01-29 16:27:05 -080055<h1 id="background">Background</h1>
56<p>Android provides an open source platform and application environment for mobile
57devices.</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
62including smart phones, tablets, and set-top-boxes. Android is
63processor-agnostic, but it does take advantage of some hardware-specific
64security 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
68the Linux kernel. All device resources, like camera functions, GPS data,
69Bluetooth functions, telephony functions, network connections, etc. are
70accessed through the operating system.</p>
71</li>
72<li>
73<p><strong>Android Application Runtime</strong>: Android applications are most often written
74in the Java programming language and run in the Dalvik virtual machine.
75However, many applications, including core Android services and applications
76are native applications or include native libraries. Both Dalvik and native
77applications run within the same security environment, contained within the
78Application Sandbox. Applications get a dedicated part of the filesystem in
79which 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
83primary sources for applications:</p>
84<ul>
85<li>
86<p><strong>Pre-Installed Applications</strong>: Android includes a set of pre-installed
87applications including phone, email, calendar, web browser, and contacts. These
88function both as user applications and to provide key device capabilities that
89can be accessed by other applications. Pre-installed applications may be part
90of the open source Android platform, or they may be developed by an OEM for a
91specific device.</p>
92</li>
93<li>
94<p><strong>User-Installed Applications</strong>: Android provides an open development
95environment supporting any third-party application. Google Play offers
96users 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
100compatible 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
104allow users to discover, install, and purchase applications from their Android
105device or the web. Google Play makes it easy for developers to reach Android
106users and potential customers. Google Play also provides community review,
107application <a href="https://developer.android.com/guide/publishing/licensing.html">license
Robert Ly9ca43692013-04-16 13:10:20 -0700108verification</a>, application security scanning, and other security services.</p>
Robert Ly35f2fda2013-01-29 16:27:05 -0800109</li>
110<li>
111<p><strong>Android Updates</strong>: The Android update service delivers new capabilities and
112security updates to Android devices, including updates through the web or over
113the air (OTA).</p>
114</li>
115<li>
116<p><strong>Application Services</strong>: Frameworks that allow Android applications to use
117cloud capabilities such as (<a href="https://developer.android.com/guide/topics/data/backup.html">backing
118up</a>) application
119data and settings and cloud-to-device messaging
120(<a href="https://code.google.com/android/c2dm/index.html">C2DM</a>)
121for push messaging.</p>
122</li>
123</ul>
124<p>These services are not part of the Android Open Source Project and are out
125of scope for this document. But they are relevant to the security of most
126Android devices, so a related security document titled “Google Services for
127Android: 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
130robust security model was required to enable a vigorous ecosystem of
131applications and devices built on and around the Android platform and supported
132by cloud services. As a result, through its entire development lifecycle,
133Android has been subjected to a professional security program. The Android team
134has had the opportunity to observe how other mobile, desktop, and server platforms
135prevented and reacted to security issues and built a security
136program 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
140development lifecycle with the creation of a rich and configurable security
141model and design. Each major feature of the platform is reviewed by engineering
142and security resources, with appropriate security controls integrated into the
143architecture of the system.</li>
144<li><strong>Penetration Testing and Code Review</strong>: During the development of the
145platform, Android-created and open-source components are subject to vigorous
146security reviews. These reviews are performed by the Android Security Team,
147Google’s Information Security Engineering team, and independent security
148consultants. The goal of these reviews is to identify weaknesses and possible
149vulnerabilities well before the platform is open-sourced, and to simulate the
150types of analysis that will be performed by external security experts upon
151release.</li>
152<li><strong>Open Source and Community Review</strong>: The Android Open Source Project enables
153broad security review by any interested party. Android also uses open source
154technologies that have undergone significant external security review,
155such as the Linux kernel. Google Play provides a forum for users and companies
156to provide information about specific applications directly to users.</li>
157<li><strong>Incident Response</strong>: Even with all of these precautions, security issues
158may occur after shipping, which is why the Android project has created a
159comprehensive security response process. A full-time Android security team
160constantly monitors Android-specific and the general security community for
161discussion of potential vulnerabilities. Upon the discovery of legitimate
162issues, the Android team has a response process that enables the rapid
163mitigation of vulnerabilities to ensure that potential risk to all Android
164users is minimized. These cloud-supported responses can include updating the
165Android platform (over-the-air updates), removing applications from Google
166Play, 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
170platforms 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
185platform. <em>Figure 1</em> summarizes the security components and considerations of
186the various levels of the Android software stack. Each component assumes that
187the components below are properly secured. With the exception of a small amount
188of Android OS code running as root, all code above the Linux Kernel is
189restricted 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
194the Linux kernel, as well as a secure inter-process communication (IPC)
195facility to enable secure communication between applications running in
196different processes. These security features at the OS level ensure that even
197native code is constrained by the Application Sandbox. Whether that code is
198the result of included application behavior or a exploitation of an application
199vulnerability, the system would prevent the rogue application from harming
200other 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
203itself has been in widespread use for years, and is used in millions of
204security-sensitive environments. Through its history of constantly being
205researched, attacked, and fixed by thousands of developers, Linux has become a
206stable and secure kernel trusted by many corporations and security
207professionals.</p>
208<p>As the base for a mobile computing environment, the Linux kernel provides
209Android 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
217kernel is to isolate user resources from one another. The Linux security
218philosophy 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,
224bluetooth)</li>
225</ul>
Robert Ly9ca43692013-04-16 13:10:20 -0700226
Robert Ly35f2fda2013-01-29 16:27:05 -0800227<h2 id="the-application-sandbox">The Application Sandbox</h2>
228<p>The Android platform takes advantage of the Linux user-based protection as a
229means of identifying and isolating application resources. The Android system
230assigns a unique user ID (UID) to each Android application and runs it as that user
231in a separate process. This approach is different from other operating systems
232(including the traditional Linux configuration), where multiple applications
233run with the same user permissions.</p>
234<p>This sets up a kernel-level Application Sandbox. The kernel enforces security
235between applications and the system at the process level through standard Linux
236facilities, such as user and group IDs that are assigned to applications. By
237default, applications cannot interact with each other and applications have
238limited access to the operating system. If application A tries to do something
239malicious like read application B's data or dial the phone without permission
240(which is a separate application), then the operating system protects against
241this because application A does not have the appropriate user privileges. The
242sandbox is simple, auditable, and based on decades-old UNIX-style user
243separation of processes and file permissions.</p>
244<p>Since the Application Sandbox is in the kernel, this security model extends to
245native code and to operating system applications. All of the software above the
246kernel in <em>Figure 1</em>, including operating system libraries, application
247framework, application runtime, and all applications run within the Application
248Sandbox. On some platforms, developers are constrained to a specific
249development framework, set of APIs, or language in order to enforce security.
250On Android, there are no restrictions on how an application can be written that
251are required to enforce security; in this respect, native code is just as
252secure as interpreted code.</p>
253<p>In some operating systems, memory corruption errors generally lead to
254completely compromising the security of the device. This is not the case in
255Android due to all applications and their resources being sandboxed at the OS
256level. A memory corruption error will only allow arbitrary code execution in
257the context of that particular application, with the permissions established by
258the operating system.</p>
259<p>Like all security features, the Application Sandbox is not unbreakable.
260However, to break out of the Application Sandbox in a properly configured
261device, 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
264libraries, application runtime, application framework, and applications. This
265partition is set to read-only. When a user boots the device into Safe Mode,
266only core Android applications are available. This ensures that the user can
267boot their phone into an environment that is free of third-party software.</p>
Robert Ly9ca43692013-04-16 13:10:20 -0700268
Robert Ly35f2fda2013-01-29 16:27:05 -0800269<h2 id="filesystem-permissions">Filesystem Permissions</h2>
270<p>In a UNIX-style environment, filesystem permissions ensure that one user cannot
271alter or read another user's files. In the case of Android, each application
272runs as its own user. Unless the developer explicitly exposes files to other
273applications, files created by one application cannot be read or altered by
274another application.</p>
Robert Ly9ca43692013-04-16 13:10:20 -0700275
276
277<h2 id="crypto">Cryptography</h2>
278
279<p>
280Android provides a set of cryptographic APIs for use by applications. These
281include implementations of standard and commonly used cryptographic primitives
282such as AES, RSA, DSA, and SHA. Additionally, APIs are provided for higher level
283protocols such as SSL and HTTPS.
284</p>
285
286<p>
287Android 4.0 introduced the
288<a href="http://developer.android.com/reference/android/security/KeyChain.html">KeyChain</a>
289class to allow applications to use the system credential storage for private
290keys and certificate chains.
291</p>
292
293<h2>Memory Management Security Enhancements</h2>
294
295Android includes many features that make common security issues harder to
296exploit. The Android SDK, compilers, and OS use tools to make common memory
297corruption 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
305to prevent chunk consolidation attacks. Chunk consolidation attacks are a
306common 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
316escalation (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>
340By default, on Android only the kernel and a small subset of the core
341applications run with root permissions. Android does not prevent a user or
342application with root permissions from modifying the operating system, kernel,
343and any other application. In general, root has full access to all
344applications and all application data. Users that change the permissions on an
345Android device to grant root access to applications increase the security
346exposure to malicious applications and potential application flaws.
347</p>
348<p>
349The ability to modify an Android device they own is important to developers
350working with the Android platform. On many Android devices users have the
351ability to unlock the bootloader in order to allow installation of an alternate
352operating system. These alternate operating systems may allow an owner to gain
353root access for purposes of debugging applications and system components or to
354access features not presented to applications by Android APIs.
355</p>
356<p>
357On some devices, a person with physical control of a device and a USB cable is
358able to install a new operating system that provides root privileges to the
359user. To protect any existing user data from compromise the bootloader unlock
360mechanism requires that the bootloader erase any existing user data as part of
361the unlock step. Root access gained via exploiting a kernel bug or security
362hole can bypass this protection.
363</p>
364<p>
365Encrypting data with a key stored on-device does not protect the application
366data from root users. Applications can add a layer of data protection using
367encryption with a key stored off-device, such as on a server or a user
368password. This approach can provide temporary protection while the key is not
369present, but at some point the key must be provided to the application and it
370then becomes accessible to root users.
371</p>
372<p>
373A more robust approach to protecting data from root users is through the use of
374hardware solutions. OEMs may choose to implement hardware solutions that limit
375access to specific types of content such as DRM for video playback, or the
376NFC-related trusted storage for Google wallet.
377</p>
378<p>
379In the case of a lost or stolen device, full filesystem encryption on Android
380devices uses the device password to protect the encryption key, so modifying
381the bootloader or operating system is not sufficient to access user data
382without the user’s device password.
383</p>
384<h2>User Security Features</h2>
385
386<h3 id="filesystem-encryption">Filesystem Encryption</h3>
387
Robert Ly35f2fda2013-01-29 16:27:05 -0800388<p>Android 3.0 and later provides full filesystem encryption, so all user data can
389be encrypted in the kernel using the dmcrypt implementation of AES128 with CBC
Robert Ly9ca43692013-04-16 13:10:20 -0700390and ESSIV:SHA256. The encryption key is protected by AES128 using a key
Robert Ly35f2fda2013-01-29 16:27:05 -0800391derived from the user password, preventing unauthorized access to stored data
Robert Ly9ca43692013-04-16 13:10:20 -0700392without the user device password. To provide resistance against systematic
Robert Ly35f2fda2013-01-29 16:27:05 -0800393password guessing attacks (e.g. “rainbow tables” or brute force), the
394password is combined with a random salt and hashed repeatedly with SHA1 using
395the standard PBKDF2 algorithm prior to being used to decrypt the filesystem
396key. To provide resistance against dictionary password guessing attacks,
397Android provides password complexity rules that can be set by the device
398administrator and enforced by the operating system. Filesystem encryption
399requires 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
Robert Ly9ca43692013-04-16 13:10:20 -0700401<a href="/tech/encryption/android_crypto_implementation.html">https://source.android.com/tech/encryption/android_crypto_implementation.html</a></p>
402
Robert Ly35f2fda2013-01-29 16:27:05 -0800403<h2 id="password-protection">Password Protection</h2>
404<p>Android can be configured to verify a user-supplied password prior to providing
405access to a device. In addition to preventing unauthorized use of the device,
406this 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
408administrator.</p>
Robert Ly9ca43692013-04-16 13:10:20 -0700409
Robert Ly35f2fda2013-01-29 16:27:05 -0800410<h2 id="device-administration">Device Administration</h2>
411<p>Android 2.2 and later provide the Android Device Administration API, which
412provides device administration features at the system level. For example, the
413built-in Android Email application uses the APIs to improve Exchange support.
414Through the Email application, Exchange administrators can enforce password
415policies — including alphanumeric passwords or numeric PINs — across
416devices. Administrators can also remotely wipe (that is, restore factory
417defaults on) lost or stolen handsets.</p>
418<p>In addition to use in applications included with the Android system, these APIs
419are available to third-party providers of Device Management solutions. Details
420on the API are provided here:
421<a href="https://devel
422oper.android.com/guide/topics/admin/device-admin.html">https://developer.android.com/guide/topics/admin/device-admin.html</a>.</p>
Robert Ly9ca43692013-04-16 13:10:20 -0700423
Robert Ly35f2fda2013-01-29 16:27:05 -0800424<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
427devices. The core operating system is based on the Linux kernel. Android
428applications are most often written in the Java programming language and run in
429the Dalvik virtual machine. However, applications can also be written in native
430code. Applications are installed from a single file with the .apk file
431extension.</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
437t-intro.html">AndroidManifest.xml</a> file is the control file that tells the system what to do with
438all the top-level components (specifically activities, services, broadcast
439receivers, and content providers described below) in an application. This also
440specifies 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
445l">Activity</a> is, generally, the code for a single, user-focused task. It usually
446includes displaying a UI to the user, but it does not have to -- some
447Activities never display UIs. Typically, one of the application's Activities
448is 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>
453is a body of code that runs in the background. It can run in its own process,
454or in the context of another application's process. Other components "bind" to
455a Service and invoke methods on it via remote procedure calls. An example of a
456Service is a media player: even when the user quits the media-selection UI, the
457user probably still intends for music to keep playing. A Service keeps the
458music 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
463castReceiver.html">BroadcastReceiver</a> is an object that is instantiated when an IPC mechanism
464known as an
465<a href="https://developer.android.com/reference/android/content/Intent.html">Intent</a>
466is issued by the operating system or another application. An application may
467register a receiver for the low battery message, for example, and change its
468behavior based on that information.</p>
469</li>
470</ul>
Robert Ly9ca43692013-04-16 13:10:20 -0700471
Robert Ly35f2fda2013-01-29 16:27:05 -0800472<h2 id="the-android-permission-model-accessing-protected-apis">The Android Permission Model: Accessing Protected APIs</h2>
Robert Ly9ca43692013-04-16 13:10:20 -0700473<p>All applications on Android run in an Application Sandbox, described earlier in this document.
474By default, an Android application can only access a limited range of system
Robert Ly35f2fda2013-01-29 16:27:05 -0800475resources. The system manages Android application access to resources that, if
476used incorrectly or maliciously, could adversely impact the user experience,
477the network, or data on the device.</p>
478<p>These restrictions are implemented in a variety of different forms. Some
479capabilities are restricted by an intentional lack of APIs to the sensitive
480functionality (e.g. there is no Android API for directly manipulating the SIM
481card). In some instances, separation of roles provides a security measure, as
482with the per-application isolation of storage. In other instances, the
483sensitive APIs are intended for use by trusted applications and protected
484through 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
495of the protected APIs on the device, an application must define the
496capabilities it needs in its manifest. When preparing to install an
497application, the system displays a dialog to the user that indicates the
498permissions requested and asks whether to continue the installation. If the
499user continues with the installation, the system accepts that the user has
500granted all of the requested permissions. The user can not grant or deny
501individual permissions -- the user must grant or deny all of the requested
502permissions as a block.</p>
503<p>Once granted, the permissions are applied to the application as long as it is
504installed. To avoid user confusion, the system does not notify the user again
505of the permissions granted to the application, and applications that are
506included in the core operating system or bundled by an OEM do not request
507permissions from the user. Permissions are removed if an application is
508uninstalled, so a subsequent re-installation will again result in display of
509permissions.</p>
510<p>Within the device settings, users are able to view permissions for applications
511they have previously installed. Users can also turn off some functionality
512globally 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
514not been declared in the application's manifest, the permission failure will
515typically result in a security exception being thrown back to the application.
516Protected API permission checks are enforced at the lowest possible level to
517prevent circumvention. An example of the user messaging when an application is
518installed 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>.
521Applications may declare their own permissions for other applications to use.
522Such permissions are not listed in the above location.</p>
523<p>When defining a permission a protectionLevel attribute tells the system how the
524user is to be informed of applications requiring the permission, or who is
525allowed to hold a permission. Details on creating and using application
526specific permissions are described at
527<a href="https://develo
528per.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
530intents, that are not available to third-party applications, but that may be
531used by applications pre-installed by the OEM. These permissions use the
532signatureOrSystem 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
535third-party applications and inform the user of the capabilities those
536applications have. Prior to installation of any application, the user is shown
537a clear message about the different permissions the application is requesting.
538After 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
540time. This is when user is actively reviewing information about the
541application, developer, and functionality to determine whether it matches their
542needs and expectations. It is also important that they have not yet
543established a mental or financial commitment to the app, and can easily compare
544the application to other alternative applications.</p>
545<p>Some other platforms use a different approach to user notification, requesting
546permission at the start of each session or while applications are in use. The
547vision of Android is to have users switching seamlessly between applications at
548will. Providing confirmations each time would slow down the user and prevent
549Android from delivering a great user experience. Having the user review
550permissions at install time gives the user the option to not install the
551application if they feel uncomfortable.</p>
552<p>Also, many user interface studies have shown that over-prompting the user
553causes the user to start saying "OK" to any dialog that is shown. One of
554Android's security goals is to effectively convey important security
555information to the user, which cannot be done using dialogs that the user will
556be trained to ignore. By presenting the important information once, and only
557when it is important, the user is more likely to think about what they are
558agreeing to.</p>
559<p>Some platforms choose not to show any information at all about application
560functionality. That approach prevents users from easily understanding and
561discussing application capabilities. While it is not possible for all users to
562always make fully informed decisions, the Android permissions model makes
563information about applications easily accessible to a wide range of users. For
564example, unexpected permissions requests can prompt more sophisticated users to
565ask critical questions about application functionality and share their concerns
566in places such as <a href="htts://play.google.com">Google Play</a> where they
567are 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
576src="images/image_install.png"/>
577</td>
578<td>
579<img alt="Permissions of an Installed Application -- gMail" width=250
580src="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.
588Examples include the filesystem, local sockets, or signals. However, the Linux
589permissions 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
594designed for high performance when performing in-process and cross-process
595calls. 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
601accessible 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
606a web page, it expresses its "Intent" to view the URL by creating an Intent
607instance and handing it off to the system. The system locates some other piece
608of code (in this case, the Browser) that knows how to handle that Intent, and
609runs it. Intents can also be used to broadcast interesting events (such as a
610notification) 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
615access to data on the device; the classic example is the ContentProvider that
616is used to access the user's list of contacts. An application can access data
617that other applications have exposed via a ContentProvider, and an application
618can 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
623sockets or world-writable files, these are the recommended Android IPC
624frameworks. Android developers will be encouraged to use best practices around
625securing 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
628the network. The Android platform has placed cost sensitive APIs in the list of
629protected APIs controlled by the OS. The user will have to grant explicit
630permission to third-party applications requesting use of cost sensitive APIs.
631These 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>
Robert Ly9ca43692013-04-16 13:10:20 -0700639
640<p> Android 4.2 adds further control on the use of SMS. Android will provide a
641notification if an application attempts to send SMS to a short code that uses
642premium services which might cause additional charges. The user can choose
643whether to allow the application to send the message or block it.
644</p>
645
Robert Ly35f2fda2013-01-29 16:27:05 -0800646<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
648handles all communications with the SIM card including access to personal
649information (contacts) on the SIM card memory. Applications also cannot access
650AT 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
654protected APIs. With normal usage, Android devices will also accumulate user
655data within third-party applications installed by users. Applications that
656choose to share this information can use Android OS permission checks to
657protect the data from third-party applications.</p>
658<p><img alt="Figure 3: Access to sensitive user data is only available through protected
659APIs" src="images/image03.png" /></p>
660<p><em>Figure 3: Access to sensitive user data is only available through protected
661APIs</em></p>
662<p>System content providers that are likely to contain personal or personally
663identifiable information such as contacts and calendar have been created with
664clearly identified permissions. This granularity provides the user with clear
665indication of the types of information that may be provided to the application.
666 During installation, a third-party application may request permission to
667access these resources. If permission is granted, the application can be
668installed and will have access to the data requested at any time when it is
669installed.</p>
670<p>Any applications which collect personal information will, by default, have that
671data restricted only to the specific application. If an application chooses to
672make the data available to other applications though IPC, the application
673granting access can apply permissions to the IPC mechanism that are enforced by
674the 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
677applications to interact with the surrounding environment, such as camera,
678microphone or GPS. For a third-party application to access these devices, it
679must first be explicitly provided access by the user through the use of Android
680OS Permissions. Upon installation, the installer will prompt the user
681requesting permission to the sensor by name.</p>
682<p>If an application wants to know the user's location, the application requires a
683permission to access the user's location. Upon installation, the installer will
684prompt the user asking if the application can access the user's location. At
685any time, if the user does not want any application to access their location,
686then the user can run the "Settings" application, go to "Location &amp; Security",
687and uncheck the "Use wireless networks" and "Enable GPS satellites". This will
688disable 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
691sensitive, but may indirectly reveal characteristics about the user, user
692preferences, and the manner in which they use a device.</p>
693<p>By default applications do not have access to operating system logs,
694browser history, phone number, or hardware / network identification
695information. If an application requests access to this information at install
696time, the installer will prompt the user asking if the application can access
697the information. If the user does not grant access, the application will not be
698installed.</p>
699<h2 id="application-signing">Application Signing</h2>
700<p>Code signing allows developers to identify the author of the application and to
701update their application without creating complicated interfaces and
702permissions. Every application that is run on the Android platform must be
703signed by the developer. Applications that attempt to install without being
704signed will rejected by either Google Play or the package installer on
705the Android device.</p>
706<p>On Google Play, application signing bridges the trust Google has with the
707developer and the trust the developer has with their application. Developers
708know their application is provided, unmodified to the Android device; and
709developers 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
711its Application Sandbox. The signed application certificate defines which user
712id is associated with which application; different applications run under
713different user IDs. Application signing ensures that one application cannot
714access any other application except through well-defined IPC.</p>
715<p>When an application (APK file) is installed onto an Android device, the Package
716Manager verifies that the APK has been properly signed with the certificate
717included in that APK. If the certificate (or, more accurately, the public key
718in the certificate) matches the key used to sign any other APK on the device,
719the new APK has the option to specify in the manifest that it will share a UID
720with the other similarly-signed APKs.</p>
721<p>Applications can be signed by a third-party (OEM, operator, alternative market)
722or self-signed. Android provides code signing using self-signed certificates
723that developers can generate without external assistance or permission.
724Applications do not have to be signed by a central authority. Android currently
725does not perform CA verification for application certificates.</p>
726<p>Applications are also able to declare security permissions at the Signature
727protection level, restricting access only to applications signed with the same
728key while maintaining distinct UIDs and Application Sandboxes. A closer
Robert Ly9ca43692013-04-16 13:10:20 -0700729relationship 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
731feature</a> where two or more applications signed with same developer key can
Robert Ly35f2fda2013-01-29 16:27:05 -0800732declare a shared UID in their manifest.</p>
Robert Ly9ca43692013-04-16 13:10:20 -0700733
734<h2 id="app-verification">Application Verification</h2>
735<p>
736Android 4.2 and later support application verification. Users can choose to
737enable “Verify Apps" and have applications evaluated by an application verifier
738prior to installation. App verification can alert the user if they try to
739install an app that might be harmful; if an application is especially bad, it
740can block installation.
741</p>
742
Robert Ly35f2fda2013-01-29 16:27:05 -0800743<h2 id="digital-rights-management">Digital Rights Management</h2>
744<p>The Android platform provides an extensible DRM framework that lets
745applications manage rights-protected content according to the license
746constraints that are associated with the content. The DRM framework supports
747many DRM schemes; which DRM schemes a device supports is left to the device
748manufacturer.</p>
749<p>The <a href="https://developer.android.com/reference/android/drm/package-summary.html">Android DRM
750framework</a>
751is 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
755application 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
759interface for DRM plug-ins (agents) to handle rights management and decryption
760for various DRM schemes</p>
761</li>
762</ul>
763<p><img alt="Figure 4: Architecture of Digital Rights Management on Android
764platform" 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
770defined time period or be pushed to all devices at once, depending on how the
771OEM and/or carrier would like to push the updates. Side-loaded updates can be
772provided from a central location for users to download as a zip file to their
773local desktop machine or directly to their handset. Once the update is copied
774or downloaded to the SD card on the device, Android will recognize the update,
775verify its integrity and authenticity, and automatically update the device.</p>
776<p>If a dangerous vulnerability is discovered internally or responsibly reported
777to Google or the Android Open Source Project, the Android security team will
778start the following process.</p>
779<ol>
780<li>The Android team will notify companies who have signed NDAs regarding the
781problem 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
789prior to availabilty of a fix and put users at risk. Many OHA members run their
790own code on Android devices such as the bootloader, wifi drivers, and the
791radio. Once the Android Security team is notified of a security issue in this
792partner code, they will consult with OHA partners to quickly find a fix for the
793problem at hand and similar problems. However, the OHA member who wrote the
794faulty code is ultimately responsible for fixing the problem.</p>
795<p>If a dangerous vulnerability is not responsibly disclosed (e.g., if it is
796posted to a public forum without warning), then Google and/or the Android Open
797Source Project will work as quickly as possible to create a patch. The patch
798will released to the public (and any partners) when the patch is tested and
799ready for use.</p>
800<p>At Google I/O 2011, many of the largest OHA partners committed to providing
801updates to devices for 18 months after initial shipment. This will provide
802users with access to the most recent Android features, as well as security
803updates.</p>
804<p>Any developer, Android user, or security researcher can notify the Android
805security team of potential security issues by sending email to
806security@android.com. If desired, communication can be encrypted using the
807Android 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@android.com">security@android.com</a>.</p>
816<p>Security information exists throughout the Android Open Source and Developer
817Sites. 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>