back to the whiteboard: a principled approach for the ...fabio pagani and davide balzarotti created...

47
Back to the Whiteboard: a Principled Approach for the Assessment and Design of Memory Forensic Techniques Fabio Pagani and Davide Balzarotti Usenix Security ’19

Upload: others

Post on 12-Aug-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Back to the Whiteboard: a Principled Approach for theAssessment and Design of Memory Forensic Techniques

Fabio Pagani and Davide Balzarotti

Usenix Security ’19

Page 2: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Memory Forensics - Introduction

InfectedMachine

MemoryDump

Analysis Evidence

1

Page 3: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Memory Forensics - Introduction

InfectedMachine

MemoryDump

Analysis Evidence

1

Page 4: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Memory Forensics - Introduction

InfectedMachine

MemoryDump

Analysis

Evidence

1

Page 5: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Memory Forensics - Introduction

InfectedMachine

MemoryDump

Analysis Evidence

1

Page 6: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Memory Forensics - Introduction

InfectedMachine

MemoryDump

Analysis Evidence

1

Page 7: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Memory Forensics - Analysis

Extract the following information:• List processes, kernel modules• Open files, memory mappings, sockets..• System information: routing table, kernel logs..

... and much more: Volatility (the most used memory forensicframework) has more than 100 plugins for Windows!

2

Page 8: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Memory Forensics - Analysis

Extract the following information:• List processes, kernel modules• Open files, memory mappings, sockets..• System information: routing table, kernel logs..

... and much more: Volatility (the most used memory forensicframework) has more than 100 plugins for Windows!

2

Page 9: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Memory Forensics - Listing Processes

task_struct

init_task

task_struct task_struct

nextprev

tasks

nextprev

tasksnextprev

tasks……

pid_hash

linux_pidhashtable

3

Page 10: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Memory Forensics - Listing Processes

task_struct

init_task

task_struct task_struct

nextprev

tasksnextprev

tasks

nextprev

tasks……

pid_hash

linux_pidhashtable

3

Page 11: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Memory Forensics - Listing Processes

task_struct

init_task

task_struct task_struct

nextprev

tasksnextprev

tasksnextprev

tasks

……

pid_hash

linux_pidhashtable

3

Page 12: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Memory Forensics - Listing Processes

task_struct

init_task

task_struct task_structlinux_pslist

nextprev

tasksnextprev

tasksnextprev

tasks……

pid_hash

linux_pidhashtable

3

Page 13: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Memory Forensics - Listing Processes

task_struct

init_task

task_struct task_structlinux_pslist

nextprev

tasksnextprev

tasksnextprev

tasks……

pid_hash

linux_pidhashtable 3

Page 14: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Motivations

Forensic analyses are manually created by humans.

• Are there other techniques to list processes?Linux kernel 4.19: ~6000 structures with ~40000 fields

• How can we compare them?Shortest one? Most stable across different kernels?

4

Page 15: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Motivations

Forensic analyses are manually created by humans.

• Are there other techniques to list processes?Linux kernel 4.19: ~6000 structures with ~40000 fields

• How can we compare them?Shortest one? Most stable across different kernels?

4

Page 16: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Motivations

Forensic analyses are manually created by humans.

• Are there other techniques to list processes?Linux kernel 4.19: ~6000 structures with ~40000 fields

• How can we compare them?Shortest one? Most stable across different kernels?

4

Page 17: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Contributions

Build a graph ofkernel structures

Define metrics toevaluate analyses

1

24

2

8 11

5 24

5

Study analyses as pathson the graph

task_struct

task_struct task_struct

task_struct

init_task

5

Page 18: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Contributions

Build a graph ofkernel structures

Define metrics toevaluate analyses

1

24

2

8 11

5 24

5

Study analyses as pathson the graph

task_struct

task_struct task_struct

task_struct

init_task

5

Page 19: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Contributions

Build a graph ofkernel structures

Define metrics toevaluate analyses

1

24

2

8 11

5 24

5

Study analyses as pathson the graph

task_struct

task_struct task_struct

task_struct

init_task

5

Page 20: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Kernel Graph - Creation

worklist← kernel global variables;while worklist ̸= ∅ do

