countering kernel rootkits with lightweight hook protection

38
COUNTERING KERNEL ROOTKITS WITH LIGHTWEIGHT HOOK PROTECTION Presented by: Ruaa Abdulrahman CAP 6135 .. Malware and Software Vulnerability Analysis April 08, 2013 1

Upload: chars

Post on 24-Feb-2016

33 views

Category:

Documents


0 download

DESCRIPTION

Countering Kernel Rootkits with Lightweight Hook Protection. Presented by: Ruaa Abdulrahman CAP 6135 .. Malware and Software Vulnerability Analysis April 08, 2013. Information. Authors: North Carolina State University Zhi Wang Xuxian Jiang Peng Ning Microsoft Research - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Countering Kernel  Rootkits  with Lightweight Hook Protection

1

COUNTERING KERNEL ROOTKITS

WITH LIGHTWEIGHT HOOK PROTECTION

Presented by: Ruaa Abdulrahman

CAP 6135 .. Malware and Software Vulnerability Analysis

April 08, 2013

Page 2: Countering Kernel  Rootkits  with Lightweight Hook Protection

2

INFORMATION Authors:

North Carolina State University Zhi Wang Xuxian Jiang Peng Ning

Microsoft Research Weidong Cui

Published at: CCS '09 Proceedings of the 16th ACM

conference on Computer and communications security, Chicago, Illinois, USA, 2009

Sponsored by: NSF 0852131, 0855297, 0855036, and 0910767

Page 3: Countering Kernel  Rootkits  with Lightweight Hook Protection

3

KERNEL ROOTKITS

it’s one of the most stealthy computer malware and poses significant security threats.

Why ?

its directly subverting OS kernel, not just hide their response, but also tamper with OS functionalities to launch various attack like:

- opining system backdoors.- Stealing privet information.- Escalating privileges of malicious processes.- Disabling defense mechanisms.

Page 4: Countering Kernel  Rootkits  with Lightweight Hook Protection

4

KERNEL ROOTKITS

Because all of that threats : we need ?

Preservation of kernel code integrity.Safeguard relevant kernel control data which

are the return addresses and function pointers.

In this paper they focused on function pointers and called it

“kernel hook”.

Equally important

Page 5: Countering Kernel  Rootkits  with Lightweight Hook Protection

5

KERNEL HOOKkernel hook == Function Pointer

Intuitively, to safeguard kernel hooks , we need to monitor and verify any write access to the memory page with kernel hook .

This approach has two conditions to work well:1- There existing a very limited number of

kernel hooks for protection.2-These hooks are not co- located together with

frequently modified memory data.

Page 6: Countering Kernel  Rootkits  with Lightweight Hook Protection

6

KERNEL HOOK Unfortunately ,these two conditions do not

work with OS like Linux and windows because:- These OS may have thousands of kernel hook

“not limited number” - and it can be widely scattered across the kernel

space .

The solution for the above challenges::

”Hooksafe”.

Page 7: Countering Kernel  Rootkits  with Lightweight Hook Protection

7

PROBLEM OVERVIEW Kernel rootkit : two types:

- Kernel Object Hooking (KOH).- Dynamic Kernel Object Manipulation (DKOM)

They focused (KOH) because it is more common attack.

KOH can hijack code hook or data hook.

hijack contro

l

data

subvert contro

l

data

Page 8: Countering Kernel  Rootkits  with Lightweight Hook Protection

8

PROBLEM OVERVIEW Hijacking a kernel code hook: is easier to protect because its require

modifying the kernel text section which is - usually static and - can be marked as read-only.

Kernel data hooks are function pointers and usually reside in two main kernel memory regions:

- Preallocated memory areas including the data sections.

- The dynamically allocated areas such as Kernel heap.

Page 9: Countering Kernel  Rootkits  with Lightweight Hook Protection

9

PROBLEM OVERVIEW Kernel data hooks are function pointers

and usually reside in two main kernel memory regions:

- Preallocated memory areas including the data sections.

- The dynamically allocated areas such as Kernel heap.

The aim is to protect the kernal hooks in both memorie regions to be

tampered by a Kernal rootKits.

Page 10: Countering Kernel  Rootkits  with Lightweight Hook Protection

10

PROBLEM OVERVIEW Protection granularity gap Challenge

Efficient Hook protection requires byte - level granularity.

BUT .. Hardware only provides page level protection

AND .. Since kernal hooks are scattered across the kernal space and often co-located with other dynamic kernal data,

SO .. we can not simply use hardware-based page level protection.

Page 11: Countering Kernel  Rootkits  with Lightweight Hook Protection

11

PROBLEM OVERVIEW

Experiment ..

