• No results found

Lecture 2 PLATFORM SECURITY IN ANDROID OS

N/A
N/A
Protected

Academic year: 2021

Share "Lecture 2 PLATFORM SECURITY IN ANDROID OS"

Copied!
61
0
0

Loading.... (view fulltext now)

Full text

(1)

PLATFORM SECURITY IN

ANDROID OS

(2)

You will be learning:

Android as a software platform

Internals and surrounding ecosystem

Security techniques in Android:

Application signing

Application isolation

Permission-based access control

(3)

Mobile Software platform security

Administrator User Application Installer Reference Monitor Mobile Device

System Updater Policy Database

Platform Security Architecture

Application Boot Integrity Device Identification Application Database Developer Centralized Marketplace Operator Auxiliary Marketplace Operator Isolated Execution Device Authentication Platform Provider Application Loader Device Management Third-party library Third-party service H W Se cu rit y A PI Secure Storage Boot Verifier Secure Storage Provider Platform Security Component Third-Party Software Component Role

Legacy DAC Execution Protection Hardware-Security Functionality Legend Software Isolation System service System library IPC

(4)

Mobile software platforms

Which mobile platforms

(5)

Smartphone

platforms

(Image TODO)

Android

iOS

Windows Phone

Other

81,2%

15,8%

2,2%

0,8%

(6)

Android in a nutshell

Linux-based (ARM, x86, x86_64, MIPS)Widely used for phones and tablets

 Wearables, smart TVs, cameras, (handheld) gaming consoles, etc.

Open-source software stack +

(7)

Security goals

Protect user data

Protect system resources

Provide application isolation

(8)

On terminology

Linux = the kernel

”Desktop Linux” ≈ GNU / Linux

Linux DAC = (Unix) file permissions

Linux MAC = SELinux

(9)

Android Software Stack

Middlewa

re

Linux Kernel Hardware Abstraction Layer (HAL) System Server Application Framework Applications Android Runtime Core Libraries Native Daemons Native Libraries Media Server

Drivers Binder SELinux

Dalvik ART System Services & Managers Media Services Manager IPC Proxies System Applications Third-party Applications Content Providers HAL Modules Java Core Library Power Management

(10)

Android Software Stack

R

eference

monitors

Linux Kernel Hardware Abstraction Layer (HAL) System Server Application Framework Applications Android Runtime Core Libraries Native Daemons Native Libraries Media Server

Drivers Binder SELinux

Dalvik ART System Services & Managers Media Services Manager IPC Proxies System Applications Third-party Applications Content Providers HAL Modules Java Core Library Power Management

(11)

Android Software Stack

Linux Kernel Hardware Abstraction Layer (HAL) Native Code System Server Application Framework Applications Android Runtime Core Libraries Native Daemons Native Libraries Media Server

Drivers Binder SELinux

Dalvik ART System Services & Managers Media Services Manager IPC Proxies System Applications Third-party Applications Content Providers HAL Modules Java Core Library Power Management Hardware Trusted OS Kernel Trusted OS Services Trusted Applications

Google. Android for Work Security white paper. 2015

Android OS Trusted Execution Environment

(12)

12

Application components

Activity • Visible UI

Service • Background job

Content

Provider • Database

Enck, Ongtang, McDaniel. Enck, Ongtang, McDaniel: Understanding Android Security. 2009

Signature

Manifest Intent

Broadcast Receiver

(13)

Software distribution

Apps from multiple sources

Google Play  Auxiliary marketplaces  Sideloading  Pre-installed software  Marketplace services  Discovery

 Purchase & Installation

 User-submitted ratings / flagging

 Malware scans (Google Bouncer)

 Remote application installation & removal

App Installer

Developer

(14)

Application signing

Goal: same-origin policy for apps

Developer signs with private key

Signature verified

with developer’s public key

(15)

Application signing (cont.)

For application packages (APKs)

Self-signed X.509 certificates (no PKI!)

 Individual signature for each file part of APK

 Package update requires same certificate

For over-the-air updates (OTAs)

Signature over entire file stored in ZIP comment  Verified by OS and Recovery Mode

System images must be signed (since 6.0)

(16)

Android application packages

