lessons from the trenches: an inside look at android security · vulnerability news headline unique...

54
Lessons from the trenches: An inside look at Android security Nick Kralevich <[email protected]> 2015-09-09

Upload: others

Post on 24-Jul-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

Lessons from the trenches: An inside look at Android security

Nick Kralevich <[email protected]>2015-09-09

Page 2: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

whoami

Page 3: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

●Nick Kralevich●[email protected]●Android Security since

2009●Platform security lead

whoami

Page 4: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

Just one of many people ...

Page 5: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

whoami

millionslines of code in Android Open Source

thousandsof unique devices

hundredsof OEMs and security solutions

Page 6: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

What does it mean to be secure?

Page 7: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

How to make a computer secure

Page 8: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

Lesson #1:Security is about compromise

Page 9: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

Android Security Philosophy

Page 10: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

Non-goal

Highly visible, minimally effective, evokes fear.

Page 11: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

The goal

Effective security is invisible and evokes calm.

Page 12: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

Bridging the gap

Page 13: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

Install Confirmation

Google Play

Unknown Sources Warning

Verify Apps Consent

Verify Apps Warning

Runtime Security Checks

Sandbox & Permissions

Page 14: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

●Prevention●Detection●Minimization●Reaction

Four pillars of Android Security

Page 15: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

First pillar of Android Security:Prevention

Page 16: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

●Code audits●Design reviews●Outreach and education●Safe by default design philosophy●“Red team”

Traditional approaches to prevention

Page 17: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

Lesson #2:Always start with a sandbox

Page 18: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

A platform for applications

Page 19: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

Android Security Evolution

System

Contacts Email Google Play

Game X

Game Y

Root

Android verifies application signature and assigns an application sandbox at install time.

Application Sandboxes (including system) isolate data by running each app as it’s own UID.

Inter-process communication (IPC) requires mutual request.

IPC and services may be protected by permissions.

Page 20: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

Android Security Evolution – 4.1

Root

System

Contacts Email Google Play

User 1

Contacts Email Google Play

Game X

Game Y

Game X

Game Y

Trust Zone

Application sandbox extended to groups of applications -- preventing IPC across the user boundary

Developer key store protected from root compromise

Page 21: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

Lesson #3:Evolve the sandbox as threats emerge

Page 22: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

Android Security Evolution – 5.0

UID=0 UID=0 UID=0 UID=0 UID=0 UID=0

System

System

System

System

System

System

Contacts Email Google Play

User 1

Contacts Email Google Play

Game X

Game Y

Game X

Game Y

Trust Zone

Segmentation of system and root UID with constrained SELinux policies

All powerful root no longer exists. Only constrained UID=0

Central security policy allows audit of system & root applications

Page 23: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

Q: It might be good for everyone to know: Which Android devices do you find the most secure?

CunningLogic (aka jcase)

A: Android 5.x and up is particularly annoying for me to try and root, my go to tactics are often dead due to the strengthened SELinux policies.

https://www.reddit.com/r/Android/comments/3hhciw/ask_us_almost_anything_about_android_security/

Android Security Evolution – 5.0

Page 24: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

Android Security Evolution

UID=0 UID=0 UID=0 UID=0 UID=0 UID=0

System

System

System

System

System

System

Contacts Email Google Play

User 1

Contacts Email Google Play

Game X

Game Y

Game X

Game Y

Kernel

Hardware

Trust Zone

Experimental features in 5.0 provide integrity checking for the full stack.

Supply chain threats are also a focus of research efforts.

Page 25: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

Lesson #4:Establish strong security standards

Page 26: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

● No unlabeled files● No ptrace● No device node creation● No raw I/O● No mmap zero● No mac_override● No setting security properties● No access to /data/security and

/data/misc/keystore● No /dev/mem or /dev/kmem access● No /proc usermode helpers● No ptrace of init● No access to generically labeled

/dev/block files● Restrictions on mounting filesystems

Security Standards – SELinux assertions

● No execute of files from outside of /system

● No access to /data/properties● No writing to /system or rootfs● No registering of unknown services● No entering init domain● No /sys/kernel/debug read access● No apps acquiring capabilities● No raw app access to camera,

microphone, NFC, radio, etc.● No app-generic socket access● No app/proc access to different security

domains ● No access to GPS files● Cannot disable SELinux