- They analyzed a typical Ubuntu 8.04 server using a whole emulator called QEMU.

- They used 5881 Linux Kernal Hooks. - They found that these Kernal hooks are

scattered across 41 Pages and some of them located in dynamic kernal heap.

Page 12: Countering Kernel  Rootkits  with Lightweight Hook Protection

12

PROBLEM OVERVIEW

Page 13: Countering Kernel  Rootkits  with Lightweight Hook Protection

13

PROBLEM OVERVIEW

What are Pages?

- Non-continuous memory blocks

- Creates a mapping between a physical address and a virtual ones

- Provides virtual RAM

Page 14: Countering Kernel  Rootkits  with Lightweight Hook Protection

14

HOOKSAFEo Hooksafe is a hypervisor-based

lightweight system that able to efficiently protect thousands of kernel hooks in a guest OS from being hijacked

o “In computing, a hypervisor, also called virtual machine monitor (VMM), is one of many virtualization techniques which allow multiple operating systems, termed guests, to run concurrently on a host computer, a feature called hardware virtualization.” Wikipedia

Page 15: Countering Kernel  Rootkits  with Lightweight Hook Protection

15

HOOKSAFE DESIGN Assumptions:

- A hypervisor will be used to monitor virtual machines

- A bootstrap like tboot exists to establish a static root of trust of the systemA hypervisor can be securely loaded Protect the kernel at boot time

- Runtime integrity of hypervisor is maintained

Page 16: Countering Kernel  Rootkits  with Lightweight Hook Protection

16

HOOKSAFE DESIGN In order to resolve the protection

granularity gap problem,

They Relocate kernel hooks to a dedicate page- aligned memory space.

Introduce thin hook indirection layer to regulate accesses to them with hardware based page level protection.

They created a shadow copy of the kernel hooks in a centralized location. Any attempt to modify the shadow copy will be trapped and verified by the underlying hypervisor .

Page 17: Countering Kernel  Rootkits  with Lightweight Hook Protection

17

HOOKSAFE DESIGN All read and Write accesses to protected

Kernal hooks are routed through the hook indirection layer.

Only hypervisor can write to the memory pages of protected kernel,

In read access they use piece of indirection code residing in the guest OS kernel memory to read corresponding shadow hook.

Page 18: Countering Kernel  Rootkits  with Lightweight Hook Protection

18

HOOKSAFE DESIGN Hooksafe achieves its functionality in two

steps:

1- Offline hook profiles

2- On line hook protector

Page 19: Countering Kernel  Rootkits  with Lightweight Hook Protection

19

OFFLINE HOOK PROFILES it is a component that profiles the guest

kernel execution and outputs a hook access profile for each protected hook.

Hook access profile will be used to enable transparent hook indirection.

Kernal instructions that read or write to a hook called Hook Access Points (HAPs).  

Page 20: Countering Kernel  Rootkits  with Lightweight Hook Protection

20

OFFLINE HOOK PROFILES

1- Static analysis performed on OS kernel

source code, Utilize known program

analysis technique to automatically collect hook access profile.

More complete, but less precise.

- For the Design .. There are two approaches:2- Dynamic analysis Doesn’t need OS kernel

source code, run the target system on

the top of an emulator and monitor every memory access to derive the hook access instruction.

Allow for recording precise runtime information, but less coverage

HookSafe chooses Precision (Dynamic) over Coverage (Static)

Page 21: Countering Kernel  Rootkits  with Lightweight Hook Protection

21

OFFLINE HOOK PROFILES- Implementation It is based on an open source whole system

emulator( QEMU). QEMU uses binary translation technique

which rewrites guest’s binary instruction. Then records executions of instructions that

read or write memories. If instruction accesses any kernel hook it is

recorded as HAP and the value. At the end, collected HAP instructions and

values will be compiled as corresponding hook access profile.

Page 22: Countering Kernel  Rootkits  with Lightweight Hook Protection

22

ONLINE HOOK PROTECTOR Its input is the Hook Access Profile.

Creates a shadow copy of all protected hooks

Instruments HAP instructions such that their accesses will be transparently redirected to the shadow copy.

Shadow copies are moved into a centralized location to be protected from unauthorized modifications and kernel rootkits. (i.e. page level protection).

Page 23: Countering Kernel  Rootkits  with Lightweight Hook Protection

23

ONLINE HOOK PROTECTOR- For the Design .. There are Three Processes :

Initialization:

1. Uses a short-lived kernel module (temporary) to create shadow copy of kernel hooks and load the code for indirection layer.

2. Use the online patching that provided by the hypervisor in order to instrument HAPs in guest kernel.

