CS-527 Software Security
Defense Mechanisms
- Asst. Prof. Mathias Payer
Department of Computer Science Purdue University TA: Kyriakos Ispoglou https://nebelwelt.net/teaching/17-527-SoftSec/
CS-527 Software Security Defense Mechanisms Asst. Prof. Mathias - - PowerPoint PPT Presentation
CS-527 Software Security Defense Mechanisms Asst. Prof. Mathias Payer Department of Computer Science Purdue University TA: Kyriakos Ispoglou https://nebelwelt.net/teaching/17-527-SoftSec/ Spring 2017 A model for Control-Flow Hijack attacks
Department of Computer Science Purdue University TA: Kyriakos Ispoglou https://nebelwelt.net/teaching/17-527-SoftSec/
Mathias Payer (Purdue University) CS-527 Software Security 2017 2 / 41
Widely-adopted defense mechanisms
1
2
3
4
5
6
7
Mathias Payer (Purdue University) CS-527 Software Security 2017 3 / 41
Widely-adopted defense mechanisms
Mathias Payer (Purdue University) CS-527 Software Security 2017 4 / 41
Widely-adopted defense mechanisms
Mathias Payer (Purdue University) CS-527 Software Security 2017 5 / 41
Data Execution Prevention
1
2
3
4
5
6
7
Mathias Payer (Purdue University) CS-527 Software Security 2017 6 / 41
Data Execution Prevention
Mathias Payer (Purdue University) CS-527 Software Security 2017 7 / 41
Data Execution Prevention
Mathias Payer (Purdue University) CS-527 Software Security 2017 8 / 41
Data Execution Prevention
8 16 24 31 15 7 23
4K memory page 10 32* 12 10 Linear address: page directory 32 bit PD entry CR3 *) 32 bits aligned to a 4-KByte boundary page table 32 bit PT entry
Mathias Payer (Purdue University) CS-527 Software Security 2017 9 / 41
Data Execution Prevention
Mathias Payer (Purdue University) CS-527 Software Security 2017 10 / 41
Data Execution Prevention
8 16 24 31 15 7 23
page-directory- pointer table Dir.Pointer entry Dir.Pointer entry Dir.Pointer entry Dir.Pointer entry page directory 64 bit PD entry Linear address: page table 64 bit PT entry 32* CR3 *) 32 bits aligned to a 32-Byte boundary 4K memory page 9 9 12
Mathias Payer (Purdue University) CS-527 Software Security 2017 11 / 41
Data Execution Prevention
Mathias Payer (Purdue University) CS-527 Software Security 2017 12 / 41
Data Execution Prevention
Mathias Payer (Purdue University) CS-527 Software Security 2017 13 / 41
Data Execution Prevention
Mathias Payer (Purdue University) CS-527 Software Security 2017 14 / 41
Data Execution Prevention
Mathias Payer (Purdue University) CS-527 Software Security 2017 15 / 41
Address Space Randomization
1
2
3
4
5
6
7
Mathias Payer (Purdue University) CS-527 Software Security 2017 16 / 41
Address Space Randomization
Mathias Payer (Purdue University) CS-527 Software Security 2017 17 / 41
Address Space Randomization
Mathias Payer (Purdue University) CS-527 Software Security 2017 18 / 41
Address Space Randomization
Mathias Payer (Purdue University) CS-527 Software Security 2017 19 / 41
Address Space Randomization
Mathias Payer (Purdue University) CS-527 Software Security 2017 20 / 41
Address Space Randomization
Mathias Payer (Purdue University) CS-527 Software Security 2017 21 / 41
Stack Canaries
1
2
3
4
5
6
7
Mathias Payer (Purdue University) CS-527 Software Security 2017 22 / 41
Stack Canaries
Mathias Payer (Purdue University) CS-527 Software Security 2017 23 / 41
Stack Canaries
Mathias Payer (Purdue University) CS-527 Software Security 2017 24 / 41
Stack Canaries
1 char
2
3
4
5 } 6 7 i n t
8
9
10
11 } 1 push
2 mov
3 sub
4 mov
5 mov
6 l e a
7 mov
8 mov
9 c a l l q
10 movzbl −0xf(%rbp ) ,%eax 11 leaveq 12 retq Mathias Payer (Purdue University) CS-527 Software Security 2017 25 / 41
Stack Canaries
1 push %rbp ; mov %rsp ,%rbp 2 sub
3 mov
4 5 6 7 mov
8 l e a
9 mov
10 mov
11 c a l l q
12 movzbl −0xf(%rbp ) ,%eax 13 14 15 16 17 leaveq ;
1 push
2 sub
3 mov
4 mov
5 mov
6 xor
7 mov
8 l e a
9 mov
10 mov
11 c a l l q
12 movzbl −0x1f(%rbp ) ,%eax 13 mov
14 xor
15 j e
16 c a l l q <
17 leaveq ;
Mathias Payer (Purdue University) CS-527 Software Security 2017 26 / 41
Safe Exception Handling
1
2
3
4
5
6
7
Mathias Payer (Purdue University) CS-527 Software Security 2017 27 / 41
Safe Exception Handling
1 double
2
3
4
5 } 6 . . . 7 t r y
8
9 } catch
10
11 }
Mathias Payer (Purdue University) CS-527 Software Security 2017 28 / 41
Safe Exception Handling
Mathias Payer (Purdue University) CS-527 Software Security 2017 29 / 41
Safe Exception Handling
Mathias Payer (Purdue University) CS-527 Software Security 2017 30 / 41
Safe Exception Handling
Mathias Payer (Purdue University) CS-527 Software Security 2017 31 / 41
Safe Exception Handling
1 typedef
2
3
4 } EXCEPTION REGISTRATION RECORD , 5
Mathias Payer (Purdue University) CS-527 Software Security 2017 32 / 41
Safe Exception Handling
Mathias Payer (Purdue University) CS-527 Software Security 2017 33 / 41
Safe Exception Handling
1James Oakley and Sergey Bratus, Exploiting the Hard-Working DWARF,
Mathias Payer (Purdue University) CS-527 Software Security 2017 34 / 41
Fortify source
1
2
3
4
5
6
7
Mathias Payer (Purdue University) CS-527 Software Security 2017 35 / 41
Fortify source
Mathias Payer (Purdue University) CS-527 Software Security 2017 36 / 41
Fortify source
1
2
3
Mathias Payer (Purdue University) CS-527 Software Security 2017 37 / 41
Fortify source
1
2
3
4
Mathias Payer (Purdue University) CS-527 Software Security 2017 38 / 41
Summary and conclusion
1
2
3
4
5
6
7
Mathias Payer (Purdue University) CS-527 Software Security 2017 39 / 41
Summary and conclusion
Mathias Payer (Purdue University) CS-527 Software Security 2017 40 / 41
Summary and conclusion
Mathias Payer (Purdue University) CS-527 Software Security 2017 41 / 41