Developers Guide Securing Mobile Applications Threat Modeling
Developers Guide Securing Mobile Applications Threat Modeling
Mobile Applications
Part One: Threat Modeling
This eBook, part one in a series, focuses on threat modeling mobile applications. Subsequent eBooks
within the series will cover mobile secure coding guidance and integrating security into the mobile
development life cycle.
FACET RESOUCE
ASSETS
Table of Contents
Web Applications.....................................................................................................................................2
Conclusion.................................................................................................................................................... 11
| synopsys.com
Introduction:
Entering the Mobile Ecosystem
It’s safe to say that mobile technology has become a ubiquitous aspect of our lives. You
almost certainly own a mobile device and rely on it daily. From the critical to the convenient,
we do nearly everything on mobile devices today. In fact, it’s hard to imagine how we could
live without them.
Software developers are all too familiar with the influx of mobile technology. Adapting to the
ever-changing evolution of platform features, user preferences, programming language shifts,
SDK updates, and so on—it’s hard to keep up with basic functionality in the mobile ecosystem.
Additionally, the price for failing to keep up is dramatic. Fickle users simply jump to the next
trending app that’s just a click away in the app store.
Keeping up with security is also becoming harder. It’s not something the average developer
appreciates on even the best day. Mobile requires a different threat model than other
platforms. Developers must understand this threat model to build apps securely. Failing to
build security into apps can lead to catastrophic results. Some recent examples of this include
Tinder and Uber.
Within this resource, we’ll address this challenge head-on by providing actionable guidance. We
aim to raise awareness, educate, and enable further discussion around mobile security. While
the contents below target mobile app developers, other roles coordinating with the development
organization can also benefit from this eBook. We also invite development leads, architects,
business analysts, and security people who are responsible for building secure apps to read on.
Threat modeling promotes the idea of thinking like an attacker. It models security risk by documenting the
existence of—and relationships between—key components of risk. For developers, threat models identify
controls requiring implementation. For security teams, threat models identify areas requiring testing. Without
threat modeling, security activities turn into an endless and aimless bug squashing activity without a risk-based
understanding of priority and impact.
| synopsys.com | 1
Without threat modeling, security
activities turn into an endless and
aimless bug squashing activity
without a risk-based understanding of
priority and impact.
Web Applications
For many years, development teams have been working with Web applications that often have a common threat
model. All Web applications have similar interfaces (e.g., protocols, languages, etc.). Many of the assets, controls,
threat agents, and attack vectors don’t change significantly between Web applications. Figure 1 presents a sample
Web application threat model diagram.
TA05
Workstation
TA03
TA04 C03
Thick-Client Browser TA01
TA02
Application
C07 Application A01
UI Process Server (Site 1) A03
| synopsys.com | 2
Table 1 presents the controls in place protecting assets from threat agents. The only controls included here are
those that Web application developers can expect to be in place universally, or controls that the Web application
developers can implement themselves.
Controls including filesystem encryption and access controls on end user workstations may be present in some
cases. However, developers cannot expect them to be in place on all workstations. That is, unless they’re creating
Intranet applications for an organization in which the IT department adds these controls to all workstations.
Controls such as certificate pinning aren’t present in some of the major browsers. At the time of this writing, these
include Internet Explorer, Edge, and Safari. Therefore, Web application developers can’t rely on these controls.
• Cookies
Malicious websites Browser • Application data • Same origin policy
• Application functionality • Input validation /
• Cookies output encoding
• Dom objects
Malicious websites Browser • Users’ private data • Browser
• User workstation functionality process sandboxing
Malicious User workstation • Application data
thick-client software
• Application functionality
• Cookies
• Users’ private data
• User workstation functionality
User with physical User workstation • Application data • Cache directives
access to workstation
• Application functionality
• Cookies
• Users’ private data
• User workstation functionality
Table 1. Threat matrix showing mappings between common threat model entities for Web applications.
| synopsys.com | 3
Mobile operating
systems implement
controls like sandboxing
and permission
enforcement to
limit malicious
application access
Mobile Device
Workstation C03
Browser TA01 TA03
Thick Client C04 C02 A01 UI Process TA02
Interface to C04 A03
C09 C04 A02
C10 Application A01
A03
Mobile Device Shared App C04 A04 Renderer (Site 1) C01 Server (Site 1)
Storage Storage C05 A02
A01 A05 C08 C09 C04 A02
C06 C04 A04
Renderer (Site 2) C01
A03
Filesystem App Sandbox
A05
TA05 Application A01
| synopsys.com | 4
Table 2 presents the concerns that vary from the Web application threat model in Table 1.
• Device functionality
Malicious app Mobile device • Application data
(root privileges) • Application functionality
• Cookies
• Users’ private data
• Device functionality
Malicious app on User workstation • Application data
user’s workstation (device backups)
• Cookies
• Users’ private data
The additional controls that are present reduce the likelihood of malicious apps accessing other applications’ data.
This includes application data stored on the device, in addition to end user data and device functionality. Authors
of mobile operating systems learned from the mistakes made years ago by authors of desktop operating systems.
For example, if a user installs a malicious thick client application on a desktop operating system, there is a chance
that it can allow full access to a user’s workstation. This is especially true if the end user is an administrator on
the workstation.
Mobile operating systems implement controls like sandboxing and permission enforcement to limit malicious
application access. Most applications don’t have administrative privileges on the device. Some mobile platforms
only allow applications approved by the platform vendor for installation on devices. However, these controls are
ineffective against malicious apps running with root privileges. For this reason, rooting/jailbreaking devices is
discouraged for users who don’t have a deep security background, and are therefore unable to identify potentially
malicious applications.
Many mobile devices allow users to back up device data to their workstations. These workstations often run
traditional desktop operating systems where these controls are not present. Thus, the concerns from the desktop
environment don’t completely disappear in the mobile ecosystem.
| synopsys.com | 5
Native Mobile Applications
A native application is an application written for a mobile device using the SDK provided by the device’s operating
system vendor. As of this writing, these are applications written in Java (optionally, with some components written
in C/C++) for Android, and applications written in Objective-C, Swift, and/or C/C++ for iOS.
TA06
Mobile Device
TA07
| synopsys.com | 6
Table 3 presents the concerns that vary from the Web application threat model in Table 1. Note that platform-
specific controls (e.g., iOS keychain) and attacks (e.g., Android applications executing native library functionalities of
other applications) aren’t discussed here.
Table 3. Threat matrix showing new mappings between common threat model entities for native
mobile applications.
The code in native mobile applications interacts with the mobile operating system, rather than the JavaScript
runtime in a browser. As a result, some controls provided by browsers are no longer available. This architecture
enables application developers to use more effective controls than are possible in Web applications. Unfortunately,
developers can also disable security controls that Web applications cannot disable.
Certificate verification for TLS connections is different in native mobile applications than Web applications. In
Web applications, browsers often perform certificate verification. (In several cases, depending on the browser/OS
combination, the browser offloads certificate verification to an operating system component or library.) Visual cues
are also presented to users depending on whether a given site is trusted or not.
When it comes to Web application certificate verification modification, HTTP Strict Transport Security (HSTS)
and HTTP Public Key Pinning (HPKP) allow developers to modify browser behavior regarding connections and/
or pinning for their own website. However, support and adoption varies. These technologies don’t fully work
in mobile (yet).
| synopsys.com | 7
The code in native mobile applications
interacts with the mobile operating
system, rather than the JavaScript
runtime in a browser
Native mobile apps have a variety of options to modify certificate verification:
The application’s choice is hidden from the application user. The user may only see an error if the certificate
verification functionality rejects a certificate.
App stores perform some of the same functions for native mobile apps that certificate authorities perform for Web
applications. Instead of expecting a user to trust a Web application because a certificate authority verifies that it
belongs to a particular organization, the user trusts a native app because the app store verifies that it belongs to a
particular organization. Unlike certificate authorities that follow certain minimal standards, some app stores do little
or no verification of an app publisher’s true identity. This is a common problem with Android app stores.
The same origin policy is an important control for Web applications. However, it’s irrelevant for native mobile apps.
This is because each server-side application has a separate native client-side application. Application sandboxing
for native mobile apps provides some of the same protections that the same origin policy provides for Web
applications. It’s important to note that these two protections are not equivalent. For example, the same origin
policy prevents websites from being able to read responses from other origins. This is the case unless the other
origins expose cross-origin communication mechanisms.
On the other hand, application sandboxing for native mobile apps doesn’t prevent them from reading responses
from other origins. There is no concept of origin in native mobile apps. The only readable content from other origins
is content available to unauthenticated users—unless a malicious native mobile app obtains the user’s credentials
or cookies for other sites. This ability to read unauthenticated content from arbitrary sites is one of the reasons why
many organizations don’t allow mobile devices on their internal networks.
Web applications can’t verify the environment that they are running in because they don’t have sufficient access
to the underlying operating system. Therefore, they can’t attempt to detect clients that have malicious software
installed. Native mobile apps are generally sandboxed and protected from other malicious applications that aren’t
running with root privileges. They can also perform checks to identify whether the device they are running on has
been rooted or jailbroken.
If client-side functionality requires protection from reverse engineering, Web applications are limited to JavaScript
obfuscation. However, native mobile apps have a variety of advanced controls available to them. These include
obfuscation, anti-debug, and anti-tamper.
Native mobile applications also have more options available to them for encrypting locally-stored data. They can
also configure backup options to prevent sensitive data from being copied to user workstations where fewer
protections may be available.
| synopsys.com | 8
Hybrid Mobile Applications
A hybrid mobile application is a combination of a native mobile app and a mobile Web application. Some
components are built as a Web application. These components display in one or more WebViews inside the rest of
the application that is built as a native mobile app.
TA06
Mobile Device
TA07
Shared App App Store
App Store Client
Storage Storage
Workstation A05 C08 C07
App Sandbox C06
TA01 TA03
Thick Client C04 C03 C02 A01 TA02
Interface to C04 C03 A03 Mobile App 1 C13 Application A01
C09 C04 A02 C14
Mobile Device App WebView Server (Site 1) A03
C04 A04 C01
Storage C05 A02
A01
A03
C06 Native Component C01
TA05
Filesystem App Sandbox C07 C10 C11 C12 Application A01
A05 C13
Server (Site 2) A03
Mobile TA04 C05 A02
App App Mobile App
Storage
Wearables / A06 C08
App Sandbox
C07
C06
Other Devices
| synopsys.com | 9
Table 4 presents the concepts that are different from all previous threat models.
Table 4. Threat matrix showing mappings between common threat model entities for hybrid mobile apps.
Since hybrid applications contain aspects of both native mobile apps and Web applications, the concerns and
controls from both threat models apply. The threat model for native mobile apps applies to native components.
Meanwhile, the threat model for Web applications (mostly) applies to the components in the WebViews. However,
there are some differences.
• Some standard browser-provided security controls aren’t present. This includes the standard user cues
corresponding to certificate verification status for TLS connections. Just like native applications, hybrid
applications can often utilize certificate pinning.
• Although the same origin policy is present, it’s only applicable to components in WebViews. Many hybrid
applications contain a mix of locally-stored HTML/JavaScript content in the application sandbox on the mobile
device, and HTML/JavaScript content stored on a server. This complicates the same origin policy. Vulnerabilities
have been discovered in the past that are a result of locally-stored files that weren’t subjected to the required
same origin policy restrictions.
• The impact of unauthorized JavaScript code running in a hybrid application can be greater than unauthorized
JavaScript code running in a browser. Hybrid applications often contain native components with which
JavaScript code can interact. For example, JavaScript code in hybrid applications can often access the
application’s locally-stored data. In these cases, the same origin policy isn’t enough to protect the application’s
data and cookies, authentication tokens, and credentials from malicious websites. Thus, applications need to
implement a whitelisting mechanism to ensure that only authorized websites can be opened in its WebViews.
| synopsys.com | 10
Cross-Platform Mobile Applications
Most Web browsers are similar enough that Web applications can be written once and accessed from any browser.
However, when writing mobile apps using native platform APIs, organizations face a challenge. They need to
create a different mobile app for each platform (e.g., Android, iOS, etc.) that they want to support. The increase
in development costs is significant. Additionally, keeping applications on different platforms in sync, and hiring
developers with the right skills, are difficult tasks. As a result, many cross-platform development frameworks have
become popular. These frameworks allow organizations to write a single mobile app that will run on all platforms.
The cross-platform frameworks take care of most platform-specific details. This is similar to how Web browsers
take care of most platform-specific details of the underlying operating system.
There is no single threat model for cross-platform mobile apps as each framework is different. Three examples
of this include:
• Apache Cordova creates hybrid mobile apps in which most application code is HTML/JavaScript. This code
accesses device functionality through plugins written in native platform APIs. The application code renders in a
WebView. The threat model for hybrid applications applies here.
• React Native creates mobile apps in which most application code is JavaScript. A JavaScript engine interprets
this code and calls native modules that directly call platform-specific APIs. (WebViews don’t need the same
involvement as they do in Apache Cordova.) The threat model for native mobile apps mostly applies here.
However, the threat model for hybrid applications may apply if using WebViews in the application. Consider
JavaScript-specific issues in React Native applications even if foregoing WebViews.
• Xamarin creates mobile apps in which application code is C#. The runtime is different on Android and iOS. On
Android, the code compiles to an intermediate language that is interpreted using a Mono VM implementation for
Android. On iOS, the application code, along with Xamarin framework code, compiles to native code that runs
like a native mobile app on iOS. Regardless of the platform-specific implementation details, the threat model for
native mobile apps applies here. However, the threat model for hybrid applications may apply if the application is
using WebViews.
The main takeaway here is that the mobile ecosystem is different than the Web ecosystem,
and mobile app development teams need to understand the assets, controls, and threat agents
for mobile apps.
| synopsys.com | 11
Don't get lost
in the mobile
abyss.
Learn more
Expert contributors:
Amit Sethi, Neil Bergman, John Kozyrakis, Corey Gagnon, Joel Scambray
©2020 Synopsys, Inc. All rights reserved. Synopsys is a trademark of Synopsys, Inc. in the United States and other countries. A list of Synopsys trademarks is
available at http://www.synopsys.com/copyright.html . All other names mentioned herein are trademarks or registered trademarks of their respective owners.
06/12/20.eb_DGTSTM_032720.