• No results found

Betriebssysteme KU Security

N/A
N/A
Protected

Academic year: 2021

Share "Betriebssysteme KU Security"

Copied!
66
0
0

Loading.... (view fulltext now)

Full text

(1)

www.iaik.tugraz.at

Betriebssysteme KU Security

IAIK

Graz University of Technology

(2)

www.iaik.tugraz.at

1. Drivers

2. Security - The simple stuff

3. Code injection attacks

4. Side-channel attacks

(3)

www.iaik.tugraz.at

1. Drivers

2. Security - The simple stuff

3. Code injection attacks

4. Side-channel attacks

(4)

www.iaik.tugraz.at

Driver Basics

Hardware has a defined interface → reference manual

x86: I/O address space via outb,inb,...

ARM: Memory mapped in physical address space

Let’s have a look at qemu’s mtree command

(5)

www.iaik.tugraz.at

Mouse driver (x86)

Send init sequence using inb and outb

Service Mouse IRQs (depending on config)

(6)

www.iaik.tugraz.at

MMC driver (ARM)

Send init sequence using memory mapped registers Commands: Read/Write

Send and retrieve data

(7)

www.iaik.tugraz.at

Sounds simple?

Writing device drivers is about implementing an interface

Reference manual → what the hardware does

Reference manual → what the hardware expects the OS to do

Large drivers (GPU) can get very complex

(8)

www.iaik.tugraz.at

1. Drivers

2. Security - The simple stuff

3. Code injection attacks

4. Side-channel attacks

(9)

www.iaik.tugraz.at

Multi user environments

Usermanagement File access rights

→ Extend the existing file system

(10)

www.iaik.tugraz.at

DOS attacks

Denial of service → using an unfairly amount of resources to block the whole system

Improve the Scheduler (priorities) Scheduler for I/O activity?

Out of memory handling?

ulimit as an operating system service

(11)

www.iaik.tugraz.at

DOS attacks

Denial of service → using an unfairly amount of resources to block the whole system

Improve the Scheduler (priorities) Scheduler for I/O activity?

Out of memory handling?

ulimit as an operating system service

(12)

www.iaik.tugraz.at

DOS attacks

Denial of service → using an unfairly amount of resources to block the whole system

Improve the Scheduler (priorities) Scheduler for I/O activity?

Out of memory handling?

ulimit as an operating system service

(13)

www.iaik.tugraz.at

Private exec

Modern browsers have a “private browsing” mode Shouldn’t that be a service of the operating system?

priv_exec → execute a program in a sandbox

→ No accesses to real file system, ...

→ No interaction with any hardware

→ Maybe a limited set of syscalls?

(14)

www.iaik.tugraz.at

Private exec

Modern browsers have a “private browsing” mode Shouldn’t that be a service of the operating system?

priv_exec → execute a program in a sandbox

→ No accesses to real file system, ...

→ No interaction with any hardware

→ Maybe a limited set of syscalls?

(15)

www.iaik.tugraz.at

1. Drivers

2. Security - The simple stuff

3. Code injection attacks

4. Side-channel attacks

(16)

www.iaik.tugraz.at

Code injection attack

Idea: Use buffer overflow to inject binary code

int f() {

char b[128];

gets(b);

}

How does the stack look now?

(17)

www.iaik.tugraz.at

Code injection attack

Stack:

0xfc return address

0xf8 ebp from calling function

0xf4 b[124],b[125],b[126],b[127]

... ...

(18)

www.iaik.tugraz.at

Code injection attack

→ Input string has 128 bytes + attack payload:

"\0\1\2\3" // the ebp i choose

"\xe0\x05\x00\x08" // 080005e0 - execv

"\4\5\6\7" // argument: char* path

"\8\9\10\11" // argument: char** argv

(19)

www.iaik.tugraz.at

Countermeasures against code injection

NX-bit in page table → prevent execution on a page Use this bit for stack pages:

