18 Android Secure App Dev
18 Android Secure App Dev
John Mitchell
Guest Lecture Tuesday June 6
• Diogo Mónica, Director of security at Docker
• Topics include container security and what it is
like working as a security engineer
• Diogo a very good speaker. Please show your
appreciating and come to class.
• We will include topics on the final exam
Two lectures on mobile security
• Introduction: platforms and trends
• Threat categories
– Physical, platform malware, malicious apps
• Defense against physical theft Tues
• Malware threats
• System architecture and defenses
– Apple iOS security features and app security model
– Android security features and app security model
• Security app development
– WebView – secure app and web interface dev Thurs
– Device fragmentation
ANDROID
– “android.permission.INTERNET”
– “android.permission.READ_EXTERNAL_STORAGE
– “android.permission.SEND_SMS”
– “android.permission.BLUETOOTH”
https://www.owasp.org/images/3/3e/Danelon_OWASP_EU_Tour_2013.pdf
ANDROID PLATFORM
https://www.owasp.org/images/3/3e/Danelon_OWASP_EU_Tour_2013.pdf
Android Intents
• Msg between components in same or different app
• Intent is a bundle of information, e.g.,
– action to be taken
– data to act on
– category of component to handle the intent
– instructions on how to launch a target activity
• Routing can be
– Explicit: delivered only to a specific receiver
– Implicit: all components that have registered to receive
that action will get the message
• Layers of security
– Each application executes as its own user identity
– Android middleware has reference monitor that
mediates the establishment of inter-component
communication (ICC)
https://www.owasp.org/images/3/3e/Danelon_OWASP_EU_Tour_2013.pdf
Permission redelegation
https://www.owasp.org/images/3/3e/Danelon_OWASP_EU_Tour_2013.pdf
How could this happen?
• App w/ permissions exposes a public interface
• Study in 2011
– Examine 872 apps
– 320 of these (37%) have permissions and at least
one type of public component
– Construct attacks using 15 vulnerabilities in 5 apps
• Reference
– Permission Re-Delegation: Attacks and Defenses,
Adrienne Felt, Helen Wang, Alexander Moshchuk,
Steven Hanna, Erika Chin, Usenix 2011
Example: power control widget
• Default widgets provided by Android, present on all devices
• Can change Wi-fi, BT, GPS, Data Sync, Screen Brightness with
only one click
• Uses Intent to communicate the event of switching settings
• A malicious app without permissions can send a fake Intent to
the Power Control Widget, simulating click to switch settings
https://www.owasp.org/images/3/3e/Danelon_OWASP_EU_Tour_2013.pdf
Vulnerable versions (in red)
.
Android malware example
Install malicious “conference app”
Malware behavior triggered by C&C
server (Chuli)
Chuli source-to-sink flows
ANDROID WEB APPS
.
A Large-Scale Study of
Mobile Web App Security
Patrick Mutchler, Adam Doupe,
John Mitchell, Chris Kruegel, Giovanni Vigna
Mobile Apps
Mobile Apps
Mobile Apps
Mobile Web Apps
Java
JavaScript
JavaScript Bridge
f.bar();
Java
JavaScript
Security Concerns
– Everyone
Isolated in Browser
No origin distinction in WebView
f.bar();
Java
JavaScript
Static Analysis
- Facebook
“…only loading content from trusted
sources into WebView will help protect
users.”
}
public boolean shouldOverrideUrlLoading(
WebView view, String url){
Bridge
content
Use HTTPS?
• 152,706 apps with partially computed URLs
• 87,968 apps (57%) with HTTP URLs
Handling SSL Errors
onReceivedSslError
1. handler.proceed()
2. handler.cancel()
3. view.loadUrl(...)
Mishandling SSL Errors
• 117,974 apps implement
onReceivedSslError
• 29,652 apps (25%) must ignore errors
Primary results
Unsafe Nav 15 34
HTTP 40 56
Unsafe HTTPS 27 29
Popularity
Outdated Apps
Libraries
.
Target Fragmentation in
Android Apps
Patrick Mutchler Yeganeh Safaei
John Mitchell Adam Doupe
Takeaways
Security consequences
Roadmap
Security consequences
“If the device is running Android 6.0 or higher… [the app] must
request each dangerous permission that it needs while the app is
running.
Security consequences
Dataset
Outdatedness
Security consequences
Fragment Injection
Vulnerable App
Malicious Intent
PreferenceActivity
Extra.SHOW_FRAGMENT
“Attacked Fragment”
Extra.SHOW_FRAG_ARG
Attacked
Fragment
Other
Data
Extras
Vulnerable if:
- Targets 4.3 or lower (31%)
- Some class inherits from PreferenceActivity (4.8%)
- That class is exported (1.1%)
- That class does not override isValidFragment (0.55%)