Android Security
Android Security
Understanding
Android Security
T
he next generation of open operating systems middleware layer running on an
embedded Linux kernel, so de-
won’t be on desktops or mainframes but on the velopers wishing to port their
application to Android must use
small mobile devices we carry every day. The its custom user interface environ-
ment. Additionally, Android re-
openness of these new environments will lead to stricts application interaction to its
special APIs by running each ap-
new applications and markets and will enable greater integration plication as its own user identity.
Although this controlled interac-
William Enck, with existing online services. and applications are now available tion has several beneficial security
Machigar However, as the importance of the for it. One of Android’s chief sell- features, our experiences devel-
Ongtang, data and services our cell phones ing points is that it lets developers oping Android applications have
and Patrick support increases, so too do the seamlessly extend online services revealed that designing secure
McDaniel opportunities for vulnerability. It’s to phones. The most visible exam- applications isn’t always straight-
Pennsylvania essential that this next generation ple of this feature is, unsurprising- forward. Android uses a simple
State of platforms provides a compre- ly, the tight integration of Google’s permission label assignment model
University hensive and usable security infra- Gmail, Calendar, and Contacts to restrict access to resources and
structure. Web applications with system util- other applications, but for reasons
Developed by the Open Hand- ities. Android users simply supply a of necessity and convenience, its
set Alliance (visibly led by Google), username and password, and their designers have added several po-
Android is a widely anticipated phones automatically synchro- tentially confusing refinements as
open source operating system for nize with Google services. Other the system has evolved.
mobile devices that provides a vendors are rapidly adapting their This article attempts to un-
base operating system, an applica- existing instant messaging, social mask the complexity of Android
tion middleware layer, a Java soft- networks, and gaming services to security and note some possible
ware development kit (SDK), and Android, and many enterprises are development pitfalls that occur
a collection of system applications. looking for ways to integrate their when defining an application’s se-
Although the Android SDK has own internal operations (such as curity. We conclude by attempt-
been available since late 2007, the inventory management, purchas- ing to draw some lessons and
first publicly available Android- ing, receiving, and so forth) into identify opportunities for future
ready “G1” phone debuted in late it as well. enhancements that should aid in
October 2008. Since then, An- Traditional desktop and server clarity and correctness.
droid’s growth has been phenom- operating systems have struggled
enal: T-Mobile’s G1 manufacturer to securely integrate such per- Android Applications
HTC estimates shipment volumes sonal and business applications The Android application frame-
of more than 1 million phones by and services on a single platform. work forces a structure on devel-
the end of 2008, and industry in- Although doing so on a mobile opers. It doesn’t have a main()
siders expect public adoption to platform such as Android remains function or single entry point for
increase steeply in 2009. Many nontrivial, many researchers hope execution—instead, developers
other cell phone providers have ei- it provides a clean slate devoid of must design applications in terms
ther promised or plan to support it the complications that legacy soft- of components.
in the near future. ware can cause. Android doesn’t
A large community of devel- officially support applications de- Example Application
opers has organized around An- veloped for other platforms: ap- We developed a pair of applications
droid, and many new products plications execute on top of a Java to help describe how Android ap-
50 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.
the phone’s location. Note that if Security Enforcement process boundaries. In fact, all
a service is currently bound, an As Figure 3 shows, Android pro- ICC occurs via an I/O control
explicit “stop” action won’t ter- tects applications and data through command on a special device
minate the service until all bound a combination of two enforcement node, /dev/binder. Because
connections are released. mechanisms, one at the system the file must be world readable
Broadcast receiver and content level and the other at the ICC lev- and writable for proper opera-
provider components have unique el. ICC mediation defines the core tion, the Linux system has no way
forms of interaction. ICC targeted security framework and is this ar- of mediating ICC. Although user
at a broadcast receiver occurs as an ticle’s focus, but it builds on the separation is straightforward and
intent sent (broadcast) either ex- guarantees provided by the under- easily understood, controlling
plicitly to the component or, more lying Linux system. ICC is much more subtle and war-
commonly, to an action string In the general case, each ap- rants careful consideration.
the component subscribes to. For plication runs as a unique user As the central point of secu-
example, FriendReceiver sub- identity, which lets Android limit rity enforcement, the Android
scribes to the developer-defined the potential damage of program- middleware mediates all ICC es-
“FRIEND_NEAR” action string. ming flaws. For example, the Web tablishment by reasoning about
FriendTracker broadcasts an in- browser vulnerability discovered labels assigned to applications and
tent to this action string when it recently after the official release of components. A reference moni-
determines that the phone is near T-Mobile G1 phones only affected tor1 provides mandatory access
a friend; the system then starts the Web browser itself (http:// control (MAC) enforcement of
FriendReceiver and displays a securityevaluators.com/content/ how applications access compo-
message to the user. case-studies/android/index.jsp). nents. In its simplest form, access
Content providers don’t use in- Because of this design choice, the to each component is restricted by
tents—rather, they’re addressed via exploit couldn’t affect other ap- assigning it an access permission
an authority string embedded in a plications or the system. A similar label; this text string need not be
special content URI of the form vulnerability in Apple’s iPhone unique. Developers assign applica-
content://<authority>/ gave way to the first “jail break- tions collections of permission la-
<table>/[<id>]. Here, <table> ing” technique, which let users bels. When a component initiates
indicates a table in the content pro- replace parts of the underlying ICC, the reference monitor looks
vider, and <id> optionally specifies system, but would also have en- at the permission labels assigned to
a record in that table. Components abled a network-based adversary its containing application and—
use this URI to perform a SQL to exploit this flaw (http://security if the target component’s access
query on a content provider, op- eva lu ator s.com /content/ca se permission label is in that collec-
tionally including WHERE condi- -studies/iphone/index.jsp). tion—allows ICC establishment
tions via the query API. ICC isn’t limited by user and to proceed. If the label isn’t in the
Application 1 Application 2
Implicitly Open
Components
Permission A: ... B: 1
Permission Developers frequently define in-
labels labels
tent filters on activities to indicate
... X
C: ... that they can handle certain types
1
Inherit permissions 2
of action/data combinations. Re-
call the example of how the sys-
tem finds an image viewer when
Figure 4. Access permission logic. The Android middleware implements a reference monitor an intent specifying the VIEW
providing mandatory access control (MAC) enforcement about how applications access action and an image reference is
components. The basic enforcement model is the same for all component types. Component passed to the “start activity” API.
A’s ability to access components B and C is determined by comparing the access permission In this case, the caller can’t know
labels on B and C to the collection of labels assigned to application 1. beforehand (much less at develop-
ment time) what access permission
is required. The developer of the
collection, establishment is denied section provides an exhaustive list target activity can permit such
even if the components are in the of refinements we identified as of functionality by not assigning an
same application. Figure 4 depicts the v1.0r1 SDK release. access permission to it—that is, if
this logic. a public component doesn’t ex-
The developer assigns permis- Public vs. Private plicitly have an access permission
sion labels via the XML manifest Components listed in its manifest definition,
file that accompanies every appli- Applications often contain com- Android permits any application
cation package. In doing so, the ponents that another application to access it.
developer defines the application’s should never access—for example, Although this default policy
security policy—that is, assigning an activity designed to return a specification enables functional-
permission labels to an application user-entered password could be ity and ease of development, it can
specifies its protection domain, started maliciously. Instead of de- lead to poor security practices and
whereas assigning permissions to fining an access permission, the is contrary to Saltzer and Schroed-
the components in an application developer could make a compo- er’s principle of fail-safe defaults.4
specifies an access policy to protect nent private by either explicitly Referring back to our example
its resources. Because Android’s setting the exported attribute to FriendViewer application, if the
policy enforcement is mandatory, false in the manifest file or letting FriendReceiver broadcast receiver
as opposed to discretionary,2 all Android infer if the component isn’t assigned an access permission,
permission labels are set at install should be private from other attri- any unprivileged installed appli-
time and can’t change until the butes in its manifest definition. cation can forge a FRIEND_NEAR
application is reinstalled. How- Private components simplify se- message, which represents a sig-
ever, despite its MAC properties, curity specification. By making a nificant security concern for appli-
Android’s permission label model component private, the developer cations making decisions based on
only restricts access to components doesn’t need to worry which per- information passed via the intent.
and doesn’t currently provide in- mission label to assign it or how As a general practice, security-
formation flow guarantees, such as another application might acquire aware developers should always
in domain type enforcement.3 that label. Any application can ac- assign access permissions to public
cess components that aren’t explic- components—in fact, they should
Security Refinements itly assigned an access permission, have an explicit reason for not as-
Android’s security framework is so the addition of private compo- signing one. All inputs should be
based on the label-oriented ICC nents and inference rules (intro- scrutinized under these conditions.
mediation described thus far, but duced in the v0.9r1 SDK release,
our description is incomplete. Par- August 2008) significantly reduces Broadcast Intent
tially out of necessity and partially the attack surface for many applica- Permissions
for convenience, the Google de- tions. However, the developer must Components aren’t the only re-
velopers who designed Android be careful when allowing Android source that requires protection. In
incorporated several refinements to determine if a component is pri- our FriendTracker example, the
to the basic security model, some vate. Security-aware developers FriendTracker service broadcasts
of which have subtle side effects should always explicitly define the an intent to the FRIEND_NEAR ac-
and make its overall security diffi- exported attribute for compo- tion string to indicate the phone is
cult to understand. The rest of this nents intended to be private. physically near a friend’s location.
Although this event notification fect the data’s integrity. Security- APIs available to third-party ap-
lets the FriendViewer application aware developers should define plications. Android protects these
update the user, it potentially in- separate read and write permis- sensitive APIs with additional per-
forms all installed applications of sions, even if the distinction isn’t mission label checks: an applica-
the phone’s proximity. In this case, immediately apparent. tion must declare a corresponding
sending the unprotected intent is a permission label in its manifest file
privacy risk. More generally, un- Service Hooks to use them. Bitfrost takes a simi-
protected intent broadcasts can Although it wasn’t explicitly iden- lar approach (the “one laptop per
unintentionally leak information tified, the FriendTracker ser- child” security model5), but it al-
to explicitly listening attackers. vice defines RPC interfaces: is lows controlled permission change
To combat this, the Android API Tracking() and addNickname after installation.
for broadcasting intents optionally (String). The isTracking() By protecting sensitive APIs
allows the developer to specify a method doesn’t change the ser- with permissions, Android forces
permission label to restrict access vice’s running state; it simply re- an application developer to de-
to the intent object. turns whether FriendTracker is clare the desire to interface with
The access permission label as- currently tracking locations. How- the system in a specific way. Con-
signment to a broadcasted intent— ever, addNickname(String) sequently, vulnerable applications
for example, sendBroadcast does modify the running state can’t gain unknown access if ex-
(intent, “perm.FRIEND_NEAR”)— by telling FriendTracker to start ploited. The most commonly en-
restricts the set of applications that tracking another friend. Due to countered protected API is for
can receive it (in this example, this state modification, the devel- network connections—for exam-
only to applications containing oper might want to differentiate ple, the FriendViewer application
the “perm.FRIEND_NEAR” per- access to the two interfaces. Un- requires Internet access for map
mission label). This lets the devel- fortunately, Android only lets the information, so it must declare
oper control how information is developer assign one permission the INTERNET permission label.
disseminated, but this refinement label to restrict starting, stopping, In general, protected APIs make
pushes an application’s security and binding to a service. Under an application’s protection domain
policy into its source code. The this model, any application that can much clearer because the policy is
manifest file therefore doesn’t give start or stop FriendTracker can also defined in the manifest file.
the entire picture of the applica- tell it to monitor new friends. To
tion’s security. address this, Android provides the Permission
checkPermission() method, Protection Levels
Content Provider which lets developers arbitrarily Early versions of the Android SDK
Permissions extend the reference monitor with let developers mark a permission
In our FriendTracker application, a more restrictive policy. In effect, as “application” or “system.” The
the FriendProvider content pro- these service hooks let the devel- default application level meant
vider stores friends’ geographic oper write code to perform custom that any application requesting the
coordinates. As a developer, we runtime security. permission label would receive it.
want our application to be the only Service hooks provide much Conversely, system permission la-
one to update the contents but for greater flexibility when defining bels were granted only to applica-
other applications to be able to access policy—in fact, several ser- tions installed in /data/system
read them. Android allows such a vices provided in the base Android (as opposed to /data/app, which
security policy by modifying how distribution use them. However, is independent of label assign-
access permissions are assigned to like broadcast intent permissions, ment). The likely reason is that
content providers—instead of us- service hooks move policy into only system applications should be
ing one permission label, the de- the application code, which can able to perform operations such as
veloper can assign both read and cloud application security. interfacing directly with the tele-
write permissions. phony API.
If the application perform- Protected APIs The v0.9r1 SDK (August
ing a query with write side ef- Not all system resources (such as 2008) extended the early model
fects (INSERT, DELETE, UPDATE) the network, camera, and mi- into four protection levels for
doesn’t have the write permission, crophone) are accessed through permission labels, with the meta
the query is denied. The separate components—instead, Android information specified in the
read and write permissions let provides direct API access. In fact, manifest of the package defining
the developer distinguish between the services that provide indi- the permission. “Normal” per-
data users and interactions that af- rect access to hardware often use missions act like the old applica-
tion permissions and are granted basic MAC model. The v0.9r1 tember 2008) introduced another
to any application that requests SDK release (August 2008) intro- delegation mechanism—URI per
them in its manifest; “dangerous” duced the concept of a “pending missions. Recall that Android
permissions are granted only after intent,” which is rather straightfor- uses a special content URI to ad-
user confirmation. Similar to se- ward: a developer defines an intent dress content providers, optionally
curity checks in popular desktop object as normally done to per- specifying a record within a table.
operating systems such as Micro- form an action (to start an activity, The developer can pass such a
soft Vista’s user account control for example). However, instead of URI in an intent’s data field—for
(UAC), when an application is in- performing the action, the devel- example, an intent can specify the
stalled, the user sees a screen list- oper passes the intent to a special VIEW action and a content URI
ing short descriptions of requested method that creates a PendingIn- identifying an image file. If used
dangerous permissions along with tent object corresponding to the to start an activity, the system will
OK and Cancel buttons. Here, desired action. The PendingIntent choose a component in a differ-
the user has the opportunity to object is simply a reference pointer ent application to view the image.
accept all permission requests or that can pass to another applica- If the target application doesn’t
deny the installation. “Signature” tion, say, via ICC. The recipient have read permission to the con-
permissions are granted only to application can modify the origi- tent provider containing the im-
applications signed by the same nal intent by filling in unspecified age file, the developer can use a
developer key as the package de- address and data fields and specify URI permission instead. In this
fining the permission (application when the action is invoked. The case, the developer sets a read flag
signing became mandatory in the invocation itself causes an RPC in the intent that grants the target
v0.9r1 SDK). Finally, “signature with the original application, in application access to the specific
or system” permissions act like which the ICC executes with all intent-identified record.
signature permissions but exist its permissions. URI permissions are essen-
for legacy compatibility with the Pending intents allow applica- tially capabilities for database re-
older system permission type. tions included with the framework cords. Although they provide least
The new permission protec- to integrate better with third-par- privilege4 access to content provid-
tion levels provide a means of ty applications. Used correctly, ers, the addition of a new delega-
controlling how developers as- they can improve an application’s tion mechanism further diverges
sign permission labels. Signature security—in fact, several Android from the original MAC model. As
permissions ensure that only the APIs require pending intents, such mentioned with pending intents,
framework developer can use as the location manager, which has delegation potentially impacts the
the specific functionality (only a “proximity update” feature that tractability of policy analysis. A
Google applications can directly notifies an application via intent content provider must explicitly
interface the telephony API, for broadcast when a geographic area allow URI permissions, therefore
example). Dangerous permissions is entered or exited. The pending they require the data store devel-
give the end user some say in the intent lets an application direct oper’s participation.
permission-granting process—for the broadcast to a specific private
example, FriendTracker defines broadcast receiver. This prevents Lessons in
the permission label associated forging without the need to co- Defining Policy
with the FRIEND_NEAR intent ordinate permissions with system Our experiences working with
broadcast as dangerous. However, applications. the Android security policy re-
the permission protection levels However, pending intents vealed that it begins with a rela-
express only trivial granting poli- diverge from Android’s MAC tively easy-to-understand MAC
cies. A third-party application still model by introducing delegation. enforcement model, but the num-
doesn’t have much control if it By using a pending intent, an ap- ber and subtlety of refinements
wants another developer to use the plication delegates the ability to make it difficult for someone to
permission label. Making a per- influence intent contents and the discover an application’s policy
mission “dangerous” helps, but it time of performing the action. simply by looking at it. Some re-
depends on the user understand- Historically, certain delegation finements push policy into the
ing the security implications. techniques have substantial nega- application code. Others add dele-
tive effects on the tractability of gation, which mixes discretionary
Pending Intents policy evaluation.6 controls into the otherwise typical
All the security refinements de- MAC model. This situation makes
scribed up to this point fall within URI Permissions gathering a firm grasp on An-
the realm of an extension to the The v1.0r1 SDK release (Sep- droid’s security model nontrivial.
Even with all the refinements, variants capture the appropriate McDaniel, Mitigating Android
holistic security concerns have response. We’ve successfully used Software Misuse Before It Happens,
gone largely unaddressed. First, Kirin to identify multiple vulner- tech. report NAS-TR-0094-2008,
what does a permission label really abilities in the base applications Network and Security Research
mean? The label itself is merely provided with Android and have Ctr., Dept. Computer Science and
a text string, but its assignment subsequently established an ongo- Eng., Pennsylvania State Univ.,
to an application provides access ing relationship with Google to Nov. 2008.
to potentially limitless resources. fix the flaws and further investi-
Second, how do you control access gate Android’s security via Kirin. William Enck is a PhD candidate in
to permission labels? Android’s In many ways, Android pro- the Systems and Internet Infrastruc-
permission protection levels pro- vides more comprehensive security ture Security (SIIS) Laboratory in the
vide some control, but more ex- than other mobile phone platforms. Department of Computer Science and
pressive constraints aren’t possible. However, learning how to effec- Engineering at Pennsylvania State Uni-
As a purposefully simple example, tively use its building blocks isn’t versity. His research interests include
should an application be able to easy. We’re only beginning to see operating systems security, telecom-
access both the microphone and different types of applications, and munications security, and systems and
the Internet? as Android matures, we’ll learn network security. Enck has an MS in
how faulty application policy af- computer science and engineering from
fects the phone’s security. We be- Pennsylvania State University. Contact