1 of 46

Contextual Policy Enforcement in Android Applications with Permission Event Graphs

Kevin Chen, Noah Johnson, Vijay D’Silva, Shuaifu Dai, Kyle MacNamara, Tom Magrino, Edward Wu, Martin Rinard*, and Dawn Song

University of California, Berkeley

*Massachusetts Institute of Technology

2 of 46

Android

Figure: Google Play App Market Growth

3 of 46

Android Malware

  • "2577% growth over 2012" -Cisco Security Report 2013

  • "Android malware cases to hit 1 million in 2013"

-Trend Micro Annual Threat Report

Figure: Google Play App Market Growth

4 of 46

Android Malware Detection

...

...

...

...

...

...

...

APP

Permission

Pkg

Author

Our approach

5 of 46

Undetected Malware Example

6 of 46

User Intended Policy

"The recording can only be started by clicking the REC button, and it will be stopped when the user clicks the STOP button."

7 of 46

Intuition

A representation that summarizes the event dependencies and their API/permission level behaviors (The Permission Event Graph), and a policy language based on that.

8 of 46

Permission Event Graph (PEG)

0

1

2

initialization

sub-graph

finalization

sub-graph

REC.onClick

Start-Recording

STOP.onClick

Stop-Recording

onCreate

onResume

startService

"The recording can only be started by clicking the REC button, and it will be stopped when the user clicks the STOP button."

9 of 46

PEG: States

0

1

2

initialization

sub-graph

finalization

sub-graph

10 of 46

PEG: States

0

1

2

initialization

sub-graph

finalization

sub-graph

State s: {true, false} ^ ModeVar

Predicate abstraction of event states.

e.g.

  • Button.registered,
  • Activity.foreground,
  • API.called

11 of 46

PEG: Transitions

0

1

2

initialization

sub-graph

finalization

sub-graph

REC.onClick

STOP.onClick

onCreate

onResume

12 of 46

PEG: Labels

0

1

2

initialization

sub-graph

finalization

sub-graph

REC.onClick

Start-Recording

STOP.onClick

Stop-Recording

onCreate

onResume

startService

13 of 46

Sound Recorder: The Good Part

0

1

2

initialization

sub-graph

finalization

sub-graph

REC.onClick

Start-Recording

STOP.onClick

Stop-Recording

onCreate

onResume

startService

14 of 46

The Complete PEG

0

6

5

4

1

2

3

initialization

Recorder Activity

finalization

finalization

Recorder Service

REC.onClick

Start-Recording

STOP.onClick

Stop-Recording

onCreate

onStart

onCreate

Timer.run

Stop-Recording

Timer.run

Start-Recording

onResume

startService

15 of 46

PEG: Context of the Benign Use

0

6

5

4

1

2

3

initialization

Recorder Activity

finalization

finalization

Recorder Service

REC.onClick

Start-Recording

16 of 46

PEG: Context of the Malicious Use

0

6

5

4

1

2

3

initialization

Recorder Activity

finalization

finalization

Recorder Service

Timer.run

Start-Recording

onResume

startService

17 of 46

Formal Specification

"The recording can only be started by clicking the REC button, and it will be stopped when the user clicks the STOP button."

0

1

2

...

...

18 of 46

Approach Overview

Abstraction

Phase

Verification

Phase

Apps

Permission Event Graph

Conformance or counter- examples

Policies

19 of 46

Case Study: Geotag

"Mark location of your photos"

20 of 46

Case Study: Geotag

"Mark location of your photos"

21 of 46

Case Study: Geotag

"Mark location of your photos"

22 of 46

Case Study: SMS Replicator Secret

A spyware that secretly forwards every SMS to another number.

23 of 46

Case Study: SMS Replicator Secret

A spyware that secretly forwards every SMS to another number.

24 of 46

LIFE PEG

Abstraction

Phase

Verification

Phase

Apps

Permission Event Graph

Conformance or counter- examples

Policies

OF

25 of 46

Abstraction

Abstraction

Phase

Apps

Permission Event Graph

26 of 46

Abstraction: The Android Trinity

Event System

Sys. Libraries

Application

Application Code

System Code

27 of 46

Abstraction: The Android Trinity

Event System

Sys. Libraries

Application

States

Call event handler

Application Code

System Code

28 of 46

Abstraction: The Android Trinity

Event System

Sys. Libraries

Application

States

Call event handler

Call API

Application Code

System Code

29 of 46

Abstraction: The Android Trinity

Event System

Sys. Libraries

Application

States

Call event handler

Call API

Register handler

Application Code

System Code

30 of 46

Abstraction: The Algorithm

Summary-based

Abstract Interpretation on (P(aState) x P(API) x P(aState)).

Interprocedural CFG with a partially context sensitive points-to analysis

Summary-based

1200+ APIs

63 Kinds of Events

Event Semantics Engine

API Semantics Engine

Application Analyzer

SrcStates

(SrcStates, DstStates) Pairs

Event Handler

PEG

* Partial Valuation of the vars in ModeVar

* Partial Valuation of the vars in ModeVar

31 of 46

Verification: BFS for Conformance

Verification

Phase

Permission Event Graph

Conformance or counter- examples

Policies

32 of 46

Evaluation: PEG size (# states, CDF)

* 269 applications. Binary code sizes vary from 4KB to 6MB

LOG scale

CDF

# of States

33 of 46

Evaluation: Abstraction Time (CDF)

Sec

CDF

34 of 46

Evaluation: Verification Time (CDF)

* Always terminate within 3.6 hours

LOG scale

Sec

CDF

35 of 46

Conclusion

  • Permission event graph: event-dependencies and their API/permission-level behaviors

  • Contextual policies based on event sequences enable the detection and analysis of complex malicious behaviors (user-oriented security)

  • Enriches the set of detection techniques used by security analysts

36 of 46

Questions ?

Kevin Chen <kevinchn@cs.berkeley.edu>

37 of 46

Backup Slides

38 of 46

Backup Slides

A

39 of 46

Native Code

  • Known
    • The API Semantics Engine

  • Unknown
    • Do NOT support

40 of 46

Rewriting

  • Barriers for static analysis:

  • Solutions:
    • Insert runtime checks
    • More in the paper

Unresolved Reflection

Unresolved Dynamic dispatching

41 of 46

API Frequency in 95,000 Apps

42 of 46

Specification Constructs

Information Type

Example

System status variables

(Mode variables)

STOPButton.registered,

MyActivity.inBackground

System APIs

and their arguments

android.location.Location: double getLatitude(),

"content://com.android.contacts/contacts"

Permissions

"android.permission.INTERNET"

43 of 46

Specification Checker Interface

Bounded BFS for conformance analysis

Write the specification FSM using the following interfaces:

public int getStateId();

public void restoreFromStateId(int id);

public ListenerResult stateListener(ModelState state);

public ListenerResult actionListener(EventModality action);

public ListenerResult methodListener(PathItemMethod method);

44 of 46

45 of 46

Evaluation

46 of 46

Applications

  • Usage scenarios:
    • Extra semantics-based filter for malware screening
    • Diagnostic tool for security analysts
    • Fine-grained information about permission use for the user