Com .ex a mple.ap p.apk META_INF MANIFEST.MF CERT.RSA CERT.SF AndroidManifest.XML classes.dex lib res assets native code non-compiled resources application assets

(17)

Package Installation

 Code and resources (common)

/data/app/com.example.app/

 lib/<arch>/libapp.so

 oat/<arch>/base.odex

 base.apk

Data (per user)

/data/user/0/com.example.app/  files/  databases/  shared_prefs/  /data/user/1/com.example.app/  ... Com.example.ap p .apk META_INF MANIFEST.MF CERT.RSA CERT.SF AndroidManifest.XML classes.dex lib res assets native code <arch>/libapp.so non-compiled resources application assets

(18)

Package management components

Package Installer (system app) PackageManager pm command Installer MountService MediaContainerService installd daemon vold daemon AppDirObserver /dev/socket/installd /dev/socket/vold

Elenkov. Android’s Security Architecture. 2015.

├packages.xml ├packages.list ├app/ ├data/ ├media/ └user/ /data ├ framework/ ├ app/ ├ priv-app/ └ vendor-app/ /system

(19)

Application isolation

Goal: Applications cannot

(20)

Application isolation

Implementation on Android:

Kernel:

Process & memory protection

Kernel: Linux

DAC

Kernel: Linux

MAC

(

SELinux

)

Middleware:

mediation

of

Binder IPC

Applications run in separate Dalvik / ART

(21)

Application Sandbox

Each application assigned a Unix UID

One UID per user per application (since 5.0)  UID owns

 Filesystem resources in /data/user/<nr>/

 Processes

 Permissions (!)

Applications from same developer

(= signed with same developer key) may share UID sandbox

(22)

Application isolation

System Third-party applications

Services

Applications

(23)

Rooting

Rooting applications exploit vulnerabilities in

privileged system daemons to obtain shell

Note: bootloader unlocking intentionally

supported by many OEMs

(24)

SE for Android

Goal: System services and

applications should not be able

to deviate from their intended

(25)

SE for Android (cont.)

Implementation on Android:

Kernel-level MAC (SELinux) –

Policies based on SELinux context

Middleware MAC (MMAC) –

Policies based on package identity

Smalley, Craig. Smalley, Craig: Security Enhanced (SE) Android. 2013 Android Open Source Project. Security-Enhanced Linux in Android. 2015

(26)

SE for Android (cont.)

Enforces MAC even for processes running

with root/superuser privileges (since 4.4)

Blocks many root exploits and

misconfigurations

Cannot protect against kernel exploits

Smalley, Craig. Smalley, Craig: Security Enhanced (SE) Android.2013 Android Open Source Project. Security-Enhanced Linux in Android. 2015

(27)

SE for Android

Domain -

Label for process(es)

Type

- Label for object(s)

Class

- Kind of object being accessed

(e.g. file, socket)

Permission

- Operation being performed

(28)

Application isolation (cont)

System Third-party applications

Services

Applications

• Linux DAC domain (UID)

(29)

Protected APIs

Goal: Protect system resources

(30)

Protected APIs

System Third-party applications

Services

Applications

• Linux DAC domain (UID)

(31)

Protected APIs (cont)

Implementation in Android:

Protected APIs for ”risky” actions

Permission-based (mandatory)

(32)

Protected APIs(cont)

What kinds of system calls on a smartphone

(33)

Examples of Protected APIs

Changing device wallpaper, ringtone

Making phone calls, sending SMS’s

Using camera, microphone, GPS

Internet, wireless, Bluetooth access

Reading/writing contacts, SMS log

Rebooting device

Factory reset

See also:http://developer.android.com/reference/android/Manifest.permission.html

”Risky

(34)

Sensitive user data

Subject to permissions checks:

Personal information (e.g. contacts)

Sensitive input devices (e.g.camera)

Location tracking can be manually disabled

(35)

Access control & permissions

Goal: Controls application

access to protected APIs

(and each other)

User agency vs. protecting system resourcesUsability of security features

(36)

Android permissions

4 categories

Normal

Dangerous

System

Signature or System

(37)

Examples of Protected APIs

Changing device wallpaper, ringtone

Making phone calls, sending SMS’s

Using camera, microphone, GPS

Internet, wireless, Bluetooth access

Reading/writing contacts, SMS log