PageFault if eip points on a stack page

Think of the attack we just saw: did we execute code on the stack?

→ Return-to-libc/Return-Oriented-Programming (ROP) still possible! Any ideas?

Randomize the position of (shared) library code!

(20)

www.iaik.tugraz.at

Countermeasures against code injection

NX-bit in page table → prevent execution on a page Use this bit for stack pages:

PageFault if eip points on a stack page Think of the attack we just saw:

did we execute code on the stack?

→ Return-to-libc/Return-Oriented-Programming (ROP) still possible! Any ideas?

Randomize the position of (shared) library code!

(21)

www.iaik.tugraz.at

Countermeasures against code injection

NX-bit in page table → prevent execution on a page Use this bit for stack pages:

PageFault if eip points on a stack page Think of the attack we just saw:

did we execute code on the stack?

→ Return-to-libc/Return-Oriented-Programming (ROP) still possible! Any ideas?

Randomize the position of (shared) library code!

(22)

www.iaik.tugraz.at

Countermeasures against code injection

NX-bit in page table → prevent execution on a page Use this bit for stack pages:

PageFault if eip points on a stack page Think of the attack we just saw:

did we execute code on the stack?

→ Return-to-libc/Return-Oriented-Programming (ROP) still possible! Any ideas?

Randomize the position of (shared) library code!

(23)

www.iaik.tugraz.at

Countermeasures against code injection

Stack canaries → detect stack corruption Kernel stops execution if stack is corrupted

→ check during context switch

Who protects the kernel against code injection

attacks?

(24)

www.iaik.tugraz.at

Countermeasures against code injection

Stack canaries → detect stack corruption Kernel stops execution if stack is corrupted

→ check during context switch

Who protects the kernel against code injection

attacks?

(25)

www.iaik.tugraz.at

Syscall-based countermeasures

If injection only changes arguments passed to __syscall :

Randomize syscall numbers

Randomize syscall argument order Blacklist syscalls

Whitelist syscalls

...

(26)

www.iaik.tugraz.at

NX-Bit

Execution Prevention for stack pages... what more?

Binary might prefer non-writeable code pages and non-executable data pages

Is there any reason to have a page writeable and executable? (apart from self-modifying code)

W⊕X policy → no page writeable and executable at the same time (except if the binary wants

self-modifying code)

(27)

www.iaik.tugraz.at

NX-Bit

Execution Prevention for stack pages... what more?

Binary might prefer non-writeable code pages and non-executable data pages

Is there any reason to have a page writeable and executable? (apart from self-modifying code)

W⊕X policy → no page writeable and executable at the same time (except if the binary wants

self-modifying code)

(28)

www.iaik.tugraz.at

NX-Bit

Execution Prevention for stack pages... what more?

Binary might prefer non-writeable code pages and non-executable data pages

Is there any reason to have a page writeable and executable? (apart from self-modifying code)

W⊕X policy → no page writeable and executable at the same time (except if the binary wants

self-modifying code)

(29)

www.iaik.tugraz.at

NX-Bit

Execution Prevention for stack pages... what more?

Binary might prefer non-writeable code pages and non-executable data pages

Is there any reason to have a page writeable and executable? (apart from self-modifying code)

W⊕X policy → no page writeable and executable at the same time

(except if the binary wants

self-modifying code)

(30)

www.iaik.tugraz.at

NX-Bit

Execution Prevention for stack pages... what more?

Binary might prefer non-writeable code pages and non-executable data pages

Is there any reason to have a page writeable and executable? (apart from self-modifying code)

W⊕X policy → no page writeable and executable at the same time (except if the binary wants

self-modifying code)

(31)

www.iaik.tugraz.at

Code injection in kernel

What if you can only write a very small amount of data in the kernel?

Where to jump?

We should prevent the kernel from being able to execute userspace code

Now think of Return-to-libc/ROP...