s← worklist.pop();new_structs← Explore(s);worklist.push(new_structs);

end while

ChallengeKernel “abstract data types”

6

Page 21: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Kernel Graph - Creation

worklist← kernel global variables;while worklist ̸= ∅ do

s← worklist.pop();new_structs← Explore(s);worklist.push(new_structs);

end while

ChallengeKernel “abstract data types”

6

Page 22: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Kernel Graph - ADT Challenge

task_struct task_struct task_struct

list_headtasks

list_headtasks

list_headtasks

……

7

Page 23: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Kernel Graph - ADT Challenge

task_struct task_struct task_struct

list_headtasks

list_headtasks

list_headtasks

……

list_headchildren

list_headchildren

list_headchildren

7

Page 24: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Kernel Graph - ADT Challenge

task_struct task_struct task_struct

list_headtasks

list_headtasks

list_headtasks

……

list_headchildren

list_headsiblings

list_headsiblings

7

Page 25: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Kernel Graph - ADT Challenge

Solved with a Clang plugin that analyzes the kernel AST

list_add(&p->tasks, &init_task.tasks);list_add(&p->sibling, &p->children);

struct task_struct.tasks -> struct task_struct.tasksstruct task_struct.children -> struct.task_struct.siblings

8

Page 26: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

The Graph

• 100k Structures(Nodes)

• 840k Pointers(Edges)

9

Page 27: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Metrics - Rationale

Metrics should capture different aspects of memory forensics:

• Non-atomic memory acquisition (i.e. kernel driver)

• Layout of kernel structures changes across different kernelversions and configurations

• Attackers can modify kernel structures

10

Page 28: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Metrics - Rationale

Metrics should capture different aspects of memory forensics:

• Non-atomic memory acquisition (i.e. kernel driver)

• Layout of kernel structures changes across different kernelversions and configurations

• Attackers can modify kernel structures

10

Page 29: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Metrics - Rationale

Metrics should capture different aspects of memory forensics:

• Non-atomic memory acquisition (i.e. kernel driver)

• Layout of kernel structures changes across different kernelversions and configurations

• Attackers can modify kernel structures

10

Page 30: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Metrics - Rationale

Metrics should capture different aspects of memory forensics:

• Non-atomic memory acquisition (i.e. kernel driver)

• Layout of kernel structures changes across different kernelversions and configurations

• Attackers can modify kernel structures

10

Page 31: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Proposed Metrics

• Atomicity• Stability• Consistency• Generality• Reliability

11

Page 32: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Proposed Metrics

• Atomicity• Stability• Consistency• Generality• Reliability

11

Page 33: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Metrics

Atomicity: distance in memory between two connected structures

0x10

0x40

0x50

0x20

0x60

0x50 0x90

0x70

0x10

12

Page 34: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Metrics

Stability: how long an edge remains stable in a running machine• 25 snapshots at [0s, 1s, 5s, ..., 3h]

1s

10s

15s

30s

12

Page 35: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Metrics

Consistency: Atomicity + Stability

7

3

3

3

A

B

12

Page 36: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Evaluation of Current Analyses

Volatility Plugin

#Nodes

Stability(s) Fast Slow

linux_arp

13 12,000 3 3

linux_check_creds

248 2 3 3

linux_check_modules

151 700 3 3

linux_check_tty

13 30 3 3

linux_find_file

14955 0 7 7

linux_ifconfig

12 12,000 3 3

linux_lsmod

12 700 3 3

linux_lsof

821 0 7 7

linux_mount

495 10 3 7

linux_pidhashtable

469 30 3 7

linux_proc_maps

4722 0 7 7

linux_pslist

124 30 3 3

13

Page 37: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Evaluation of Current Analyses

Volatility Plugin #Nodes

Stability(s) Fast Slow

linux_arp 13

12,000 3 3

linux_check_creds 248

2 3 3

linux_check_modules 151

700 3 3

linux_check_tty 13

30 3 3

linux_find_file 14955

0 7 7

linux_ifconfig 12

12,000 3 3

linux_lsmod 12

700 3 3

linux_lsof 821

0 7 7

linux_mount 495

10 3 7

linux_pidhashtable 469

30 3 7