Rebooting device

Factory reset

”Risky ” Dangerous Normal System

(38)

Permission assignment

Application declare all permissions in

AndroidManifest.xml

Permissions assigned to application UIDSome permissions not user-grantable

 Only available to pre-installed applications

My Messenger

INTERNET; READ CONTACTS

(39)

Permission assignment

Normal permission granted automatically

Signature permissions granted if app

signature matches the declarer of the signature

(40)

User approval (up to 5.1)

Dangerous permissions

require user approval at install time

If not granted, application

not installed at all!

Granted for all users

 Stored in

/data/system/packages.xml

(41)

User approval (since 6.0)

Dangerous permissions

require user approval at runtime

If not granted, application

continues to run with limited capabilities

Permission managed per

application, per user

 Stored in

/data/system/users/<id>/ runtime-permissions.xml

(42)

Permission revocation

May be revoked later

(43)

Alternatives to obtaining

permissions

Delegate task to other application using

Intent, e.g. invoke Camera app using

ACTION_IMAGE_CAPTURE Intent

Caller does not need CAMERA permission

 Caller cannot control the user experience, but does not have to provide UI for task

 If no default app available, user is prompted to designate the handler

(44)

Intents

Messaging object used for Inter-Component

Communication (ICC)

Recall: activities, services, content providers,

broadcast receivers

Addressing

 Explicit – fully qualified component name

Implicit – Intent filter declared in manifest

 Provides a mechanism for late binding

Pending Intents

(45)

Binder

IPC system for object-orientated operating

system services (comp. CORBA/COM)

Most underlying IPC based on Binder

 Intents & content providers abstractions on top of Binder

 Cf. local UNIX-domain sockets, signals, filesystem

Bionic libc doesn’t support System V IPC

Does not provide mediation by itself

(46)

Binder Service Discovery

Linux Kernel

Binder Driver (/dev/binder)

ServiceManager (servicemanager) System Server (system_server) Application(s) binder_ becom e_co nt ext_man ager( ) ioctl(BINDER_SET_CONTEXT_MGR) Services List (*svclist) do_add_ servi ce() do_find _serv ice( ) Other System Services & Managers Activity Manager Package Manager Framework library 1 2 3 Application Components e.g. Activity, Service

etc.

(47)

Starting an Activity

Linux Kernel Binder System Server (system_server) Application Component

e.g. Activity, Service etc. Package Manager

Application Framework

Activity Manager

ICC Reference Monitor

RPC Stub Ma nifes t startActivity(intent) checkCallingPermission(…) PERMISSION_GRANTED Other System Services & Managers Activity onCreate(…) 1 3 4 2 transact(…)

(48)

Starting an Activity

Linux Kernel Binder System Server (system_server) Application Component

e.g. Activity, Service etc. Package Manager

Application Framework

Activity Manager

ICC Reference Monitor

RPC Stub Ma nifes t startActivity(intent) checkCallingPermission(…) PERMISSION_DENIED Other System Services & Managers 1 3 4 2 transact(…) SecurityException

(49)

49

Authentication

Keyguard

Pattern

 PIN / Password

Gatekeeper HAL (since 6.0)

Allows Keyguard to make use of native security

features

TrustAgentAPI (since 5.0)

Enables services that notify the system about

whether they believe the environment of the device to be trusted

Android Open Source Project. Gatekeeper. Elenkov. Password storage in Android M. 2015. Elenkov. Dissecting Lollipop’s SmartLock. 2014.

(50)

Authentication (cont.)

Smart Lock Trust Agent (since 5.0)

Trusted Bluetooth device  Trusted NFC

 Trusted place ( via geofencing )

 Facial recognition

On-body detection

Fingerprint HAL (since 6.0)

 Access to vendor-specific fingerprint hardware

Elenkov. Dissecting Lollipop’s SmartLock. 2014.

Nexus Help: Set up your device for automatic unlock.

(51)

Hardware-based security

features

Goals:

Platform integrity

(52)

Hardware-based security

features

Implementation on Android:

Verified boot

Full-disk encryption

Keychain / Keystore

(53)

Keychain

System credential store for private keys and

certificate chains (since 4.0)

KeyChain API is used for Wi-Fi and Virtual

Private Network (VPN) certificates

