-
CSE543 - Introduction to Computer and Network Security Page
CSE543 - Introduction to Computer and Network Security Module: Return-oriented Programming
Professor Trent Jaeger
1
1
CSE543 - Introduction to Computer and Network Security Module: - - PowerPoint PPT Presentation
CSE543 - Introduction to Computer and Network Security Page
1
1
CSE543 - Introduction to Computer and Network Security Page
2
2
CSE543 - Introduction to Computer and Network Security Page
3
3
CSE543 - Introduction to Computer and Network Security Page
4
4
CSE543 - Introduction to Computer and Network Security Page
5
5
CSE543 - Introduction to Computer and Network Security Page
6
6
CSE543 - Introduction to Computer and Network Security Page
7
7
CSE543 - Introduction to Computer and Network Security Page
8
8
%eax = %ebx = 0x8048000 = Registers Memory Code Stack
G1 5 jmp G2 Return Address
buf
0x8048000 jump G3
. . .
pop %eax ret pop %ebx ret movl %eax, (%ebx) ret
G2: G2 G3 G1: G3:
9
%eax = %ebx = 0x8048000 = Registers Memory Code Stack
G1 5 jmp G2 Return Address
buf
0x8048000 jump G3
. . .
pop %eax ret pop %ebx ret movl %eax, (%ebx) ret
G2: G2 G3 G1: G3:
5
10
%eax = %ebx = 0x8048000 = Registers Memory Code Stack
G1 5 jmp G2 Return Address
buf
0x8048000 jump G3
. . .
pop %eax ret pop %ebx ret movl %eax, (%ebx) ret
G2: G2 G3 G1: G3:
5
11
%eax = %ebx = 0x8048000 = Registers Memory Code Stack
G1 5 jmp G2 Return Address
buf
0x8048000 jump G3
. . .
pop %eax ret pop %ebx ret movl %eax, (%ebx) ret
G2: G2 G3 G1: G3:
5 0x8048000
12
%eax = %ebx = 0x8048000 = Registers Memory Code Stack
G1 5 jmp G2 Return Address
buf
0x8048000 jump G3
. . .
pop %eax ret pop %ebx ret movl %eax, (%ebx) ret
G2: G2 G3 G1: G3:
5 0x8048000
13
%eax = %ebx = 0x8048000 = Registers Memory Code Stack
G1 5 jmp G2 Return Address
buf
0x8048000 jump G3
. . .
pop %eax ret pop %ebx ret movl %eax, (%ebx) ret
G2: G2 G3 G1: G3:
5 0x8048000
14
%eax = %ebx = 0x8048000 = Registers Memory Code Stack
G1 5 jmp G2 Return Address
buf
0x8048000 jump G3
. . .
pop %eax ret pop %ebx ret movl %eax, (%ebx) ret
G2: G2 G3 G1: G3:
5 0x8048000 5
15
CSE543 - Introduction to Computer and Network Security Page
16
16
CSE543 - Introduction to Computer and Network Security Page
17
17
CSE543 - Introduction to Computer and Network Security Page
18
18
CSE543 - Introduction to Computer and Network Security Page
19
19
CSE543 - Introduction to Computer and Network Security Page
20
20
CSE543 - Introduction to Computer and Network Security Page
21
21
CSE543 - Introduction to Computer and Network Security Page
22
22
CSE543 - Introduction to Computer and Network Security Page
23
23
CSE543 - Introduction to Computer and Network Security Page
24
24
25
Jay Ligatti summer 2004 intern work with: Úlfar Erlingsson and Martín Abadi
25
26
FA FB return call fp
26-1
26
FA FB return call fp Acall Acall+1 B1 Bret CFG excerpt
26-2
26
FA FB return call fp Acall Acall+1 B1 Bret CFG excerpt
nop IMM1 if(*fp != nop IMM1) halt
26-3
26
FA FB return call fp Acall Acall+1 B1 Bret CFG excerpt
nop IMM1 if(*fp != nop IMM1) halt nop IMM2 if(**esp != nop IMM2) halt
NB: Need to ensure bit patterns for nops appear nowhere else in code memory
26-4
27
Maybe statically all we know is that FA can call any int int function FA FB call fp Acall B1 CFG excerpt C1 FC
succ(Acall) = {B1, C1}
27-1
27
Maybe statically all we know is that FA can call any int int function FA FB call fp Acall B1 CFG excerpt C1 FC
nop IMM1 if(*fp != nop IMM1) halt nop IMM1
Construction: All targets of a computed jump must have the same destination id (IMM) in their nop instruction
succ(Acall) = {B1, C1}
27-2
28
Q: What if FB can return to many functions ? Bret Acall+1 CFG excerpt Dcall+1 FB FA return call FB FD call FB
succ(Bret) = {Acall+1, Dcall+1}
28-1
28
Q: What if FB can return to many functions ? Bret Acall+1 CFG excerpt Dcall+1 FB FA return call FB FD call FB
nop IMM2 if(**esp != nop IMM2) halt nop IMM2
succ(Bret) = {Acall+1, Dcall+1}
28-2
28
Q: What if FB can return to many functions ? Bret Acall+1 CFG excerpt Dcall+1 FB FA return call FB FD call FB
nop IMM2 if(**esp != nop IMM2) halt nop IMM2
succ(Bret) = {Acall+1, Dcall+1}
A: Imprecise CFG
28-3
28
Q: What if FB can return to many functions ? Bret Acall+1 CFG excerpt Dcall+1 FB FA return call FB FD call FB
nop IMM2 if(**esp != nop IMM2) halt nop IMM2
succ(Bret) = {Acall+1, Dcall+1}
CFG Integrity: Changes to the PC are only to valid successor PCs, per succ(). A: Imprecise CFG
28-4
29
Acall B1 CFG excerpt C1 Ecall
29-1
29
Acall B1 CFG excerpt C1 Ecall
29-2
29
Acall B1 CFG excerpt C1 Ecall Solution I: Allow the imprecision
29-3
29
Acall B1 CFG excerpt C1 Ecall Solution I: Allow the imprecision Solution II: Duplicate code to remove zig-zags Acall B1 CFG excerpt C1A Ecall C1E
29-4
CSE543 - Introduction to Computer and Network Security Page
30
30
CSE543 - Introduction to Computer and Network Security Page
31
31
CSE543 - Introduction to Computer and Network Security Page
32
32
CSE543 - Introduction to Computer and Network Security Page
33
33
CSE543 - Introduction to Computer and Network Security Page
34
34
CSE543 - Introduction to Computer and Network Security Page
35
35
CSE543 - Introduction to Computer and Network Security Page
36
36
CSE543 - Introduction to Computer and Network Security Page
37
37-1
CSE543 - Introduction to Computer and Network Security Page
37
37-2
CSE543 - Introduction to Computer and Network Security Page
38
38
CSE543 - Introduction to Computer and Network Security Page
39
39
CSE543 - Introduction to Computer and Network Security Page
40
40