Page 24: Countering Kernel  Rootkits  with Lightweight Hook Protection

24

ONLINE HOOK PROTECTOR Run-Time Read/Write Indirection

Read Access: reads from the shadow hook copy and returns to HAP site.

Write Access: indirection layer issues hyper call and transfers control to hypervisor for validation check. Memory protection component validates write request and update shadow hook.

Page 25: Countering Kernel  Rootkits  with Lightweight Hook Protection

25

ONLINE HOOK PROTECTOR Run-Time Tracking of Dynamically

Allocated Hooks

Dynamically Allocated Hooks is embedded in Dynamic Kernel Object (i.e. heap).

If one such kernel object is being allocated, a hypercall will be issued to HookSafe to create a shadow copy of the hook

Another hypercall is triggered to remove the shadow copy when kernel object is released.

Page 26: Countering Kernel  Rootkits  with Lightweight Hook Protection

26

ONLINE HOOK PROTECTOR- Implementation It is developed based on Xen Hypervisor. Hypervisor replaces the HAP instruction at

runtime with jmp instruction to allow execution flow to trampoline code in Hook indirection layer.

Trampoline code collects runtime info which is used by hook redirector to determine exact kernel hook being accessed.

After hook redirector processes the actual read or write on shadow hook, trampoline executes HAP specific overwritten instruction, if any, before returning to original program.

Page 27: Countering Kernel  Rootkits  with Lightweight Hook Protection

27

ONLINE HOOK PROTECTOR

Page 28: Countering Kernel  Rootkits  with Lightweight Hook Protection

28

ONLINE HOOK PROTECTOR

Page 29: Countering Kernel  Rootkits  with Lightweight Hook Protection

29

MEMORY PROTECTION

In order to protect the guest kernel code and the in-guest memory used by hooksafe.

the hypervisor maintains an SPT for each guest, which regulate the translation directly from a guest virtual address to the host physical address.

Any update in the guest page table GPT in the guest kernel is trapped and propagated to the SPT shadow page table by the hypervisor.

Page 30: Countering Kernel  Rootkits  with Lightweight Hook Protection

30

EVALUATION In order to evaluate HookSafe’s effectiveness

in preventing real-world rootkits, They used the Xen Hypervisor (version 3.3.o) to protect more than 5900 kernel hooks in Ubuntu 8.04 Linux system.

There experiments with nine real-world rootkits show that Hooksafe can effectively defeat these nine rootkits attempt to hijack kernal hooks that are being protected.

It prevented all of nine rootkits from modifying protected hooks and hiding themselves.

This large scale protection is achieved with only 6% slow down in system performance.

Page 31: Countering Kernel  Rootkits  with Lightweight Hook Protection

31

EVALUATION

Page 32: Countering Kernel  Rootkits  with Lightweight Hook Protection

32

CONCLUSION HookSafe is a hypervisor-based lightweight

system that can protect thousands of kernel hooks from being hijacked by Kernel rootkits.

HookSafe overcomes a critical challenge of Protection Granularity Gap by introducing a thin hook indirection layer.

Experimental result with nine real-world rootkits show HookSafe is effective in defeating their hijacking attempts with only 6% performance overhead.

Page 33: Countering Kernel  Rootkits  with Lightweight Hook Protection

33

STRENGTHS Rootkit protection is performed without the

need of going to the source code (Dynamic Analysis)

Low overhead of 6% of runtime

Works with variable instruction length architecture (e.g. x86)

Perform byte equivalent protection by using page protection of the hypervisor.

Page 34: Countering Kernel  Rootkits  with Lightweight Hook Protection

34

WEAKNESS Doesn’t record what caused the rootkit

infection. It can detect, but not defend against future attempts.

When discrepancy is found it automatically assumes the original hook was compromised.

Memory usage for creating shadow copies

Page 35: Countering Kernel  Rootkits  with Lightweight Hook Protection

35

SUGGESTIONS Test HookSafe on Windows

Instead of checking discrepancy between hooks and their copy, check against a hash value to find out which is compromised

Incorporate static analysis or broader dynamic analysis (e.g. adaptive analysis)

Page 36: Countering Kernel  Rootkits  with Lightweight Hook Protection

36

REFERENCES1. Z. Wang, X. Jiang, W. Cui, and P. Ning,

“Countering kernel rootkits with lightweight hook protection”, Proceedings of the 16th ACM conference on Computer and communications security, Chicago, Illinois, USA, 2009, pp. 545 – 554

2. http://www.wikipedia.org

Page 37: Countering Kernel  Rootkits  with Lightweight Hook Protection

37

Page 38: Countering Kernel  Rootkits  with Lightweight Hook Protection

38

QUESTIONS