Currently ~250 rules

Page 27: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

Second pillar of Android security:Minimization

Page 28: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

●Impossible to fix every bug●Impossible to find every bug●Robustness in failure●Maintain the integrity of the system

Why minimization?

Page 29: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

Lesson #5:Account for human error

Page 30: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

Is this statement true?

x + 1 > x

A quiz

Page 31: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

Is this statement true?

x + 1 > x

Not if you’re a programmer...

A quiz

Page 32: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

●ASLR●No eXecute Memory●FORTIFY_SOURCE●Read-only Relocations●Stack Canaries●Non-PIE binaries banned

Compiler Hardening

Page 33: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

●Research○ Integer overflow protections○ CFI (Control Flow Integrity)○ Safe Stack○ -fstack-protector-strong

Compiler Hardening – research

Page 34: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

Lesson #6:Encourage safe languages

Page 35: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

●Android standardized on memory safe languages

●Native code specifically discouraged:Notably, using native code on Android generally does not result in a noticeable performance improvement, but it always increases your app complexity. In general, you should only use the NDK if it is essential to your app—never because you simply prefer to program in C/C++.

https://developer.android.com/tools/sdk/ndk/index.html

Language Choice

Page 36: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

●Our industry needs to discourage memory unsafe languages○ Too risky and error prone

●Early research on C replacements for Android○ Suggestions welcome!

Language Choice – research

Page 37: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

"Every program and every user of the system should operate using the least set of privileges necessary to complete the job."J. H. Saltzer and M. D. Schroeder, “The protection of information in computer systems”, pp. 1278-1308, Proceedings of the IEEE 63, number 9, September 1975

Principle of least privilege

Page 38: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

●Designed with containment in mind○ UID sandbox○ SELinux sandbox

●Exploit mitigations effective○ ASLR○ SELinux no-exec rules

Case Study – libstagefright

Page 39: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

Third pillar of Android Security:Detection

Page 40: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

Lesson #6:Keep your ears to the ground

Page 41: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

[email protected]●Android bug database●Academic research / journals●Automated monitoring of forums●Failed exploit detection●Android Security Rewards Program

Multiple methods of discovering bugs

Page 42: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

Android Security Rewards Program

Severity Bug Test case CTS / patch CTS+Patch

Critical $2,000 $3,000 $4,000 $8,000

High $1,000 $1,500 $2,000 $4,000

Moderate $500 $750 $1,000 $2,000

Low $0 $333 $500 $1,000

Page 43: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

●$10K - local to kernel●$20k - remote to kernel●$20k - local to trustzone●$30k - remote to trustzone

Up to $38,000 per issuehttps://g.co/AndroidSecurityRewards

Android Security Rewards Program

Page 44: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

Fourth pillar of Android Security:Reaction

Page 45: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

Lesson #7:Have an update strategy

Page 46: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

●Monthly Security Updates●Monthly Security Bulletins●3 years from device availability

Updates

Page 47: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

●3rd party apps are important too●1.6 million apps in Google Play●Identified security vulnerabilities

○ OpenSSL○ Private Keys in Apps○ Apache Cordova Update○ Exposed Credentials

●All of them are getting fixed

Not just about OS updates...

Page 48: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

There is no such thing as perfect security.

Page 49: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

Lesson #8:Strive for accurate risk assessments

Page 50: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

VulnerabilityNews

Headline Unique APKs

Peak exploitation after public release (per

install)

Exploitation before public

release (absolute)

Master Key99% of devices

vulnerable1231 < 8 in a million 0

FakeID82% of

Android users at risk

258 <1 in a million 0

Masterkey data collected from 11/15/2012 to 8/15/2013 and previously published at VirusBulletin 2013. Fake ID data collected data collected from 11/15/2012 to 12/11/2014 and previously published at

Source: Google Safety Net Data

On risk

Page 52: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

Closing

Page 53: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

●Android grew up in the Internet age, and learned from 40 years of digital security experience.

●Robust, sophisticated, multi-layer security model.

●Open platform ensures Android will continue to evolve to meet new threats.

In closing

Page 54: Lessons from the trenches: An inside look at Android security · Vulnerability News Headline Unique APKs Peak exploitation after public release (per install) Exploitation before public

Questions?

Nick [email protected]

[email protected]