Hardware-backed keystore binds keys to

device to make them non-exportable

KeyInfo.isInsideSecureHardware() (since 6.0)

indicates if key is stored in hardware keystore

(54)

54

Keystore

Keystore

 For application-bound keys

 Access via Java CE API

KeymasterHAL

Access to hardware-backed keystoreAssymmetric key generation,

signing and verification (since 4.1)

Binder IKeyStoreInterface (since 4.3)

Symmetric key support, access control, public key

import and private / symmetric key import (since 6.0)

Android Open Source Project. Keymaster. Elenkov. Keystore redesign in Android M.2015.

(55)

Keystore (cont.)

Elenkov. Keystore redesign in Android M.2015.

Elenkov. Credential storage enhancements in Android 4.3. 2013.

Propri etory (de vi ce spec ific) Android OS Hardware libQSEEComAPI.so Keymaster HAL libkeymaster.so IKeyStoreService AndroidKeyStoreProvider

Java Cryptography Extensions (JCE)

Application Application

Qualcomm Secure Execution Environment (QSEE) KeyStore Trusted App

ARM TrustZone

Trusted Execution Environment (TEE)

QSEE Communication API

(56)

Full Disk Encryption

Block-device encryption based on dm-cryptEncrypted on first boot (since 5.0)

AES 128 CBC and ESSIV:SHA256

DEK encrypted with AES 128

KEK derived from user PIN / password / pattern

+ hardware-bound key stored in TEE (since 5.0)

Crypto acceleration through hardware AES

(e.g. dm-req-crypt)

Android Open Source Project. Full Disk Encryption.

(57)

Verified Boot

Based on dm-verity kernel feature

Calculates SHA256 hash over every 4K block

of the system partition block device

 Hash values stored in hash tree

Tree collapsed into a single root hash

Signature of the root hash verified with public

key included on the boot partition

 Must be verified externally by the OEM

(58)

Verified Boot Hash Tree

(59)

Mobile Software platform security

Administrator User Application Installer Reference Monitor Mobile Device

System Updater Policy Database

Platform Security Architecture

Application Boot Integrity Device Identification Application Database Developer Centralized Marketplace Operator Auxiliary Marketplace Operator Isolated Execution Device Authentication Platform Provider Application Loader Device Management Third-party library Third-party service H W Se cu rit y A PI Secure Storage Boot Verifier Secure Storage Provider Platform Security Component Third-Party Software Component Role

Legacy DAC Execution Protection Hardware-Security Functionality Legend Software Isolation System service System library IPC

(60)

Did you learn:

Android as a software platform

Internals and surrounding ecosystem

Security techniques in Android:

Application signing

Application isolation

Permission-based access control

Hardware-based security features

(61)

Plan for the course

Lecture 1: Platform security basics

Lecture 2: Case study – Android

Lecture 3: Mobile software platform

security in general

Lecture 4: Hardware security enablers

Lecture 5: Usability of platform security

Invited lecture: SE Android policies

References

Related documents

Amongst those respondents in the UK who used social networks for discovering an important breaking story such as a natural disaster or political crisis, 65% said they would turn

While indirect agritourism has the potential to result in thriving domestic agriculture sectors, there must be deliberate efforts to prevent a solitary focus on providing food

and LCP olecranon plate Good Fair Fair Fair Excellent Excellent Excellent Good Good Poor Good LOM Ulnar nerve Sx Heterotophic ossification LOM, ulnar nerve Sx Ulnar nerve Sx

16Gb 48/48 FC Switch with 48 active ports; rackmount kit; accessory kit (enterprise safety and regulatory information, installation guide, rack-mounting instructions), power

The EUT is connected to the power mains through a coupling device that directly couples the EFT interference signal. Each of the Line and Neutral conductors is impressed with

o Phyllodium pulchellum(syn. Desmodium pulchellum), 0.2% 5-MeO-DMT, small quantities of DMT [55] DMT (dominates in seedlings and young plants), 5-MEO- DMT (dominates in

FmSim and ReSim are new software tools using system dynamics and simulation technologies which combine the user friendliness of spreadsheets, the methodology of flow diagrams

This difference is the equivalent of £1.47m when applied to all 2.1m live customers in March 2010 Financial Services