linux_proc_maps 4722

0 7 7

linux_pslist 124

30 3 3

96% of the nodes→ giant strongly connected component(contains on average 53% of total nodes)

13

Page 38: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Evaluation of Current Analyses

Volatility Plugin #Nodes

Stability(s)

Fast Slow

linux_arp 13 12,000

3 3

linux_check_creds 248 2

3 3

linux_check_modules 151 700

3 3

linux_check_tty 13 30

3 3

linux_find_file 14955 0

7 7

linux_ifconfig 12 12,000

3 3

linux_lsmod 12 700

3 3

linux_lsof 821 0

7 7

linux_mount 495 10

3 7

linux_pidhashtable 469 30

3 7

linux_proc_maps 4722 0

7 7

linux_pslist 124 30

3 3

Stability: 3 paths never changed in over 3 hours11 paths changed in less than 1 minute

13

Page 39: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Evaluation of Current Analyses

Volatility Plugin #Nodes

Stability Consistency(s) Fast Slow

linux_arp 13 12,000 3 3linux_check_creds 248 2 3 3linux_check_modules 151 700 3 3linux_check_tty 13 30 3 3linux_find_file 14955 0 7 7linux_ifconfig 12 12,000 3 3linux_lsmod 12 700 3 3linux_lsof 821 0 7 7linux_mount 495 10 3 7linux_pidhashtable 469 30 3 7linux_proc_maps 4722 0 7 7linux_pslist 124 30 3 3

Consistency: 5 inconsistent plugins when fast acquisition7 inconsistent plugins when slow acquisition

13

Page 40: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Finding New Ways to List Processes

Much harder than expected!

• Hundreds of millions of paths when considering the shortest paths fromevery root node to every task_struct

• Not every path represent an heuristics, because heuristics must be generatedby an algorithm

To limit the path explosion problem:

• Removed every root node that is not connected to every task_struct• Remove edges used by known techniques (i.e. tasks field)• Remove similar edges (parallel edges with same weights)• Merge similar paths into templates (struct type + remove adjacent same typenodes)

Resulted in 4000 path templates!

14

Page 41: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Finding New Ways to List Processes

Much harder than expected!

• Hundreds of millions of paths when considering the shortest paths fromevery root node to every task_struct

• Not every path represent an heuristics, because heuristics must be generatedby an algorithm

To limit the path explosion problem:

• Removed every root node that is not connected to every task_struct• Remove edges used by known techniques (i.e. tasks field)• Remove similar edges (parallel edges with same weights)• Merge similar paths into templates (struct type + remove adjacent same typenodes)

Resulted in 4000 path templates! 14

Page 42: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Kernel Graph - New Heuristics Results

Category Root Node #Nodes

#task_struct Stability Generality Consistency

cgroup css_set_table 172 156 10.00 29/85 7

cgrp_dfl_root 186 156 10.00 29/85 3

memory/fs dentry_hash 58383 23 0.00 36/85 7

inode_hash 14999 23 1.00 36/85 7

workers wq_workqueues 427 69 200.00 39/85 3

All implemented as Volatility plugins!

15

Page 43: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

A Principled Approach to Memory Forensics

Forensics analyses can be extracted and evaluated in aprincipled way!

• Kernel graph to model kernel structures• Set of metrics to capture memory forensics aspects• Experiments to study current and future techniques

16

Page 44: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

A Principled Approach to Memory Forensics

Forensics analyses can be extracted and evaluated in aprincipled way!

• Kernel graph to model kernel structures• Set of metrics to capture memory forensics aspects• Experiments to study current and future techniques

16

Page 45: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Future Work

Our framework enables more future research!

https://github.com/pagabuc/kernographer

17

Page 46: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Questions?Twitter: @pagabuc

Email: [email protected]

17

Page 47: Back to the Whiteboard: a Principled Approach for the ...Fabio Pagani and Davide Balzarotti Created Date: 8/16/2019 10:36:35 AM

Kernel Graph - New Heuristics Templates

Examples

struct hlist_head [128] - struct css_set - structtask_struct

struct hlist_bl_head *- struct dentry - struct inode -struct vm_area_struct - struct mm_struct - structtask_struct

18