What if we can set ebp/esp to point into userspace?

(32)

www.iaik.tugraz.at

Code injection in kernel

What if you can only write a very small amount of data in the kernel?

Where to jump?

We should prevent the kernel from being able to execute userspace code

Now think of Return-to-libc/ROP...

What if we can set ebp/esp to point into userspace?

(33)

www.iaik.tugraz.at

Code injection in kernel

What if you can only write a very small amount of data in the kernel?

Where to jump?

We should prevent the kernel from being able to execute userspace code

Now think of Return-to-libc/ROP...

What if we can set ebp/esp to point into userspace?

(34)

www.iaik.tugraz.at

Code injection in kernel

Maybe the kernel should not have userspace data mapped?

→ We remove the userspace mapping from kernel Linux did that too, but they are still vulnerable... why?

→ Identity mapping breaks everything!

(35)

www.iaik.tugraz.at

Code injection in kernel

Maybe the kernel should not have userspace data mapped?

→ We remove the userspace mapping from kernel Linux did that too, but they are still vulnerable... why?

→ Identity mapping breaks everything!

(36)

www.iaik.tugraz.at

Code injection in kernel

Maybe the kernel should not have userspace data mapped?

→ We remove the userspace mapping from kernel Linux did that too, but they are still vulnerable... why?

→ Identity mapping breaks everything!

(37)

www.iaik.tugraz.at

1. Drivers

2. Security - The simple stuff

3. Code injection attacks

4. Side-channel attacks

(38)

www.iaik.tugraz.at

Cache Attacks

Cache is faster than Memory

That’s the problem.

(39)

www.iaik.tugraz.at

Cache Attacks

Cache is faster than Memory

That’s the problem.

(40)

www.iaik.tugraz.at

Cache Attacks - Modern Caches

Shared in Memory → Shared in Cache

clflush flushes data from cache

Shared in Cache → I can flush shared data

Shared libraries → different process execute on

physically shared memory

(41)

www.iaik.tugraz.at

Cache Attacks - Modern Caches

Shared in Memory → Shared in Cache clflush flushes data from cache

Shared in Cache → I can flush shared data

Shared libraries → different process execute on

physically shared memory

(42)

www.iaik.tugraz.at

Cache Attacks - Flush+Reload

After loading a shared library, attack as follows:

1. clflush interesting function code 2. Wait a bit

3. Check whether function was accessed

(43)

www.iaik.tugraz.at

Cache Attacks - Flush+Reload

RSA: Square+Multiply depending on secret key bits

→ 96.7% of the key bits after a single decryption

(44)

www.iaik.tugraz.at

Cache Attacks - without shared memory?

F+R requires shared memory → disable shared memory?

Prime+Probe works similar and does not require

shared memory

(45)

www.iaik.tugraz.at

Cache Attacks - without shared memory?

F+R requires shared memory → disable shared memory?

Prime+Probe works similar and does not require

shared memory

(46)

www.iaik.tugraz.at

Cache Attacks

Cache attack only possible by executing attacker’s code

I only start self-compiled programs.

Are we safe now?

Recent paper: The Spy in the Sandbox - Practical

Cache Attacks in Javascript

(47)

www.iaik.tugraz.at

Cache Attacks

Cache attack only possible by executing attacker’s code

I only start self-compiled programs.

Are we safe now?

Recent paper: The Spy in the Sandbox - Practical

Cache Attacks in Javascript

(48)

www.iaik.tugraz.at

Cache attack countermeasures

OS could flush cache during context switch

Maybe not the whole cache, but only parts of it User programs could tell the OS which parts they want to protect

And what about Hyperthreading? → disable it?

(49)

www.iaik.tugraz.at

Cache attack countermeasures

OS could flush cache during context switch Maybe not the whole cache, but only parts of it

User programs could tell the OS which parts they want to protect

And what about Hyperthreading? → disable it?

(50)

