Understanding Android Security PDF
Understanding Android Security PDF
com
Focus
Understanding
Android Security
William Enck, Machigar steeply in 2009. Many other cell support applications developed for
Ongtang, and Patrick McDaniel phone providers have either prom- other platforms: applications ex-
Pennsylvania State University ised or plan to support it in the ecute on top of a Java middleware
near future. layer running on an embedded Li-
T
he next generation of open A large community of develop- nux kernel, so developers wishing
operating systems won’t be ers has organized around Android, to port their application to Android
on desktops or mainframes and many new products and appli- must use its custom user interface
but on the small mobile devices we cations are now available for it. One environment. Additionally, An-
carry every day. The openness of of Android’s chief selling points is droid restricts application interac-
these new environments will lead that it lets developers seamlessly tion to its special APIs by running
to new applications and markets extend online services to phones. each application as its own user
and will enable greater integra- The most visible example of this identity. Although this controlled
tion with existing online services. feature is—unsurprisingly— interaction has several beneficial
However, as the importance of the the tight integration of Google’s security features, our experiences
data and services our cell phones Gmail, Calendar, and Contacts developing Android applications
support increases, so too do the op- Web applications with system util- have revealed that designing secure
portunities for vulnerability. It’s es- ities. Android users simply supply a applications isn’t always straight-
sential that this next generation of username and password, and their forward. Android uses a simple
platforms provide a comprehensive phones automatically synchro- permission label assignment model
and usable security infrastructure. nize with Google services. Other to restrict access to resources and
Developed by the Open Hand- vendors are rapidly adapting their other applications, but for reasons
set Alliance (visibly led by Google), existing instant messaging, social of necessity and convenience, its
Android is a widely anticipated networks, and gaming services to designers have added several po-
open source operating system for Android, and many enterprises are tentially confusing refinements as
mobile devices that provides a base looking for ways to integrate their the system has evolved.
operating system, an application own internal operations (such as This article attempts to unmask
middleware layer, a Java software inventory management, purchas- the complexity of Android security
development kit (SDK), and a col- ing, receiving, and so forth) into it and note some possible development
lection of system applications. Al- as well. pitfalls that occur when defining an
though the Android SDK has been Traditional desktop and server application’s security. We conclude
available since late 2007, the first operating systems have struggled by attempting to draw some lessons
publicly available Android-ready to securely integrate such personal and identify opportunities for fu-
“G1” phone debuted in late Oc- and business applications and ser- ture enhancements that should aid
tober 2008. Since then, Android’s vices on a single platform; although in clarity and correctness.
growth has been phenomenal: T- doing so on a mobile platform such
Mobile’s G1 manufacturer HTC as Android remains nontrivial, Android Applications
estimates shipment volumes of many researchers hope it provides The Android application frame-
more than 1 million phones by the a clean slate devoid of the compli- work forces a structure on devel-
end of 2008, and industry insiders cations that legacy software can opers. It doesn’t have a main()
expect public adoption to increase cause. Android doesn’t officially function or single entry point for
10 Published by the IEEE Computer Society ■ 1540-7993/09/$25.00 © 2009 IEEE ■ IEEE Security & Privacy
Focus
Android applications
FriendTracker application FriendViewer application Contacts application
Figure 3. Protection. Security enforcement in Android occurs in two places: each application executes as its own user identity, allowing
the underlying Linux system to provide system-level isolation; and the Android middleware contains a reference monitor that mediates
the establishment of inter-component communication (ICC). Both mechanisms are vital to the phone’s security, but the first is
straightforward to implement, whereas the second requires careful consideration of both mechanism and policy.
Once bound, FriendTracker in- in that table. Components use this system, but would also have en-
vokes methods to register a call- URI to perform a SQL query on abled a network-based adversary
back that provides updates on the a content provider, optionally in- to exploit this flaw ([Link]
phone’s location. Note that if a ser- cluding WHERE conditions via the eva lu ator [Link] /content/ca se
vice is currently bound, an explicit query API. -studies/iphone/[Link]).
“stop” action won’t terminate the ICC isn’t limited by user and
service until all bound connec- Security Enforcement process boundaries. In fact, all
tions are released. As Figure 3 shows, Android pro- ICC occurs via an I/O control
Broadcast receiver and content tects applications and data through command on a special device
provider components have unique a combination of two enforcement node, /dev/binder. Because
forms of interaction. ICC targeted mechanisms, one at the system lev- the file must be world readable
at a broadcast receiver occurs as an el and the other at the ICC level. and writable for proper opera-
intent sent (broadcast) either ex- ICC mediation defines the core tion, the Linux system has no way
plicitly to the component or, more security framework and is this ar- of mediating ICC. Although user
commonly, to an action string ticle’s focus, but it builds on the separation is straightforward and
the component subscribes to. For guarantees provided by the under- easily understood, controlling ICC
example, FriendReceiver sub- lying Linux system. is much more subtle and warrants
scribes to the developer-defined In the general case, each ap- careful consideration.
“FRIEND_NEAR” action string. plication runs as a unique user As the central point of secu-
FriendTracker broadcasts an in- identity, which lets Android limit rity enforcement, the Android
tent to this action string when it the potential damage of program- middleware mediates all ICC es-
determines that the phone is near ming flaws. For example, the Web tablishment by reasoning about
a friend; the system then starts browser vulnerability discovered labels assigned to applications and
FriendReceiver and displays a recently after the official release components. A reference monitor1
message to the user. of T-Mobile G1 phones only af- provides mandatory access control
Content providers don’t use fected the Web browser (http:// (MAC) enforcement of how ap-
intents—rather, they’re ad- [Link]/content/ plications access components. In its
dressed via an authority string case-studies/android/[Link]). simplest form, access to each com-
embedded in a special content Because of this design choice, the ponent is restricted by assigning it
Uniform Resource Identifier exploit couldn’t affect other ap- an access permission label; this text
(URI) of the form content:// plications or the system. A similar string need not be unique. Devel-
<authority>/<table>/ vulnerability in Apple’s iPhone opers assign applications collections
[<id>]. Here, <table> indicates gave way to the first “jail break- of permission labels. When a com-
a table in the content provider, and ing” technique, which let users ponent initiates ICC, the reference
<id> optionally specifies a record replace parts of the underlying monitor looks at the permission
Application 1 Application 2
to determine if a component is pri-
Permission A: ... B: 1
Permission vate. Security-aware developers
labels labels
should always explicitly define the
... X ... exported attribute for compo-
1 C:
Inherit permissions 2
nents intended to be private.
Implicitly Open
Figure 4. Access permission logic. The Android middleware implements a reference monitor Components
providing mandatory access control (MAC) enforcement about how applications access Developers frequently define in-
components. The basic enforcement model is the same for all component types. Component tent filters on activities to indicate
A’s ability to access components B and C is determined by comparing the access permission that they can handle certain types
labels on B and C to the collection of labels assigned to application 1. of action/data combinations. Re-
call the example of how the system
finds an image viewer when an
labels assigned to its containing ap- incorporated several refinements intent specifying the VIEW action
plication and—if the target com- to the basic security model, some and an image reference is passed
ponent’s access permission label is of which have subtle side effects to the “start activity” API. In this
in that collection—allows ICC es- and make its overall security diffi- case, the caller can’t know before-
tablishment to proceed. If the label cult to understand. The rest of this hand (much less at development
isn’t in the collection, establishment section provides an exhaustive list time) what access permission is re-
is denied even if the components of refinements we identified as of quired. The developer of the target
are in the same application. Figure the v1.0r1 SDK release. activity can permit such function-
4 depicts this logic. ality by not assigning an access per-
The developer assigns permis- Public vs. Private mission to it—that is, if a public
sion labels via the XML manifest Components component doesn’t explicitly have
file that accompanies every appli- Applications often contain com- an access permission listed in its
cation package. In doing so, the ponents that another application manifest definition, Android per-
developer defines the application’s should never access—for example, mits any application to access it.
security policy—that is, assigning an activity designed to return a Although this default allows
permission labels to an application user-entered password could be policy specification enables func-
specifies its protection domain, started maliciously. Instead of de- tionality and ease of development,
whereas assigning permissions to fining an access permission, the de- it can lead to poor security prac-
the components in an application veloper could make a component tices and is contrary to Saltzer and
specifies an access policy to protect private by either explicitly setting Schroeder’s principle of fail-safe
its resources. Because Android’s the exported attribute to false in defaults.4 Referring back to our
policy enforcement is mandatory, the manifest file or letting Android example FriendViewer application,
as opposed to discretionary,2 all infer if the component should be if the FriendReceiver broadcast re-
permission labels are set at install private from other attributes in its ceiver isn’t assigned an access per-
time and can’t change until the manifest definition. mission, any unprivileged installed
application is reinstalled. How- Private components simplify application can forge a FRIEND_
ever, despite its MAC properties, security specification. By making NEAR message, which represents a
Android’s permission label model a component private, the devel- significant security concern for ap-
only restricts access to components oper doesn’t need to worry which plications making decisions based
and doesn’t currently provide in- permission label to assign it or how on information passed via the in-
formation flow guarantees, such as another application might acquire tent. As a general practice, securi-
in domain type enforcement.3 that label. Any application can ac- ty-aware developers should always
cess components that aren’t explic- assign access permissions to public
Security Refinements itly assigned an access permission, components—in fact, they should
Android’s security framework is so the addition of private compo- have an explicit reason for not as-
based on the label-oriented ICC nents and inference rules (intro- signing one. All inputs should be
mediation described thus far, but duced in the v0.9r1 SDK release, scrutinized under these conditions.
our description is incomplete. Par- August 2008) significantly reduces
tially out of necessity and partially the attack surface for many applica- Broadcast Intent
for convenience, the Google de- tions. However, the developer must Permissions
velopers who designed Android be careful when allowing Android Components aren’t the only re-
source that requires protection. In query with write side effects (IN- Not all system resources (such as
our FriendTracker example, the SERT, DELETE, UPDATE) doesn’t the network, camera, and mi-
FriendTracker service broadcasts have the write permission, the que- crophone) are accessed through
an intent to the FRIEND_NEAR ac- ry is denied. The separate read and components—instead, Android
tion string to indicate the phone is write permissions let the developer provides direct API access. In fact,
physically near a friend’s location. distinguish between data users and the services that provide indi-
Although this event notification interactions that affect the data’s rect access to hardware often use
lets the FriendViewer application integrity. Security-aware develop- APIs available to third-party ap-
update the user, it potentially in- ers should define separate read and plications. Android protects these
forms all installed applications of write permissions, even if the dis- sensitive APIs with additional per-
the phone’s proximity. In this case, tinction isn’t immediately apparent. mission label checks: an applica-
sending the unprotected intent tion must declare a corresponding
is a privacy risk. More generally, Service Hooks permission label in its manifest file
unprotected intent broadcasts can Although they weren’t explic- to use them. Bitfrost takes a simi-
unintentionally leak information itly identified, the FriendTrack- lar approach (the “one laptop per
to explicitly listening attackers. er service defines RPC child” security model5), but it al-
To combat this, the Android API interfaces: isTracking() and lows controlled permission change
for broadcasting intents optionally addNickname(String). The after installation.
allows the developer to specify a isTracking() method doesn’t By protecting sensitive APIs
permission label to restrict access change the service’s running with permissions, Android forces
to the intent object. state; it simply returns wheth- an application developer to de-
The access permission label as- er FriendTracker is currently clare the desire to interface with
signment to a broadcasted intent— tracking locations. However, the system in a specific way. Con-
for example, sendBroadcast addNickname(String) does sequently, vulnerable applications
(intent, “perm.FRIEND_NEAR”)— modify the running state by telling can’t gain unknown access if ex-
restricts the set of applications that FriendTracker to start tracking an- ploited. The most commonly en-
can receive it (in this example, other friend. Due to this state mod- countered protected API is for
only to applications containing ification, the developer might want network connections—for exam-
the “perm.FRIEND_NEAR” per- to differentiate access to the two ple, the FriendViewer application
mission label). This lets the devel- interfaces. Unfortunately, Android requires Internet access for map
oper control how information is only lets the developer assign one information, so it must declare
disseminated, but this refinement permission label to restrict starting, the INTERNET permission label.
pushes an application’s security stopping, and binding to a service. In general, protected APIs make
policy into its source code. The Under this model, any application an application’s protection domain
manifest file therefore doesn’t give that can start or stop FriendTrack- much clearer because the policy is
the entire picture of the applica- er can also tell it to monitor new defined in the manifest file.
tion’s security. friends. To address this, Android
provides the checkPermission() Permission
Content Provider method, which lets developers arbi- Protection Levels
Permissions trarily extend the reference moni- Early versions of the Android SDK
In our FriendTracker application, tor with a more restrictive policy. let developers mark a permission
the FriendProvider content pro- In effect, these service hooks let the as “application” or “system.” The
vider stores friends’ geographic developer write code to perform default application level meant
coordinates. As a developer, we custom runtime security. that any application requesting the
want our application to be the only Service hooks provide much permission label would receive it.
one to update the contents but for greater flexibility when defining Conversely, system permission la-
other applications to be able to access policy—in fact, several ser- bels were granted only to applica-
read them. Android allows such a vices provided in the base Android tions installed in /data/system
security policy by modifying how distribution use them. However, (as opposed to /data/app, which
access permissions are assigned to like broadcast intent permissions, is independent of label assign-
content providers—instead of us- service hooks move policy into the ment). The likely reason is that
ing one permission label, the de- application code, which can cloud only system applications should be
veloper can assign both read and application security. able to perform operations such as
write permissions. interfacing directly with the tele-
If the application performing a Protected APIs phony API.
The v0.9r1 SDK (August 2008) gerous” helps, but it depends on certain delegation techniques have
extended the early model into four the user understanding the secu- substantial negative effects on the
protection levels for permission rity implications. tractability of policy evaluation.6
labels, with the meta information
specified in the manifest of the Pending Intents URI Permissions
package defining the permission. All the security refinements de- The v1.0r1 SDK release (September
“Normal” permissions act like scribed up to this point fall within 2008) introduced another delegation
the old application permissions the realm of an extension to the ba- mechanism—URI permissions.
and are granted to any application sic MAC model. The v0.9r1 SDK Recall that Android uses a special
that requests them in its mani- release (August 2008) introduced content URI to address content
fest; “dangerous” permissions are the concept of a “pending intent,” providers, optionally specifying a
granted only after user confirma- which is rather straightforward: a record within a table. The devel-
tion. Similar to security checks in developer defines an intent object oper can pass such a URI in an
popular desktop operating systems as normally done to perform an intent’s data field—for example, an
such as Microsoft Vista’s user ac- action (to start an activity, for ex- intent can specify the VIEW action
count control (UAC), when an ap- ample). However, instead of per- and a content URI identifying an
plication is installed, the user sees forming the action, the developer image file. If used to start an activ-
a screen listing short descriptions passes the intent to a special meth- ity, the system will choose a com-
of requested dangerous permis- od that creates a PendingIntent ob- ponent in a different application to
sions along with OK and Cancel ject corresponding to the desired view the image. If the target appli-
buttons. Here, the user has the action. The PendingIntent object is cation doesn’t have read permission
opportunity to accept all permis- simply a reference pointer that can to the content provider containing
sion requests or deny the installa- pass to another application, say, via the image file, the developer can
tion. “Signature” permissions are ICC. The recipient application can use a URI permission instead. In
granted only to applications signed modify the original intent by fill- this case, the developer sets a read
by the same developer key as the ing in unspecified address and data flag in the intent that grants the
package defining the permission fields and specify when the action target application access to the spe-
(application signing became man- is invoked. The invocation itself cific intent-identified record.
datory in the v0.9r1 SDK). Finally, causes an RPC with the original URI permissions are essen-
“signature or system” permissions application, in which the ICC ex- tially capabilities for database re-
act like signature permissions but ecutes with all its permissions. cords. Although they provide least
exist for legacy compatibility with Pending intents allow applica- privilege4 access to content provid-
the older system permission type. tions included with the framework ers, the addition of a new delega-
The new permission protection to integrate better with third- tion mechanism further diverges
levels provide a means of control- party applications. Used correctly, from the original MAC model. As
ling how developers assign permis- they can improve an application’s mentioned with pending intents,
sion labels. Signature permissions security—in fact, several Android delegation potentially impacts the
ensure that only the framework APIs require pending intents, such tractability of policy analysis. A
developer can use the specific as the location manager, which has content provider must explicitly
functionality (only Google appli- a “proximity update” feature that allow URI permissions, therefore
cations can directly interface the notifies an application via intent they require the data store devel-
telephony API, for example). Dan- broadcast when a geographic area oper’s participation.
gerous permissions give the end is entered or exited. The pending
user some say in the permission- intent lets an application direct the Lessons in
granting process—for example, broadcast to a specific private broad- Defining Policy
FriendTracker defines the per- cast receiver. This prevents forging Our experiences working with
mission label associated with the without the need to coordinate per- Android security policy revealed
FRIEND_NEAR intent broadcast as missions with system applications. that it begins with a relatively easy
dangerous. However, the permis- However, pending intents di- to understand MAC enforcement
sion protection levels express only verge from Android’s MAC model model, but the number and subtlety
trivial granting policies. A third- by introducing delegation. By using of refinements make it difficult for
party application still doesn’t have a pending intent, an application someone to discover an application’s
much control if it wants another delegates the ability to influence policy simply by looking at it. Some
developer to use the permission intent contents and the time of per- refinements push policy into the
label. Making a permission “dan- forming the action. Historically, application code. Others add del-
egation, which mixes discretionary significantly reduce the need to mation and System Security, vol. 6,
controls into the otherwise typical defer install-time decisions to the no.1, 2003, pp. 128–171.
MAC model. This situation makes user—that is, the policy invariants 7. W. Enck, M. Ongtang, and P.
gathering a firm grasp on Android’s capture the appropriate response. McDaniel, Mitigating Android
security model nontrivial. We’ve successfully used Kirin to Software Misuse Before It Happens,
Even with all the refinements, identify multiple vulnerabilities in tech. report NAS-TR-0094-2008,
holistic security concerns have the base applications provided with Network and Security Research
gone largely unaddressed. First, Android and have subsequently es- Ctr., Dept. Computer Science
what does a permission label re- tablished an ongoing relationship and Eng., Pennsylvania State
ally mean? The label itself is merely with Google to fix the flaws and Univ., Nov. 2008.
a text string, but its assignment to further investigate Android’s secu-
an application provides access to rity via Kirin. William Enck is a PhD candidate in
potentially limitless resources. Sec- In many ways, Android pro- the Systems and Internet Infrastruc-
ond, how do you control access to vides more comprehensive se- ture Security (SIIS) Laboratory in the
permission labels? Android’s per- curity than other mobile phone Department of Computer Science and
mission protection levels provide platforms. However, learning Engineering at Pennsylvania State Uni-
some control, but more expressive how to effectively use its building versity. His research interests include
constraints aren’t possible. As a pur- blocks isn’t easy. We’re only begin- operating systems security, telecom-
posefully simple example, should ning to see different types of appli- munications security, and systems and
an application be able to access both cations, and as Android matures, network security. Enck has an MS in
the microphone and the Internet? we’ll learn how faulty application computer science and engineering from
policy affects the phone’s security. Pennsylvania State University. Contact
We believe that tools such as Ki- him at 344 Information Sciences and