www.iaik.tugraz.at

Cache attack countermeasures

OS could flush cache during context switch Maybe not the whole cache, but only parts of it User programs could tell the OS which parts they want to protect

And what about Hyperthreading? → disable it?

(51)

www.iaik.tugraz.at

Cache attack countermeasures

OS could flush cache during context switch Maybe not the whole cache, but only parts of it User programs could tell the OS which parts they want to protect

And what about Hyperthreading?

→ disable it?

(52)

www.iaik.tugraz.at

Cache attack countermeasures

OS could flush cache during context switch Maybe not the whole cache, but only parts of it User programs could tell the OS which parts they want to protect

And what about Hyperthreading? → disable it?

(53)

www.iaik.tugraz.at

Copy-on-write attack

Let’s exploit copy-on-write!

...

Ummm..

How?

(54)

www.iaik.tugraz.at

Copy-on-write attack

Let’s exploit copy-on-write!

...

Ummm..

How?

(55)

www.iaik.tugraz.at

Copy-on-write attack

Let’s exploit copy-on-write!

...

Ummm..

How?

(56)

www.iaik.tugraz.at

Copy-on-write attack

Let’s exploit copy-on-write!

...

Ummm..

How?

(57)

www.iaik.tugraz.at

Copy-on-write attack

Regular write access vs. copy-on-write write access

Timing difference?

Yes! Enormous timing difference!

We get a true/false information whether our page was

twice in memory!

(58)

www.iaik.tugraz.at

Copy-on-write attack

Regular write access vs. copy-on-write write access Timing difference?

Yes! Enormous timing difference!

We get a true/false information whether our page was

twice in memory!

(59)

www.iaik.tugraz.at

Copy-on-write attack

Regular write access vs. copy-on-write write access Timing difference?

Yes! Enormous timing difference!

We get a true/false information whether our page was

twice in memory!

(60)

www.iaik.tugraz.at

Page Deduplication

Search Memory for identical pages Make them CoW!

Save lot’s of memory → save lot’s of money!

(61)

www.iaik.tugraz.at

Page Deduplication

Search Memory for identical pages Make them CoW!

Save lot’s of memory → save lot’s of money!

(62)

www.iaik.tugraz.at

Page Deduplication Attack

1. Fill a page with data

2. Wait

3. Measure write access time to the page 4.

5. High time → found it!

(63)

www.iaik.tugraz.at

Page Deduplication Attack

1. Fill a page with data 2. Wait

3. Measure write access time to the page 4.

5. High time → found it!

(64)

www.iaik.tugraz.at

Page Deduplication Attack

1. Fill a page with data 2. Wait

3. Measure write access time to the page 4.

5. High time → found it!

(65)

www.iaik.tugraz.at

Page Deduplication Attack - Countermeasures

1. Disable Page Deduplication?

2. Deduplicate only read-only pages?

3. Attack requires native code execution?

(66)

www.iaik.tugraz.at

EOF

Better ideas? We want to see them!

Have fun programming!

References

Related documents

Concept location facilitates maintenance tasks by guiding developers towards segments that implement concepts to maintain and reducing the number of methods to investigate

2) The overall performance of the virtual infrastruc- ture: The number of worker VMs must never exceed the threshold over which extra workers become an overhead. As more nodes are

[r]

Participate Develop Solution Knowledge Train Provide Ongoing Support Provide on-site support after transition to Florida PALM. Super

(Native fields in the north were dominated by a mixture of C 3 and C 4 species; Martin et al., 2014.) Furthermore, the shorter growing season in native sites was

The paper points towards the salience of analyses of social capital, metropolitan and provincial cities as well as labour market conditions on these processes.. In addition, it

We have seen many cases when huge amounts vertical bone was lost around crestal dental implants: after this event either a bone transplant became necessary or the

Can stack web page to the table is the option in the table maker for table jquery spreadsheet within a rectangular, grouping and even number of