SlideShare a Scribd company logo
1 of 115
Download to read offline
Drinking from LETHE:
New methods of exploiting and mitigating
memory corruption vulnerabilities
Daniel Selifonov
DEF CON 23
August 7, 2015
Show of Hands
1. Have you written programs in C or C++?
2. Have you implemented a classic stack smash
exploit?
3. … a return-to-libc or return-oriented-
programming exploit?
4. … a return-to-libc or ROP exploit that used
memory disclosure or info leaks?
Motivations
● Software is rife with
memory corruption
vulnerabilities
● Most memory corruption
vulnerabilities are directly
applicable to code
execution exploits
● And there's no end in
sight...
Motivations (II)
● Industrialized
ecosystem of
vulnerability
discovery and
brokering
weaponized exploits
● Little of this discovery
process feeds into
fixes...
The other AFL
Motivations (III)
● State actor (e.g. NSA
Tailored Access
Operations group)
budgets: ≈ $∞
● Bug bounties just
drive up prices
● Target supply, not
demand for exploits...
The Plan
● Sever the path between
vulnerability and
(reliable) exploit
● Why do programmers
keep hitting this
fundamental blindspot?
● Defenses are born in
light of attack strategies
Memory Safety
#include <stdio.h>
int main() {
foo();
bar(11, 12);
return 0;
}
void foo() {
int a;
char b[23];
gets(b);
printf("Hey %s!n",b);
}
int bar(int x, int y) {
return x + y;
}
Memory Safety
#include <stdio.h>
int main() {
foo();
bar(11, 12);
return 0;
}
void foo() {
int a;
char b[23];
gets(b);
printf("Hey %s!n",b);
}
int bar(int x, int y) {
return x + y;
}
Memory Safety
#include <stdio.h>
int main() {
foo();
bar(11, 12);
return 0;
}
void foo() {
int a;
char b[23];
gets(b);
printf("Hey %s!n",b);
}
int bar(int x, int y) {
return x + y;
}
<return address to C runtime exit>
Memory Safety
#include <stdio.h>
int main() {
foo();
bar(11, 12);
return 0;
}
void foo() {
int a;
char b[23];
gets(b);
printf("Hey %s!n",b);
}
int bar(int x, int y) {
return x + y;
}
<return address to C runtime exit>
Memory Safety
#include <stdio.h>
int main() {
foo();
bar(11, 12);
return 0;
}
void foo() {
int a;
char b[23];
gets(b);
printf("Hey %s!n",b);
}
int bar(int x, int y) {
return x + y;
}
<return address to C runtime exit>
<return address to >
Memory Safety
#include <stdio.h>
int main() {
foo();
bar(11, 12);
return 0;
}
void foo() {
int a;
char b[23];
gets(b);
printf("Hey %s!n",b);
}
int bar(int x, int y) {
return x + y;
}
<return address to C runtime exit>
<return address to >
Memory Safety
#include <stdio.h>
int main() {
foo();
bar(11, 12);
return 0;
}
void foo() {
int a;
char b[23];
gets(b);
printf("Hey %s!n",b);
}
int bar(int x, int y) {
return x + y;
}
<return address to C runtime exit>
<return address to >
<4 bytes for 'int a'>
Memory Safety
#include <stdio.h>
int main() {
foo();
bar(11, 12);
return 0;
}
void foo() {
int a;
char b[23];
gets(b);
printf("Hey %s!n",b);
}
int bar(int x, int y) {
return x + y;
}
<return address to C runtime exit>
<return address to >
<4 bytes for 'int a'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
Memory Safety
#include <stdio.h>
int main() {
foo();
bar(11, 12);
return 0;
}
void foo() {
int a;
char b[23];
gets(b);
printf("Hey %s!n",b);
}
int bar(int x, int y) {
return x + y;
}
<return address to C runtime exit>
<return address to >
<4 bytes for 'int a'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
Memory Safety
#include <stdio.h>
int main() {
foo();
bar(11, 12);
return 0;
}
void foo() {
int a;
char b[23];
gets(b);
printf("Hey %s!n",b);
}
int bar(int x, int y) {
return x + y;
}
<return address to C runtime exit>
<return address to >
<4 bytes for 'int a'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<return address to >
Memory Safety
#include <stdio.h>
int main() {
foo();
bar(11, 12);
return 0;
}
void foo() {
int a;
char b[23];
gets(b);
printf("Hey %s!n",b);
}
int bar(int x, int y) {
return x + y;
}
<return address to C runtime exit>
<return address to >
<4 bytes for 'int a'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
Memory Safety
#include <stdio.h>
int main() {
foo();
bar(11, 12);
return 0;
}
void foo() {
int a;
char b[23];
gets(b);
printf("Hey %s!n",b);
}
int bar(int x, int y) {
return x + y;
}
<return address to C runtime exit>
<return address to >
<4 bytes for 'int a'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<return address to >
Memory Safety
#include <stdio.h>
int main() {
foo();
bar(11, 12);
return 0;
}
void foo() {
int a;
char b[23];
gets(b);
printf("Hey %s!n",b);
}
int bar(int x, int y) {
return x + y;
}
<return address to C runtime exit>
<return address to >
<4 bytes for 'int a'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
Memory Safety
#include <stdio.h>
int main() {
foo();
bar(11, 12);
return 0;
}
void foo() {
int a;
char b[23];
gets(b);
printf("Hey %s!n",b);
}
int bar(int x, int y) {
return x + y;
}
<return address to C runtime exit>
<return address to >
Memory Safety
#include <stdio.h>
int main() {
foo();
bar(11, 12);
return 0;
}
void foo() {
int a;
char b[23];
gets(b);
printf("Hey %s!n",b);
}
int bar(int x, int y) {
return x + y;
}
<return address to C runtime exit>
Memory Safety
#include <stdio.h>
int main() {
foo();
bar(11, 12);
return 0;
}
void foo() {
int a;
char b[23];
gets(b);
printf("Hey %s!n",b);
}
int bar(int x, int y) {
return x + y;
}
<return address to C runtime exit>
<return address to >
Memory Safety
#include <stdio.h>
int main() {
foo();
bar(11, 12);
return 0;
}
void foo() {
int a;
char b[23];
gets(b);
printf("Hey %s!n",b);
}
int bar(int x, int y) {
return x + y;
}
<return address to C runtime exit>
<return address to >
Memory Safety
#include <stdio.h>
int main() {
foo();
bar(11, 12);
return 0;
}
void foo() {
int a;
char b[23];
gets(b);
printf("Hey %s!n",b);
}
int bar(int x, int y) {
return x + y;
}
<return address to C runtime exit>
Memory Safety
#include <stdio.h>
int main() {
foo();
bar(11, 12);
return 0;
}
void foo() {
int a;
char b[23];
gets(b);
printf("Hey %s!n",b);
}
int bar(int x, int y) {
return x + y;
}
Part II:
Code Injection
Smashing the Stack (1996)
#include <stdio.h>
int main() {
foo();
bar(11, 12);
return 0;
}
void foo() {
int a;
char b[23];
gets(b);
printf("Hey %s!n",b);
}
int bar(int x, int y) {
return x + y;
}
<return address to >
<return address to C runtime exit>
<4 bytes for 'int a'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<return address to >
Smashing the Stack (1996)
#include <stdio.h>
int main() {
foo();
bar(11, 12);
return 0;
}
void foo() {
int a;
char b[23];
gets(b);
printf("Hey %s!n",b);
}
int bar(int x, int y) {
return x + y;
}
<return address to >
<return address to C runtime exit>
<4 bytes for 'int a'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<return address to >
Smashing the Stack (1996)
#include <stdio.h>
int main() {
foo();
bar(11, 12);
return 0;
}
void foo() {
int a;
char b[23];
gets(b);
printf("Hey %s!n",b);
}
int bar(int x, int y) {
return x + y;
}
<return address to >
<return address to C runtime exit>
<4 bytes for 'int a'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<return address to >
Smashing the Stack (1996)
#include <stdio.h>
int main() {
foo();
bar(11, 12);
return 0;
}
void foo() {
int a;
char b[23];
gets(b);
printf("Hey %s!n",b);
}
int bar(int x, int y) {
return x + y;
}
<return address to >
<return address to C runtime exit>
<4 bytes for 'int a'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<return address to >
Smashing the Stack (1996)
#include <stdio.h>
int main() {
foo();
bar(11, 12);
return 0;
}
void foo() {
int a;
char b[23];
gets(b);
printf("Hey %s!n",b);
}
int bar(int x, int y) {
return x + y;
}
<return address to >
<return address to C runtime exit>
<4 bytes for 'int a'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
Smashing the Stack (1996)
#include <stdio.h>
int main() {
foo();
bar(11, 12);
return 0;
}
void foo() {
int a;
char b[23];
gets(b);
printf("Hey %s!n",b);
}
int bar(int x, int y) {
return x + y;
}
<return address to >
<4 bytes for 'int a'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
Smashing the Stack (1996)
#include <stdio.h>
int main() {
foo();
bar(11, 12);
return 0;
}
void foo() {
int a;
char b[23];
gets(b);
printf("Hey %s!n",b);
}
int bar(int x, int y) {
return x + y;
}
<return address to >
<4 bytes for 'int a'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
<4 bytes for 'char b[]'>
Paging/Virtual Memory
0xdeadbeef
Paging/Virtual Memory
0xdeadbeef
11011110101011011011111011101111
Paging/Virtual Memory
0xdeadbeef
11011110101011011011111011101111
1101111010
(890)
1011011011
(731)
111011101111
(3823)
Paging/Virtual Memory
0xdeadbeef
11011110101011011011111011101111
1101111010
(890)
1011011011
(731)
111011101111
(3823)
Page Directory
(1024 entries)
Paging/Virtual Memory
0xdeadbeef
11011110101011011011111011101111
1101111010
(890)
1011011011
(731)
111011101111
(3823)
Page Directory
(1024 entries)
CR3
Paging/Virtual Memory
0xdeadbeef
11011110101011011011111011101111
1101111010
(890)
1011011011
(731)
111011101111
(3823)
Page Directory
(1024 entries)
CR3
Paging/Virtual Memory
0xdeadbeef
11011110101011011011111011101111
1101111010
(890)
1011011011
(731)
111011101111
(3823)
Page Directory
(1024 entries)
CR3
PDE
Paging/Virtual Memory
0xdeadbeef
11011110101011011011111011101111
1101111010
(890)
1011011011
(731)
111011101111
(3823)
Page Directory
(1024 entries)
Page Table
(1024 ents)
CR3
PDE
Paging/Virtual Memory
0xdeadbeef
11011110101011011011111011101111
1101111010
(890)
1011011011
(731)
111011101111
(3823)
Page Directory
(1024 entries)
Page Table
(1024 ents)
CR3
PDE
Paging/Virtual Memory
0xdeadbeef
11011110101011011011111011101111
1101111010
(890)
1011011011
(731)
111011101111
(3823)
Page Directory
(1024 entries)
Page Table
(1024 ents)
CR3
PDE
Paging/Virtual Memory
0xdeadbeef
11011110101011011011111011101111
1101111010
(890)
1011011011
(731)
111011101111
(3823)
Page Directory
(1024 entries)
Page Table
(1024 ents)
CR3
PDE
PTE
Paging/Virtual Memory
0xdeadbeef
11011110101011011011111011101111
1101111010
(890)
1011011011
(731)
111011101111
(3823)
Page Directory
(1024 entries)
Page Table
(1024 ents)
Page
4096 bytes
CR3
PDE
PTE
Paging/Virtual Memory
0xdeadbeef
11011110101011011011111011101111
1101111010
(890)
1011011011
(731)
111011101111
(3823)
Page Directory
(1024 entries)
Page Table
(1024 ents)
Page
4096 bytes
CR3
PDE
PTE
Paging/Virtual Memory
0xdeadbeef
11011110101011011011111011101111
1101111010
(890)
1011011011
(731)
111011101111
(3823)
Page Directory
(1024 entries)
Page Table
(1024 ents)
Page
4096 bytes
CR3
PDE
PTE
Paging/Virtual Memory
0xdeadbeef
11011110101011011011111011101111
1101111010
(890)
1011011011
(731)
111011101111
(3823)
Page Directory
(1024 entries)
Page Table
(1024 ents)
Page
4096 bytes
CR3
PDE
PTE Byte
Paging/Virtual Memory
0xdeadbeef
11011110101011011011111011101111
1101111010
(890)
1011011011
(731)
111011101111
(3823)
Page Directory
(1024 entries)
Page Table
(1024 ents)
Page
4096 bytes
CR3
PDE
PTE Byte
Page Table Entries
32 0
Physical address of next level Read/
Write
User/
Supervisor
Paging made fast: TLB
0xdeadbeef
11011110101011011011111011101111
1101111010
(890)
1011011011
(731)
Paging made fast: TLB
0xdeadbeef
11011110101011011011111011101111
1101111010
(890)
1011011011
(731)
Page
(4096 bytes)
Paging made fast: TLB
0xdeadbeef
11011110101011011011111011101111
1101111010
(890)
1011011011
(731)
Page
(4096 bytes)
Paging made fast: TLB
0xdeadbeef
11011110101011011011111011101111
1101111010
(890)
1011011011
(731)
Page
(4096 bytes)
Paging made fast: TLB
0xdeadbeef
11011110101011011011111011101111
1101111010
(890)
1011011011
(731)
Page
(4096 bytes)
Virtual
Address
Physical
Address
Aggregate
Permissions
TLB Entry:
PaX PAGEEXEC (2000)
User/
Supervisor:
Emulates
Non-Exec
Instruction TLB:
Data TLB:
Virtual Addr Physical Addr Permission
Virtual Addr Physical Addr Permission
Instruction Pointer:
PaX Page Fault Strategy:
if (supervisor page &&
IP on faulting page) {
Terminate
} else {
Set user page in PTE
Prime Data TLB
Set supervisor page in PTE
}
PaX PAGEEXEC (2000)
User/
Supervisor:
Emulates
Non-Exec
Instruction TLB:
Data TLB:
Virtual Addr Physical Addr Permission
Virtual Addr Physical Addr Permission
Instruction Pointer:
PaX Page Fault Strategy:
if (supervisor page &&
IP on faulting page) {
Terminate
} else {
Set user page in PTE
Prime Data TLB
Set supervisor page in PTE
}
1
PaX PAGEEXEC (2000)
User/
Supervisor:
Emulates
Non-Exec
Instruction TLB:
Data TLB:
Virtual Addr Physical Addr Permission
Virtual Addr Physical Addr Permission
Instruction Pointer:
PaX Page Fault Strategy:
if (supervisor page &&
IP on faulting page) {
Terminate
} else {
Set user page in PTE
Prime Data TLB
Set supervisor page in PTE
}
1
PaX PAGEEXEC (2000)
User/
Supervisor:
Emulates
Non-Exec
Instruction TLB:
Data TLB:
Virtual Addr Physical Addr Permission
Virtual Addr Physical Addr Permission
Instruction Pointer:
PaX Page Fault Strategy:
if (supervisor page &&
IP on faulting page) {
Terminate
} else {
Set user page in PTE
Prime Data TLB
Set supervisor page in PTE
}
1
PaX PAGEEXEC (2000)
User/
Supervisor:
Emulates
Non-Exec
Instruction TLB:
Data TLB:
Virtual Addr Physical Addr Permission
Virtual Addr Physical Addr Permission
Instruction Pointer:
PaX Page Fault Strategy:
if (supervisor page &&
IP on faulting page) {
Terminate
} else {
Set user page in PTE
Prime Data TLB
Set supervisor page in PTE
}
0
PaX PAGEEXEC (2000)
User/
Supervisor:
Emulates
Non-Exec
Instruction TLB:
Data TLB:
Virtual Addr Physical Addr Permission
Virtual Addr Physical Addr Permission
Instruction Pointer:
PaX Page Fault Strategy:
if (supervisor page &&
IP on faulting page) {
Terminate
} else {
Set user page in PTE
Prime Data TLB
Set supervisor page in PTE
}
0
PaX PAGEEXEC (2000)
User/
Supervisor:
Emulates
Non-Exec
Instruction TLB:
Data TLB:
Virtual Addr Physical Addr Permission
Virtual Addr Physical Addr Permission
Instruction Pointer:
~ User/~
PaX Page Fault Strategy:
if (supervisor page &&
IP on faulting page) {
Terminate
} else {
Set user page in PTE
Prime Data TLB
Set supervisor page in PTE
}
0
PaX PAGEEXEC (2000)
User/
Supervisor:
Emulates
Non-Exec
Instruction TLB:
Data TLB:
Virtual Addr Physical Addr Permission
Virtual Addr Physical Addr Permission
Instruction Pointer:
~ User/~
PaX Page Fault Strategy:
if (supervisor page &&
IP on faulting page) {
Terminate
} else {
Set user page in PTE
Prime Data TLB
Set supervisor page in PTE
}
1
PaX PAGEEXEC (2000)
User/
Supervisor:
Emulates
Non-Exec
Instruction TLB:
Data TLB:
Virtual Addr Physical Addr Permission
Virtual Addr Physical Addr Permission
Instruction Pointer:
~ User/~
PaX Page Fault Strategy:
if (supervisor page &&
IP on faulting page) {
Terminate
} else {
Set user page in PTE
Prime Data TLB
Set supervisor page in PTE
}
1
PaX PAGEEXEC (2000)
User/
Supervisor:
Emulates
Non-Exec
Instruction TLB:
Data TLB:
Virtual Addr Physical Addr Permission
Virtual Addr Physical Addr Permission
Instruction Pointer:
~ User/~
PaX Page Fault Strategy:
if (supervisor page &&
IP on faulting page) {
Terminate
} else {
Set user page in PTE
Prime Data TLB
Set supervisor page in PTE
}
1
PaX PAGEEXEC (2000)
User/
Supervisor:
Emulates
Non-Exec
Instruction TLB:
Data TLB:
Virtual Addr Physical Addr Permission
Virtual Addr Physical Addr Permission
Instruction Pointer:
~ User/~
PaX Page Fault Strategy:
if (supervisor page &&
IP on faulting page) {
Terminate
} else {
Set user page in PTE
Prime Data TLB
Set supervisor page in PTE
}
1
PaX PAGEEXEC (2000)
User/
Supervisor:
Emulates
Non-Exec
Instruction TLB:
Data TLB:
Virtual Addr Physical Addr Permission
Virtual Addr Physical Addr Permission
Instruction Pointer:
~ User/~
PaX Page Fault Strategy:
if (supervisor page &&
IP on faulting page) {
Terminate
} else {
Set user page in PTE
Prime Data TLB
Set supervisor page in PTE
}
~ User/~
1
Page Level Permissions
User Supervisor PaX/NX
Not-Writable Read/Execute Read
Writable Read/Write/Execute Read/Write
For mapped pages:
Part III:
Code Reuse
Return to libc (1997)
...
<Shell code>
<Shell code>
<Shell code>
<Shell code>
<Shell code>
<nop> <nop> <nop> <nop>
<nop> <nop> <nop> <nop>
<nop> <nop> <nop> <nop>
<smashed return address to ~ >
Return to libc (1997)
...
<Shell code>
<Shell code>
<Shell code>
<Shell code>
<Shell code>
<nop> <nop> <nop> <nop>
<nop> <nop> <nop> <nop>
<nop> <nop> <nop> <nop>
<smashed return address to ~ >
Return to libc (1997)
...
sh”
/bas
“/bin
<pointer to >
<dummy value>
<smashed ret to libc system() >
...
<vulnerable buffer>
Return to libc (1997)
...
sh”
/bas
“/bin
<pointer to >
<dummy value>
<smashed ret to libc system() >
...
<vulnerable buffer>
...
<pointer to “/bin/bash”>
<saved return address>
<local variable for system()>
<local variable for system()>
...
...
Return to libc (1997)
...
sh”
/bas
“/bin
<pointer to >
<dummy value>
<smashed ret to libc system() >
...
<vulnerable buffer>
...
<pointer to “/bin/bash”>
<saved return address>
<local variable for system()>
<local variable for system()>
...
...
Return Oriented Programming ('07)
...
<argument popping gadget addr>
<argument 2>
<argument 1>
<argument popping gadget addr>
<gadget addr 2>
<argument 2>
<argument 1>
<argument popping gadget addr>
<gadget addr 1>
push eax
ret
pop eax
ret
pop ebx
ret
mov [ebx],eax
ret
xchg ebx,esp
ret
pop edi
pop ebp
ret
Address Space Layout
Randomization (2003)
0...00
f...ff
Stack
Heap
mmap
Library A
Library B
Library C
Program Code
Stack
Heap
mmap
Library A
Library B
Library C
Program Code
Part IV:
Memory Disclosure
&
Advanced Code Reuse
Offset Fix Ups
Library Relative 0..00
libc
Offset Fix Ups
Library Relative 0..00
libc
Library Relative 0..23:
location of system()
Offset Fix Ups
Library Relative 0..00
libc
Library Relative 0..23:
location of system()
Library Relative 0..46:
location of printf()
Offset Fix Ups
Library Relative 0..00
libc
Library Relative 0..23:
location of system()
Library Relative 0..46:
location of printf()
Randomized Virtual Addr
for printf: 0xdefc0b46
Offset Fix Ups
Library Relative 0..00
libc
Library Relative 0..23:
location of system()
Library Relative 0..46:
location of printf()
Randomized Virtual Addr
for printf: 0xdefc0b46
Randomized Virtual Addr
for system: 0xdefc0b23
Offset Fix Ups
Library Relative 0..00
libc
Library Relative 0..23:
location of system()
Library Relative 0..46:
location of printf()
Randomized Virtual Addr
for printf: 0xdefc0b46
Randomized Virtual Addr
for system: 0xdefc0b23
Fine Grained ASLR
● Smashing the
Gadgets (2012)
● Address Space
Layout Permutation
(2006)
lib-func-a lib-func-b
lib-func-b lib-func-f
lib-func-c lib-func-a
lib-func-d lib-func-c
lib-func-f lib-func-d
Function level FG-ASLR:
mov eax, [ebp-4]
mov ebx, [ebp-8]
add eax, ebx
xor ecx, ecx
push eax
push ebx
push ecx
call foo
mov edx, [ebp-4]
mov esi, [ebp-8]
add edx, esi
xor edi, edi
push edx
push esi
push edi
call foo
Just-in-Time Code Reuse (2013)
Code Ptr:
0xdeadbeef
Just-in-Time Code Reuse (2013)
Code Ptr:
0xdeadbeef
4K Page @
0xdeadb000
Just-in-Time Code Reuse (2013)
Code Ptr:
0xdeadbeef
4K Page @
0xdeadb000
...
mov eax, [ebp-4]
mov ebx, [ebp-8]
add eax, ebx
push eax
push ebx
call 0x64616d6e
...
Just-in-Time Code Reuse (2013)
Code Ptr:
0xdeadbeef
4K Page @
0xdeadb000
...
mov eax, [ebp-4]
mov ebx, [ebp-8]
add eax, ebx
push eax
push ebx
call 0x64616d6e
...
Just-in-Time Code Reuse (2013)
Code Ptr:
0xdeadbeef
4K Page @
0xdeadb000
...
mov eax, [ebp-4]
mov ebx, [ebp-8]
add eax, ebx
push eax
push ebx
call 0x64616d6e
...
4K Page @
0x64616000
Just-in-Time Code Reuse (2013)
Code Ptr:
0xdeadbeef
4K Page @
0xdeadb000
...
mov eax, [ebp-4]
mov ebx, [ebp-8]
add eax, ebx
push eax
push ebx
call 0x64616d6e
...
4K Page @
0x64616000
Just-in-Time Code Reuse (2013)
Code Ptr:
0xdeadbeef
4K Page @
0xdeadb000
...
mov eax, [ebp-4]
mov ebx, [ebp-8]
add eax, ebx
push eax
push ebx
call 0x64616d6e
...
4K Page @
0x64616000
The Value of One Pointer?
Volcano and Hobbit: sold separately.
Part V:
Conceal
&
Forget
C++ Virtual Function Tables
Instance of class Dog
Vtable ptr
Member: name
Member: age
Member: breed
Instance of class Cat
Vtable ptr
Member: name
Member: fav. catnip
Member: sharp claws?
Function ptr: feed()
Function ptr: pet()
Function ptr: sound()
Function ptr: feed()
Function ptr: pet()
Function ptr: sound()
Animal → Dog, Animal → Cat
class Cat : public Animal {
…
void sound() {
printf(“Meow!”);
}
…
}
class Dog : public Animal {
…
void sound() {
printf(“Woof!”);
}
…
}
C++ Virtual Function Tables
Instance of class Dog
Vtable ptr
Member: name
Member: age
Member: breed
Instance of class Cat
Vtable ptr
Member: name
Member: fav. catnip
Member: sharp claws?
Function ptr: feed()
Function ptr: pet()
Function ptr: sound()
Function ptr: feed()
Function ptr: pet()
Function ptr: sound()
Animal → Dog, Animal → Cat
class Cat : public Animal {
…
void sound() {
printf(“Meow!”);
}
…
}
class Dog : public Animal {
…
void sound() {
printf(“Woof!”);
}
…
}
Knights and Knaves
Instance of class Dog
Vtable ptr
Member: name
Member: age
Member: breed
Function ptr: feed()
Function ptr: pet()
Function ptr: sound()
Knights and Knaves
Instance of class Dog
Vtable ptr
Member: name
Member: age
Member: breed
Function ptr: feed()
Function ptr: pet()
Function ptr: sound()
Function ptr? feed()
Function ptr? feed()
Function ptr? feed()
Function ptr? pet()
Function ptr? pet()
Function ptr? pet()
Function ptr? sound()
Function ptr? sound()
Function ptr? sound()
Knights and Knaves
Instance of class Dog
Vtable ptr
Member: name
Member: age
Member: breed
Function ptr? feed()
Function ptr? feed()
Function ptr? feed()
Function ptr? pet()
Function ptr? pet()
Function ptr? pet()
Function ptr? sound()
Function ptr? sound()
Function ptr? sound()
Knights and Knaves
Instance of class Dog
Vtable ptr
Member: name
Member: age
Member: breed
Function ptr? feed()
Function ptr? feed()
Function ptr? feed()
Function ptr? pet()
Function ptr? pet()
Function ptr? pet()
Function ptr? sound()
Function ptr? sound()
Function ptr? sound()
Knights and Knaves
Instance of class Dog
Vtable ptr
Member: name
Member: age
Member: breed
Function ptr? feed()
Function ptr? feed()
Function ptr? feed()
Function ptr? pet()
Function ptr? pet()
Function ptr? pet()
Function ptr? sound()
Function ptr? sound()
Function ptr? sound()
Execute Only Memory
Code Ptr:
0xdeadbeef
4K Page @
0xdeadb000
...
mov eax, [ebp-4]
mov ebx, [ebp-8]
add eax, ebx
push eax
push ebx
call 0x64616d6e
...
Execute Only Memory
Code Ptr:
0xdeadbeef
4K Page @
0xdeadb000
...
mov eax, [ebp-4]
mov ebx, [ebp-8]
add eax, ebx
push eax
push ebx
call 0x64616d6e
...
Necessary vs. Sufficient
● Code reuse requires:
– No ASLR: A priori knowledge of place
– ASLR: A priori knowledge of relative place + runtime
discovery of offset
– FG-ASLR: Runtime discovery of value at discovered
place
● No runtime discovery? No discovery of value or
place and no code to reuse:
– XO-M + FG-ASLR = <3
Elephant in the Room
Two words: memory overhead
https://www.flickr.com/photos/mobilestreetlife/4179063482
Blunting the Edge
● Oxymoron (2014)
– Key idea: call fs:0x100
mov eax, [ebp-4]
mov ebx, [ebp-8]
add eax, ebx
xor ecx, ecx
push eax
push ebx
push ecx
call fs:0x100
...
0x110: jmp ...
0x10c: jmp ...
0x108: jmp ...
0x104: jmp ...
0x100: jmp 0xdefc23defc23
0xfc: jmp ...
0xf8: jmp ...
0xf4: jmp ...
...
Start of fs segment at random addr...
Xen, Linux, & LLVM
● Xen 4.4 introduced PVH mode (Xen 4.5 → PVH
dom0)
– PVH uses Intel Extended Page Tables for PFN →
MFN translations
– EPT supports explicit R/W/E permissions
● Linux mprotect M_EXECUTE & ~M_READ sets
EPT through Xen
– Xen injects violations into Linux #PF handler
● LLVM for FG-ASLR and execute-only codegen
Part VI:
Closing Thoughts
Takeaways
Non-Writable Readable EPT ~R
X Read/Execute Execute Only
NX Read Nothing
Writable Readable EPT ~R
X Read/Write/Execute Write/Execute
NX Read/Write Write
Takeaways
Non-Writable Readable EPT ~R
X Read/Execute Execute Only
NX Read Nothing
Writable Readable EPT ~R
X Read/Write/Execute Write/Execute
NX Read/Write Write
Constant Data
Takeaways
Non-Writable Readable EPT ~R
X Read/Execute Execute Only
NX Read Nothing
Writable Readable EPT ~R
X Read/Write/Execute Write/Execute
NX Read/Write Write
Constant Data
Stack/Heap/mmap
Takeaways
Non-Writable Readable EPT ~R
X Read/Execute Execute Only
NX Read Nothing
Writable Readable EPT ~R
X Read/Write/Execute Write/Execute
NX Read/Write Write
Constant Data
Stack/Heap/mmap
Program/Library
Code
Takeaways
Non-Writable Readable EPT ~R
X Read/Execute Execute Only
NX Read Nothing
Writable Readable EPT ~R
X Read/Write/Execute Write/Execute
NX Read/Write Write
Constant Data
Stack/Heap/mmap
Program/Library
Code
Takeaways
Non-Writable Readable EPT ~R
X Read/Execute Execute Only
NX Read Nothing
Writable Readable EPT ~R
X Read/Write/Execute Write/Execute
NX Read/Write Write
Constant Data
Stack/Heap/mmap
Program/Library
Code
Takeaways
Non-Writable Readable EPT ~R
X Read/Execute Execute Only
NX Read Nothing
Writable Readable EPT ~R
X Read/Write/Execute Write/Execute
NX Read/Write Write
Constant Data
Stack/Heap/mmap
Program/Library
Code
FIN
● Code: <TBD>
● White Paper: <TBD>
● Email: ds@thyth.com
● Twitter: @dsThyth
● PGP:
– 201a 7b59 a15b e5f0 bc37 08d3 bc7f 39b2 dfc0 2d75

More Related Content

What's hot

8 arrays and pointers
8  arrays and pointers8  arrays and pointers
8 arrays and pointersMomenMostafa
 
c++ program for Railway reservation
c++ program for Railway reservationc++ program for Railway reservation
c++ program for Railway reservationSwarup Kumar Boro
 
Implementing Software Machines in Go and C
Implementing Software Machines in Go and CImplementing Software Machines in Go and C
Implementing Software Machines in Go and CEleanor McHugh
 
Implementing Software Machines in C and Go
Implementing Software Machines in C and GoImplementing Software Machines in C and Go
Implementing Software Machines in C and GoEleanor McHugh
 
Programa en C++ ( escriba 3 números y diga cual es el mayor))
Programa en C++ ( escriba 3 números y diga cual es el mayor))Programa en C++ ( escriba 3 números y diga cual es el mayor))
Programa en C++ ( escriba 3 números y diga cual es el mayor))Alex Penso Romero
 
Php questions and answers
Php questions and answersPhp questions and answers
Php questions and answersDeepika joshi
 
Egor Bogatov - .NET Core intrinsics and other micro-optimizations
Egor Bogatov - .NET Core intrinsics and other micro-optimizationsEgor Bogatov - .NET Core intrinsics and other micro-optimizations
Egor Bogatov - .NET Core intrinsics and other micro-optimizationsEgor Bogatov
 
Data Structure - 2nd Study
Data Structure - 2nd StudyData Structure - 2nd Study
Data Structure - 2nd StudyChris Ohk
 
How to add an optimization for C# to RyuJIT
How to add an optimization for C# to RyuJITHow to add an optimization for C# to RyuJIT
How to add an optimization for C# to RyuJITEgor Bogatov
 
C Programming Training in Ambala ! Batra Computer Centre
C Programming Training in Ambala ! Batra Computer CentreC Programming Training in Ambala ! Batra Computer Centre
C Programming Training in Ambala ! Batra Computer Centrejatin batra
 
ONLINE STUDENT MANAGEMENT SYSTEM
ONLINE STUDENT MANAGEMENT SYSTEMONLINE STUDENT MANAGEMENT SYSTEM
ONLINE STUDENT MANAGEMENT SYSTEMRohit malav
 
Declarative Datalog Debugging for Mere Mortals
Declarative Datalog Debugging for Mere MortalsDeclarative Datalog Debugging for Mere Mortals
Declarative Datalog Debugging for Mere MortalsBertram Ludäscher
 

What's hot (20)

8 arrays and pointers
8  arrays and pointers8  arrays and pointers
8 arrays and pointers
 
C programs
C programsC programs
C programs
 
c++ program for Railway reservation
c++ program for Railway reservationc++ program for Railway reservation
c++ program for Railway reservation
 
Implementing Software Machines in Go and C
Implementing Software Machines in Go and CImplementing Software Machines in Go and C
Implementing Software Machines in Go and C
 
Implementing Software Machines in C and Go
Implementing Software Machines in C and GoImplementing Software Machines in C and Go
Implementing Software Machines in C and Go
 
Vcs15
Vcs15Vcs15
Vcs15
 
Programa en C++ ( escriba 3 números y diga cual es el mayor))
Programa en C++ ( escriba 3 números y diga cual es el mayor))Programa en C++ ( escriba 3 números y diga cual es el mayor))
Programa en C++ ( escriba 3 números y diga cual es el mayor))
 
Revision1 C programming
Revision1 C programmingRevision1 C programming
Revision1 C programming
 
Revision1schema C programming
Revision1schema C programmingRevision1schema C programming
Revision1schema C programming
 
Php questions and answers
Php questions and answersPhp questions and answers
Php questions and answers
 
C questions
C questionsC questions
C questions
 
Egor Bogatov - .NET Core intrinsics and other micro-optimizations
Egor Bogatov - .NET Core intrinsics and other micro-optimizationsEgor Bogatov - .NET Core intrinsics and other micro-optimizations
Egor Bogatov - .NET Core intrinsics and other micro-optimizations
 
C program
C programC program
C program
 
Data Structure - 2nd Study
Data Structure - 2nd StudyData Structure - 2nd Study
Data Structure - 2nd Study
 
Buffer OverFlow
Buffer OverFlowBuffer OverFlow
Buffer OverFlow
 
How to add an optimization for C# to RyuJIT
How to add an optimization for C# to RyuJITHow to add an optimization for C# to RyuJIT
How to add an optimization for C# to RyuJIT
 
String
StringString
String
 
C Programming Training in Ambala ! Batra Computer Centre
C Programming Training in Ambala ! Batra Computer CentreC Programming Training in Ambala ! Batra Computer Centre
C Programming Training in Ambala ! Batra Computer Centre
 
ONLINE STUDENT MANAGEMENT SYSTEM
ONLINE STUDENT MANAGEMENT SYSTEMONLINE STUDENT MANAGEMENT SYSTEM
ONLINE STUDENT MANAGEMENT SYSTEM
 
Declarative Datalog Debugging for Mere Mortals
Declarative Datalog Debugging for Mere MortalsDeclarative Datalog Debugging for Mere Mortals
Declarative Datalog Debugging for Mere Mortals
 

Similar to Defcon 23 - Daniel Selifonov - drinking from LETHE

CS50 Lecture3
CS50 Lecture3CS50 Lecture3
CS50 Lecture3昀 李
 
C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)Saifur Rahman
 
ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...
ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...
ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...Muhammad Ulhaque
 
Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 FocJAYA
 
Computer Architecture and Organization lab with matlab
Computer Architecture and Organization lab with matlabComputer Architecture and Organization lab with matlab
Computer Architecture and Organization lab with matlabShankar Gangaju
 
Unit 3 Input Output.pptx
Unit 3 Input Output.pptxUnit 3 Input Output.pptx
Unit 3 Input Output.pptxPrecise Mya
 
Compiler design.pdf
Compiler design.pdfCompiler design.pdf
Compiler design.pdfNitesh Dubey
 
GE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python ProgrammingGE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python ProgrammingMuthu Vinayagam
 
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1Little Tukta Lita
 
Intro to c programming
Intro to c programmingIntro to c programming
Intro to c programmingPrabhu Govind
 
Concepts of C [Module 2]
Concepts of C [Module 2]Concepts of C [Module 2]
Concepts of C [Module 2]Abhishek Sinha
 
ภาษาซีพื้นฐาน
ภาษาซีพื้นฐานภาษาซีพื้นฐาน
ภาษาซีพื้นฐานKrunee Thitthamon
 

Similar to Defcon 23 - Daniel Selifonov - drinking from LETHE (20)

CS50 Lecture3
CS50 Lecture3CS50 Lecture3
CS50 Lecture3
 
C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)
 
Vcs28
Vcs28Vcs28
Vcs28
 
String Manipulation Function and Header File Functions
String Manipulation Function and Header File FunctionsString Manipulation Function and Header File Functions
String Manipulation Function and Header File Functions
 
Tu1
Tu1Tu1
Tu1
 
ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...
ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...
ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...
 
Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 Foc
 
Computer Architecture and Organization lab with matlab
Computer Architecture and Organization lab with matlabComputer Architecture and Organization lab with matlab
Computer Architecture and Organization lab with matlab
 
C programms
C programmsC programms
C programms
 
Software Exploits
Software ExploitsSoftware Exploits
Software Exploits
 
Unit 3 Input Output.pptx
Unit 3 Input Output.pptxUnit 3 Input Output.pptx
Unit 3 Input Output.pptx
 
Session06 functions
Session06 functionsSession06 functions
Session06 functions
 
Compiler design.pdf
Compiler design.pdfCompiler design.pdf
Compiler design.pdf
 
GE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python ProgrammingGE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python Programming
 
7 functions
7  functions7  functions
7 functions
 
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1
 
Intro to c programming
Intro to c programmingIntro to c programming
Intro to c programming
 
Concepts of C [Module 2]
Concepts of C [Module 2]Concepts of C [Module 2]
Concepts of C [Module 2]
 
ภาษาซีพื้นฐาน
ภาษาซีพื้นฐานภาษาซีพื้นฐาน
ภาษาซีพื้นฐาน
 
C Programming lab
C Programming labC Programming lab
C Programming lab
 

More from Felipe Prado

DEF CON 24 - Sean Metcalf - beyond the mcse red teaming active directory
DEF CON 24 - Sean Metcalf - beyond the mcse red teaming active directoryDEF CON 24 - Sean Metcalf - beyond the mcse red teaming active directory
DEF CON 24 - Sean Metcalf - beyond the mcse red teaming active directoryFelipe Prado
 
DEF CON 24 - Bertin Bervis and James Jara - exploiting and attacking seismolo...
DEF CON 24 - Bertin Bervis and James Jara - exploiting and attacking seismolo...DEF CON 24 - Bertin Bervis and James Jara - exploiting and attacking seismolo...
DEF CON 24 - Bertin Bervis and James Jara - exploiting and attacking seismolo...Felipe Prado
 
DEF CON 24 - Tamas Szakaly - help i got ants
DEF CON 24 - Tamas Szakaly - help i got antsDEF CON 24 - Tamas Szakaly - help i got ants
DEF CON 24 - Tamas Szakaly - help i got antsFelipe Prado
 
DEF CON 24 - Ladar Levison - compelled decryption
DEF CON 24 - Ladar Levison - compelled decryptionDEF CON 24 - Ladar Levison - compelled decryption
DEF CON 24 - Ladar Levison - compelled decryptionFelipe Prado
 
DEF CON 24 - Clarence Chio - machine duping 101
DEF CON 24 - Clarence Chio - machine duping 101DEF CON 24 - Clarence Chio - machine duping 101
DEF CON 24 - Clarence Chio - machine duping 101Felipe Prado
 
DEF CON 24 - Chris Rock - how to overthrow a government
DEF CON 24 - Chris Rock - how to overthrow a governmentDEF CON 24 - Chris Rock - how to overthrow a government
DEF CON 24 - Chris Rock - how to overthrow a governmentFelipe Prado
 
DEF CON 24 - Fitzpatrick and Grand - 101 ways to brick your hardware
DEF CON 24 - Fitzpatrick and Grand - 101 ways to brick your hardwareDEF CON 24 - Fitzpatrick and Grand - 101 ways to brick your hardware
DEF CON 24 - Fitzpatrick and Grand - 101 ways to brick your hardwareFelipe Prado
 
DEF CON 24 - Rogan Dawes and Dominic White - universal serial aBUSe remote at...
DEF CON 24 - Rogan Dawes and Dominic White - universal serial aBUSe remote at...DEF CON 24 - Rogan Dawes and Dominic White - universal serial aBUSe remote at...
DEF CON 24 - Rogan Dawes and Dominic White - universal serial aBUSe remote at...Felipe Prado
 
DEF CON 24 - Jay Beale and Larry Pesce - phishing without frustration
DEF CON 24 - Jay Beale and Larry Pesce - phishing without frustrationDEF CON 24 - Jay Beale and Larry Pesce - phishing without frustration
DEF CON 24 - Jay Beale and Larry Pesce - phishing without frustrationFelipe Prado
 
DEF CON 24 - Gorenc Sands - hacker machine interface
DEF CON 24 - Gorenc Sands - hacker machine interfaceDEF CON 24 - Gorenc Sands - hacker machine interface
DEF CON 24 - Gorenc Sands - hacker machine interfaceFelipe Prado
 
DEF CON 24 - Allan Cecil and DwangoAC - tasbot the perfectionist
DEF CON 24 - Allan Cecil and DwangoAC -  tasbot the perfectionistDEF CON 24 - Allan Cecil and DwangoAC -  tasbot the perfectionist
DEF CON 24 - Allan Cecil and DwangoAC - tasbot the perfectionistFelipe Prado
 
DEF CON 24 - Rose and Ramsey - picking bluetooth low energy locks
DEF CON 24 - Rose and Ramsey - picking bluetooth low energy locksDEF CON 24 - Rose and Ramsey - picking bluetooth low energy locks
DEF CON 24 - Rose and Ramsey - picking bluetooth low energy locksFelipe Prado
 
DEF CON 24 - Rich Mogull - pragmatic cloud security
DEF CON 24 - Rich Mogull - pragmatic cloud securityDEF CON 24 - Rich Mogull - pragmatic cloud security
DEF CON 24 - Rich Mogull - pragmatic cloud securityFelipe Prado
 
DEF CON 24 - Grant Bugher - Bypassing captive portals
DEF CON 24 - Grant Bugher - Bypassing captive portalsDEF CON 24 - Grant Bugher - Bypassing captive portals
DEF CON 24 - Grant Bugher - Bypassing captive portalsFelipe Prado
 
DEF CON 24 - Patrick Wardle - 99 problems little snitch
DEF CON 24 - Patrick Wardle - 99 problems little snitchDEF CON 24 - Patrick Wardle - 99 problems little snitch
DEF CON 24 - Patrick Wardle - 99 problems little snitchFelipe Prado
 
DEF CON 24 - Plore - side -channel attacks on high security electronic safe l...
DEF CON 24 - Plore - side -channel attacks on high security electronic safe l...DEF CON 24 - Plore - side -channel attacks on high security electronic safe l...
DEF CON 24 - Plore - side -channel attacks on high security electronic safe l...Felipe Prado
 
DEF CON 24 - Six Volts and Haystack - cheap tools for hacking heavy trucks
DEF CON 24 - Six Volts and Haystack - cheap tools for hacking heavy trucksDEF CON 24 - Six Volts and Haystack - cheap tools for hacking heavy trucks
DEF CON 24 - Six Volts and Haystack - cheap tools for hacking heavy trucksFelipe Prado
 
DEF CON 24 - Dinesh and Shetty - practical android application exploitation
DEF CON 24 - Dinesh and Shetty - practical android application exploitationDEF CON 24 - Dinesh and Shetty - practical android application exploitation
DEF CON 24 - Dinesh and Shetty - practical android application exploitationFelipe Prado
 
DEF CON 24 - Klijnsma and Tentler - stargate pivoting through vnc
DEF CON 24 - Klijnsma and Tentler - stargate pivoting through vncDEF CON 24 - Klijnsma and Tentler - stargate pivoting through vnc
DEF CON 24 - Klijnsma and Tentler - stargate pivoting through vncFelipe Prado
 
DEF CON 24 - Antonio Joseph - fuzzing android devices
DEF CON 24 - Antonio Joseph - fuzzing android devicesDEF CON 24 - Antonio Joseph - fuzzing android devices
DEF CON 24 - Antonio Joseph - fuzzing android devicesFelipe Prado
 

More from Felipe Prado (20)

DEF CON 24 - Sean Metcalf - beyond the mcse red teaming active directory
DEF CON 24 - Sean Metcalf - beyond the mcse red teaming active directoryDEF CON 24 - Sean Metcalf - beyond the mcse red teaming active directory
DEF CON 24 - Sean Metcalf - beyond the mcse red teaming active directory
 
DEF CON 24 - Bertin Bervis and James Jara - exploiting and attacking seismolo...
DEF CON 24 - Bertin Bervis and James Jara - exploiting and attacking seismolo...DEF CON 24 - Bertin Bervis and James Jara - exploiting and attacking seismolo...
DEF CON 24 - Bertin Bervis and James Jara - exploiting and attacking seismolo...
 
DEF CON 24 - Tamas Szakaly - help i got ants
DEF CON 24 - Tamas Szakaly - help i got antsDEF CON 24 - Tamas Szakaly - help i got ants
DEF CON 24 - Tamas Szakaly - help i got ants
 
DEF CON 24 - Ladar Levison - compelled decryption
DEF CON 24 - Ladar Levison - compelled decryptionDEF CON 24 - Ladar Levison - compelled decryption
DEF CON 24 - Ladar Levison - compelled decryption
 
DEF CON 24 - Clarence Chio - machine duping 101
DEF CON 24 - Clarence Chio - machine duping 101DEF CON 24 - Clarence Chio - machine duping 101
DEF CON 24 - Clarence Chio - machine duping 101
 
DEF CON 24 - Chris Rock - how to overthrow a government
DEF CON 24 - Chris Rock - how to overthrow a governmentDEF CON 24 - Chris Rock - how to overthrow a government
DEF CON 24 - Chris Rock - how to overthrow a government
 
DEF CON 24 - Fitzpatrick and Grand - 101 ways to brick your hardware
DEF CON 24 - Fitzpatrick and Grand - 101 ways to brick your hardwareDEF CON 24 - Fitzpatrick and Grand - 101 ways to brick your hardware
DEF CON 24 - Fitzpatrick and Grand - 101 ways to brick your hardware
 
DEF CON 24 - Rogan Dawes and Dominic White - universal serial aBUSe remote at...
DEF CON 24 - Rogan Dawes and Dominic White - universal serial aBUSe remote at...DEF CON 24 - Rogan Dawes and Dominic White - universal serial aBUSe remote at...
DEF CON 24 - Rogan Dawes and Dominic White - universal serial aBUSe remote at...
 
DEF CON 24 - Jay Beale and Larry Pesce - phishing without frustration
DEF CON 24 - Jay Beale and Larry Pesce - phishing without frustrationDEF CON 24 - Jay Beale and Larry Pesce - phishing without frustration
DEF CON 24 - Jay Beale and Larry Pesce - phishing without frustration
 
DEF CON 24 - Gorenc Sands - hacker machine interface
DEF CON 24 - Gorenc Sands - hacker machine interfaceDEF CON 24 - Gorenc Sands - hacker machine interface
DEF CON 24 - Gorenc Sands - hacker machine interface
 
DEF CON 24 - Allan Cecil and DwangoAC - tasbot the perfectionist
DEF CON 24 - Allan Cecil and DwangoAC -  tasbot the perfectionistDEF CON 24 - Allan Cecil and DwangoAC -  tasbot the perfectionist
DEF CON 24 - Allan Cecil and DwangoAC - tasbot the perfectionist
 
DEF CON 24 - Rose and Ramsey - picking bluetooth low energy locks
DEF CON 24 - Rose and Ramsey - picking bluetooth low energy locksDEF CON 24 - Rose and Ramsey - picking bluetooth low energy locks
DEF CON 24 - Rose and Ramsey - picking bluetooth low energy locks
 
DEF CON 24 - Rich Mogull - pragmatic cloud security
DEF CON 24 - Rich Mogull - pragmatic cloud securityDEF CON 24 - Rich Mogull - pragmatic cloud security
DEF CON 24 - Rich Mogull - pragmatic cloud security
 
DEF CON 24 - Grant Bugher - Bypassing captive portals
DEF CON 24 - Grant Bugher - Bypassing captive portalsDEF CON 24 - Grant Bugher - Bypassing captive portals
DEF CON 24 - Grant Bugher - Bypassing captive portals
 
DEF CON 24 - Patrick Wardle - 99 problems little snitch
DEF CON 24 - Patrick Wardle - 99 problems little snitchDEF CON 24 - Patrick Wardle - 99 problems little snitch
DEF CON 24 - Patrick Wardle - 99 problems little snitch
 
DEF CON 24 - Plore - side -channel attacks on high security electronic safe l...
DEF CON 24 - Plore - side -channel attacks on high security electronic safe l...DEF CON 24 - Plore - side -channel attacks on high security electronic safe l...
DEF CON 24 - Plore - side -channel attacks on high security electronic safe l...
 
DEF CON 24 - Six Volts and Haystack - cheap tools for hacking heavy trucks
DEF CON 24 - Six Volts and Haystack - cheap tools for hacking heavy trucksDEF CON 24 - Six Volts and Haystack - cheap tools for hacking heavy trucks
DEF CON 24 - Six Volts and Haystack - cheap tools for hacking heavy trucks
 
DEF CON 24 - Dinesh and Shetty - practical android application exploitation
DEF CON 24 - Dinesh and Shetty - practical android application exploitationDEF CON 24 - Dinesh and Shetty - practical android application exploitation
DEF CON 24 - Dinesh and Shetty - practical android application exploitation
 
DEF CON 24 - Klijnsma and Tentler - stargate pivoting through vnc
DEF CON 24 - Klijnsma and Tentler - stargate pivoting through vncDEF CON 24 - Klijnsma and Tentler - stargate pivoting through vnc
DEF CON 24 - Klijnsma and Tentler - stargate pivoting through vnc
 
DEF CON 24 - Antonio Joseph - fuzzing android devices
DEF CON 24 - Antonio Joseph - fuzzing android devicesDEF CON 24 - Antonio Joseph - fuzzing android devices
DEF CON 24 - Antonio Joseph - fuzzing android devices
 

Recently uploaded

#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 

Recently uploaded (20)

#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 

Defcon 23 - Daniel Selifonov - drinking from LETHE

  • 1. Drinking from LETHE: New methods of exploiting and mitigating memory corruption vulnerabilities Daniel Selifonov DEF CON 23 August 7, 2015
  • 2. Show of Hands 1. Have you written programs in C or C++? 2. Have you implemented a classic stack smash exploit? 3. … a return-to-libc or return-oriented- programming exploit? 4. … a return-to-libc or ROP exploit that used memory disclosure or info leaks?
  • 3. Motivations ● Software is rife with memory corruption vulnerabilities ● Most memory corruption vulnerabilities are directly applicable to code execution exploits ● And there's no end in sight...
  • 4. Motivations (II) ● Industrialized ecosystem of vulnerability discovery and brokering weaponized exploits ● Little of this discovery process feeds into fixes... The other AFL
  • 5. Motivations (III) ● State actor (e.g. NSA Tailored Access Operations group) budgets: ≈ $∞ ● Bug bounties just drive up prices ● Target supply, not demand for exploits...
  • 6. The Plan ● Sever the path between vulnerability and (reliable) exploit ● Why do programmers keep hitting this fundamental blindspot? ● Defenses are born in light of attack strategies
  • 7. Memory Safety #include <stdio.h> int main() { foo(); bar(11, 12); return 0; } void foo() { int a; char b[23]; gets(b); printf("Hey %s!n",b); } int bar(int x, int y) { return x + y; }
  • 8. Memory Safety #include <stdio.h> int main() { foo(); bar(11, 12); return 0; } void foo() { int a; char b[23]; gets(b); printf("Hey %s!n",b); } int bar(int x, int y) { return x + y; }
  • 9. Memory Safety #include <stdio.h> int main() { foo(); bar(11, 12); return 0; } void foo() { int a; char b[23]; gets(b); printf("Hey %s!n",b); } int bar(int x, int y) { return x + y; } <return address to C runtime exit>
  • 10. Memory Safety #include <stdio.h> int main() { foo(); bar(11, 12); return 0; } void foo() { int a; char b[23]; gets(b); printf("Hey %s!n",b); } int bar(int x, int y) { return x + y; } <return address to C runtime exit>
  • 11. Memory Safety #include <stdio.h> int main() { foo(); bar(11, 12); return 0; } void foo() { int a; char b[23]; gets(b); printf("Hey %s!n",b); } int bar(int x, int y) { return x + y; } <return address to C runtime exit> <return address to >
  • 12. Memory Safety #include <stdio.h> int main() { foo(); bar(11, 12); return 0; } void foo() { int a; char b[23]; gets(b); printf("Hey %s!n",b); } int bar(int x, int y) { return x + y; } <return address to C runtime exit> <return address to >
  • 13. Memory Safety #include <stdio.h> int main() { foo(); bar(11, 12); return 0; } void foo() { int a; char b[23]; gets(b); printf("Hey %s!n",b); } int bar(int x, int y) { return x + y; } <return address to C runtime exit> <return address to > <4 bytes for 'int a'>
  • 14. Memory Safety #include <stdio.h> int main() { foo(); bar(11, 12); return 0; } void foo() { int a; char b[23]; gets(b); printf("Hey %s!n",b); } int bar(int x, int y) { return x + y; } <return address to C runtime exit> <return address to > <4 bytes for 'int a'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'>
  • 15. Memory Safety #include <stdio.h> int main() { foo(); bar(11, 12); return 0; } void foo() { int a; char b[23]; gets(b); printf("Hey %s!n",b); } int bar(int x, int y) { return x + y; } <return address to C runtime exit> <return address to > <4 bytes for 'int a'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'>
  • 16. Memory Safety #include <stdio.h> int main() { foo(); bar(11, 12); return 0; } void foo() { int a; char b[23]; gets(b); printf("Hey %s!n",b); } int bar(int x, int y) { return x + y; } <return address to C runtime exit> <return address to > <4 bytes for 'int a'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <return address to >
  • 17. Memory Safety #include <stdio.h> int main() { foo(); bar(11, 12); return 0; } void foo() { int a; char b[23]; gets(b); printf("Hey %s!n",b); } int bar(int x, int y) { return x + y; } <return address to C runtime exit> <return address to > <4 bytes for 'int a'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'>
  • 18. Memory Safety #include <stdio.h> int main() { foo(); bar(11, 12); return 0; } void foo() { int a; char b[23]; gets(b); printf("Hey %s!n",b); } int bar(int x, int y) { return x + y; } <return address to C runtime exit> <return address to > <4 bytes for 'int a'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <return address to >
  • 19. Memory Safety #include <stdio.h> int main() { foo(); bar(11, 12); return 0; } void foo() { int a; char b[23]; gets(b); printf("Hey %s!n",b); } int bar(int x, int y) { return x + y; } <return address to C runtime exit> <return address to > <4 bytes for 'int a'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'>
  • 20. Memory Safety #include <stdio.h> int main() { foo(); bar(11, 12); return 0; } void foo() { int a; char b[23]; gets(b); printf("Hey %s!n",b); } int bar(int x, int y) { return x + y; } <return address to C runtime exit> <return address to >
  • 21. Memory Safety #include <stdio.h> int main() { foo(); bar(11, 12); return 0; } void foo() { int a; char b[23]; gets(b); printf("Hey %s!n",b); } int bar(int x, int y) { return x + y; } <return address to C runtime exit>
  • 22. Memory Safety #include <stdio.h> int main() { foo(); bar(11, 12); return 0; } void foo() { int a; char b[23]; gets(b); printf("Hey %s!n",b); } int bar(int x, int y) { return x + y; } <return address to C runtime exit> <return address to >
  • 23. Memory Safety #include <stdio.h> int main() { foo(); bar(11, 12); return 0; } void foo() { int a; char b[23]; gets(b); printf("Hey %s!n",b); } int bar(int x, int y) { return x + y; } <return address to C runtime exit> <return address to >
  • 24. Memory Safety #include <stdio.h> int main() { foo(); bar(11, 12); return 0; } void foo() { int a; char b[23]; gets(b); printf("Hey %s!n",b); } int bar(int x, int y) { return x + y; } <return address to C runtime exit>
  • 25. Memory Safety #include <stdio.h> int main() { foo(); bar(11, 12); return 0; } void foo() { int a; char b[23]; gets(b); printf("Hey %s!n",b); } int bar(int x, int y) { return x + y; }
  • 27. Smashing the Stack (1996) #include <stdio.h> int main() { foo(); bar(11, 12); return 0; } void foo() { int a; char b[23]; gets(b); printf("Hey %s!n",b); } int bar(int x, int y) { return x + y; } <return address to > <return address to C runtime exit> <4 bytes for 'int a'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <return address to >
  • 28. Smashing the Stack (1996) #include <stdio.h> int main() { foo(); bar(11, 12); return 0; } void foo() { int a; char b[23]; gets(b); printf("Hey %s!n",b); } int bar(int x, int y) { return x + y; } <return address to > <return address to C runtime exit> <4 bytes for 'int a'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <return address to >
  • 29. Smashing the Stack (1996) #include <stdio.h> int main() { foo(); bar(11, 12); return 0; } void foo() { int a; char b[23]; gets(b); printf("Hey %s!n",b); } int bar(int x, int y) { return x + y; } <return address to > <return address to C runtime exit> <4 bytes for 'int a'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <return address to >
  • 30. Smashing the Stack (1996) #include <stdio.h> int main() { foo(); bar(11, 12); return 0; } void foo() { int a; char b[23]; gets(b); printf("Hey %s!n",b); } int bar(int x, int y) { return x + y; } <return address to > <return address to C runtime exit> <4 bytes for 'int a'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <return address to >
  • 31. Smashing the Stack (1996) #include <stdio.h> int main() { foo(); bar(11, 12); return 0; } void foo() { int a; char b[23]; gets(b); printf("Hey %s!n",b); } int bar(int x, int y) { return x + y; } <return address to > <return address to C runtime exit> <4 bytes for 'int a'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'>
  • 32. Smashing the Stack (1996) #include <stdio.h> int main() { foo(); bar(11, 12); return 0; } void foo() { int a; char b[23]; gets(b); printf("Hey %s!n",b); } int bar(int x, int y) { return x + y; } <return address to > <4 bytes for 'int a'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'>
  • 33. Smashing the Stack (1996) #include <stdio.h> int main() { foo(); bar(11, 12); return 0; } void foo() { int a; char b[23]; gets(b); printf("Hey %s!n",b); } int bar(int x, int y) { return x + y; } <return address to > <4 bytes for 'int a'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'> <4 bytes for 'char b[]'>
  • 50. Page Table Entries 32 0 Physical address of next level Read/ Write User/ Supervisor
  • 51. Paging made fast: TLB 0xdeadbeef 11011110101011011011111011101111 1101111010 (890) 1011011011 (731)
  • 52. Paging made fast: TLB 0xdeadbeef 11011110101011011011111011101111 1101111010 (890) 1011011011 (731) Page (4096 bytes)
  • 53. Paging made fast: TLB 0xdeadbeef 11011110101011011011111011101111 1101111010 (890) 1011011011 (731) Page (4096 bytes)
  • 54. Paging made fast: TLB 0xdeadbeef 11011110101011011011111011101111 1101111010 (890) 1011011011 (731) Page (4096 bytes)
  • 55. Paging made fast: TLB 0xdeadbeef 11011110101011011011111011101111 1101111010 (890) 1011011011 (731) Page (4096 bytes) Virtual Address Physical Address Aggregate Permissions TLB Entry:
  • 56. PaX PAGEEXEC (2000) User/ Supervisor: Emulates Non-Exec Instruction TLB: Data TLB: Virtual Addr Physical Addr Permission Virtual Addr Physical Addr Permission Instruction Pointer: PaX Page Fault Strategy: if (supervisor page && IP on faulting page) { Terminate } else { Set user page in PTE Prime Data TLB Set supervisor page in PTE }
  • 57. PaX PAGEEXEC (2000) User/ Supervisor: Emulates Non-Exec Instruction TLB: Data TLB: Virtual Addr Physical Addr Permission Virtual Addr Physical Addr Permission Instruction Pointer: PaX Page Fault Strategy: if (supervisor page && IP on faulting page) { Terminate } else { Set user page in PTE Prime Data TLB Set supervisor page in PTE } 1
  • 58. PaX PAGEEXEC (2000) User/ Supervisor: Emulates Non-Exec Instruction TLB: Data TLB: Virtual Addr Physical Addr Permission Virtual Addr Physical Addr Permission Instruction Pointer: PaX Page Fault Strategy: if (supervisor page && IP on faulting page) { Terminate } else { Set user page in PTE Prime Data TLB Set supervisor page in PTE } 1
  • 59. PaX PAGEEXEC (2000) User/ Supervisor: Emulates Non-Exec Instruction TLB: Data TLB: Virtual Addr Physical Addr Permission Virtual Addr Physical Addr Permission Instruction Pointer: PaX Page Fault Strategy: if (supervisor page && IP on faulting page) { Terminate } else { Set user page in PTE Prime Data TLB Set supervisor page in PTE } 1
  • 60. PaX PAGEEXEC (2000) User/ Supervisor: Emulates Non-Exec Instruction TLB: Data TLB: Virtual Addr Physical Addr Permission Virtual Addr Physical Addr Permission Instruction Pointer: PaX Page Fault Strategy: if (supervisor page && IP on faulting page) { Terminate } else { Set user page in PTE Prime Data TLB Set supervisor page in PTE } 0
  • 61. PaX PAGEEXEC (2000) User/ Supervisor: Emulates Non-Exec Instruction TLB: Data TLB: Virtual Addr Physical Addr Permission Virtual Addr Physical Addr Permission Instruction Pointer: PaX Page Fault Strategy: if (supervisor page && IP on faulting page) { Terminate } else { Set user page in PTE Prime Data TLB Set supervisor page in PTE } 0
  • 62. PaX PAGEEXEC (2000) User/ Supervisor: Emulates Non-Exec Instruction TLB: Data TLB: Virtual Addr Physical Addr Permission Virtual Addr Physical Addr Permission Instruction Pointer: ~ User/~ PaX Page Fault Strategy: if (supervisor page && IP on faulting page) { Terminate } else { Set user page in PTE Prime Data TLB Set supervisor page in PTE } 0
  • 63. PaX PAGEEXEC (2000) User/ Supervisor: Emulates Non-Exec Instruction TLB: Data TLB: Virtual Addr Physical Addr Permission Virtual Addr Physical Addr Permission Instruction Pointer: ~ User/~ PaX Page Fault Strategy: if (supervisor page && IP on faulting page) { Terminate } else { Set user page in PTE Prime Data TLB Set supervisor page in PTE } 1
  • 64. PaX PAGEEXEC (2000) User/ Supervisor: Emulates Non-Exec Instruction TLB: Data TLB: Virtual Addr Physical Addr Permission Virtual Addr Physical Addr Permission Instruction Pointer: ~ User/~ PaX Page Fault Strategy: if (supervisor page && IP on faulting page) { Terminate } else { Set user page in PTE Prime Data TLB Set supervisor page in PTE } 1
  • 65. PaX PAGEEXEC (2000) User/ Supervisor: Emulates Non-Exec Instruction TLB: Data TLB: Virtual Addr Physical Addr Permission Virtual Addr Physical Addr Permission Instruction Pointer: ~ User/~ PaX Page Fault Strategy: if (supervisor page && IP on faulting page) { Terminate } else { Set user page in PTE Prime Data TLB Set supervisor page in PTE } 1
  • 66. PaX PAGEEXEC (2000) User/ Supervisor: Emulates Non-Exec Instruction TLB: Data TLB: Virtual Addr Physical Addr Permission Virtual Addr Physical Addr Permission Instruction Pointer: ~ User/~ PaX Page Fault Strategy: if (supervisor page && IP on faulting page) { Terminate } else { Set user page in PTE Prime Data TLB Set supervisor page in PTE } 1
  • 67. PaX PAGEEXEC (2000) User/ Supervisor: Emulates Non-Exec Instruction TLB: Data TLB: Virtual Addr Physical Addr Permission Virtual Addr Physical Addr Permission Instruction Pointer: ~ User/~ PaX Page Fault Strategy: if (supervisor page && IP on faulting page) { Terminate } else { Set user page in PTE Prime Data TLB Set supervisor page in PTE } ~ User/~ 1
  • 68. Page Level Permissions User Supervisor PaX/NX Not-Writable Read/Execute Read Writable Read/Write/Execute Read/Write For mapped pages:
  • 70. Return to libc (1997) ... <Shell code> <Shell code> <Shell code> <Shell code> <Shell code> <nop> <nop> <nop> <nop> <nop> <nop> <nop> <nop> <nop> <nop> <nop> <nop> <smashed return address to ~ >
  • 71. Return to libc (1997) ... <Shell code> <Shell code> <Shell code> <Shell code> <Shell code> <nop> <nop> <nop> <nop> <nop> <nop> <nop> <nop> <nop> <nop> <nop> <nop> <smashed return address to ~ >
  • 72. Return to libc (1997) ... sh” /bas “/bin <pointer to > <dummy value> <smashed ret to libc system() > ... <vulnerable buffer>
  • 73. Return to libc (1997) ... sh” /bas “/bin <pointer to > <dummy value> <smashed ret to libc system() > ... <vulnerable buffer> ... <pointer to “/bin/bash”> <saved return address> <local variable for system()> <local variable for system()> ... ...
  • 74. Return to libc (1997) ... sh” /bas “/bin <pointer to > <dummy value> <smashed ret to libc system() > ... <vulnerable buffer> ... <pointer to “/bin/bash”> <saved return address> <local variable for system()> <local variable for system()> ... ...
  • 75. Return Oriented Programming ('07) ... <argument popping gadget addr> <argument 2> <argument 1> <argument popping gadget addr> <gadget addr 2> <argument 2> <argument 1> <argument popping gadget addr> <gadget addr 1> push eax ret pop eax ret pop ebx ret mov [ebx],eax ret xchg ebx,esp ret pop edi pop ebp ret
  • 76. Address Space Layout Randomization (2003) 0...00 f...ff Stack Heap mmap Library A Library B Library C Program Code Stack Heap mmap Library A Library B Library C Program Code
  • 78. Offset Fix Ups Library Relative 0..00 libc
  • 79. Offset Fix Ups Library Relative 0..00 libc Library Relative 0..23: location of system()
  • 80. Offset Fix Ups Library Relative 0..00 libc Library Relative 0..23: location of system() Library Relative 0..46: location of printf()
  • 81. Offset Fix Ups Library Relative 0..00 libc Library Relative 0..23: location of system() Library Relative 0..46: location of printf() Randomized Virtual Addr for printf: 0xdefc0b46
  • 82. Offset Fix Ups Library Relative 0..00 libc Library Relative 0..23: location of system() Library Relative 0..46: location of printf() Randomized Virtual Addr for printf: 0xdefc0b46 Randomized Virtual Addr for system: 0xdefc0b23
  • 83. Offset Fix Ups Library Relative 0..00 libc Library Relative 0..23: location of system() Library Relative 0..46: location of printf() Randomized Virtual Addr for printf: 0xdefc0b46 Randomized Virtual Addr for system: 0xdefc0b23
  • 84. Fine Grained ASLR ● Smashing the Gadgets (2012) ● Address Space Layout Permutation (2006) lib-func-a lib-func-b lib-func-b lib-func-f lib-func-c lib-func-a lib-func-d lib-func-c lib-func-f lib-func-d Function level FG-ASLR: mov eax, [ebp-4] mov ebx, [ebp-8] add eax, ebx xor ecx, ecx push eax push ebx push ecx call foo mov edx, [ebp-4] mov esi, [ebp-8] add edx, esi xor edi, edi push edx push esi push edi call foo
  • 85. Just-in-Time Code Reuse (2013) Code Ptr: 0xdeadbeef
  • 86. Just-in-Time Code Reuse (2013) Code Ptr: 0xdeadbeef 4K Page @ 0xdeadb000
  • 87. Just-in-Time Code Reuse (2013) Code Ptr: 0xdeadbeef 4K Page @ 0xdeadb000 ... mov eax, [ebp-4] mov ebx, [ebp-8] add eax, ebx push eax push ebx call 0x64616d6e ...
  • 88. Just-in-Time Code Reuse (2013) Code Ptr: 0xdeadbeef 4K Page @ 0xdeadb000 ... mov eax, [ebp-4] mov ebx, [ebp-8] add eax, ebx push eax push ebx call 0x64616d6e ...
  • 89. Just-in-Time Code Reuse (2013) Code Ptr: 0xdeadbeef 4K Page @ 0xdeadb000 ... mov eax, [ebp-4] mov ebx, [ebp-8] add eax, ebx push eax push ebx call 0x64616d6e ... 4K Page @ 0x64616000
  • 90. Just-in-Time Code Reuse (2013) Code Ptr: 0xdeadbeef 4K Page @ 0xdeadb000 ... mov eax, [ebp-4] mov ebx, [ebp-8] add eax, ebx push eax push ebx call 0x64616d6e ... 4K Page @ 0x64616000
  • 91. Just-in-Time Code Reuse (2013) Code Ptr: 0xdeadbeef 4K Page @ 0xdeadb000 ... mov eax, [ebp-4] mov ebx, [ebp-8] add eax, ebx push eax push ebx call 0x64616d6e ... 4K Page @ 0x64616000
  • 92. The Value of One Pointer? Volcano and Hobbit: sold separately.
  • 94. C++ Virtual Function Tables Instance of class Dog Vtable ptr Member: name Member: age Member: breed Instance of class Cat Vtable ptr Member: name Member: fav. catnip Member: sharp claws? Function ptr: feed() Function ptr: pet() Function ptr: sound() Function ptr: feed() Function ptr: pet() Function ptr: sound() Animal → Dog, Animal → Cat class Cat : public Animal { … void sound() { printf(“Meow!”); } … } class Dog : public Animal { … void sound() { printf(“Woof!”); } … }
  • 95. C++ Virtual Function Tables Instance of class Dog Vtable ptr Member: name Member: age Member: breed Instance of class Cat Vtable ptr Member: name Member: fav. catnip Member: sharp claws? Function ptr: feed() Function ptr: pet() Function ptr: sound() Function ptr: feed() Function ptr: pet() Function ptr: sound() Animal → Dog, Animal → Cat class Cat : public Animal { … void sound() { printf(“Meow!”); } … } class Dog : public Animal { … void sound() { printf(“Woof!”); } … }
  • 96. Knights and Knaves Instance of class Dog Vtable ptr Member: name Member: age Member: breed Function ptr: feed() Function ptr: pet() Function ptr: sound()
  • 97. Knights and Knaves Instance of class Dog Vtable ptr Member: name Member: age Member: breed Function ptr: feed() Function ptr: pet() Function ptr: sound() Function ptr? feed() Function ptr? feed() Function ptr? feed() Function ptr? pet() Function ptr? pet() Function ptr? pet() Function ptr? sound() Function ptr? sound() Function ptr? sound()
  • 98. Knights and Knaves Instance of class Dog Vtable ptr Member: name Member: age Member: breed Function ptr? feed() Function ptr? feed() Function ptr? feed() Function ptr? pet() Function ptr? pet() Function ptr? pet() Function ptr? sound() Function ptr? sound() Function ptr? sound()
  • 99. Knights and Knaves Instance of class Dog Vtable ptr Member: name Member: age Member: breed Function ptr? feed() Function ptr? feed() Function ptr? feed() Function ptr? pet() Function ptr? pet() Function ptr? pet() Function ptr? sound() Function ptr? sound() Function ptr? sound()
  • 100. Knights and Knaves Instance of class Dog Vtable ptr Member: name Member: age Member: breed Function ptr? feed() Function ptr? feed() Function ptr? feed() Function ptr? pet() Function ptr? pet() Function ptr? pet() Function ptr? sound() Function ptr? sound() Function ptr? sound()
  • 101. Execute Only Memory Code Ptr: 0xdeadbeef 4K Page @ 0xdeadb000 ... mov eax, [ebp-4] mov ebx, [ebp-8] add eax, ebx push eax push ebx call 0x64616d6e ...
  • 102. Execute Only Memory Code Ptr: 0xdeadbeef 4K Page @ 0xdeadb000 ... mov eax, [ebp-4] mov ebx, [ebp-8] add eax, ebx push eax push ebx call 0x64616d6e ...
  • 103. Necessary vs. Sufficient ● Code reuse requires: – No ASLR: A priori knowledge of place – ASLR: A priori knowledge of relative place + runtime discovery of offset – FG-ASLR: Runtime discovery of value at discovered place ● No runtime discovery? No discovery of value or place and no code to reuse: – XO-M + FG-ASLR = <3
  • 104. Elephant in the Room Two words: memory overhead https://www.flickr.com/photos/mobilestreetlife/4179063482
  • 105. Blunting the Edge ● Oxymoron (2014) – Key idea: call fs:0x100 mov eax, [ebp-4] mov ebx, [ebp-8] add eax, ebx xor ecx, ecx push eax push ebx push ecx call fs:0x100 ... 0x110: jmp ... 0x10c: jmp ... 0x108: jmp ... 0x104: jmp ... 0x100: jmp 0xdefc23defc23 0xfc: jmp ... 0xf8: jmp ... 0xf4: jmp ... ... Start of fs segment at random addr...
  • 106. Xen, Linux, & LLVM ● Xen 4.4 introduced PVH mode (Xen 4.5 → PVH dom0) – PVH uses Intel Extended Page Tables for PFN → MFN translations – EPT supports explicit R/W/E permissions ● Linux mprotect M_EXECUTE & ~M_READ sets EPT through Xen – Xen injects violations into Linux #PF handler ● LLVM for FG-ASLR and execute-only codegen
  • 108. Takeaways Non-Writable Readable EPT ~R X Read/Execute Execute Only NX Read Nothing Writable Readable EPT ~R X Read/Write/Execute Write/Execute NX Read/Write Write
  • 109. Takeaways Non-Writable Readable EPT ~R X Read/Execute Execute Only NX Read Nothing Writable Readable EPT ~R X Read/Write/Execute Write/Execute NX Read/Write Write Constant Data
  • 110. Takeaways Non-Writable Readable EPT ~R X Read/Execute Execute Only NX Read Nothing Writable Readable EPT ~R X Read/Write/Execute Write/Execute NX Read/Write Write Constant Data Stack/Heap/mmap
  • 111. Takeaways Non-Writable Readable EPT ~R X Read/Execute Execute Only NX Read Nothing Writable Readable EPT ~R X Read/Write/Execute Write/Execute NX Read/Write Write Constant Data Stack/Heap/mmap Program/Library Code
  • 112. Takeaways Non-Writable Readable EPT ~R X Read/Execute Execute Only NX Read Nothing Writable Readable EPT ~R X Read/Write/Execute Write/Execute NX Read/Write Write Constant Data Stack/Heap/mmap Program/Library Code
  • 113. Takeaways Non-Writable Readable EPT ~R X Read/Execute Execute Only NX Read Nothing Writable Readable EPT ~R X Read/Write/Execute Write/Execute NX Read/Write Write Constant Data Stack/Heap/mmap Program/Library Code
  • 114. Takeaways Non-Writable Readable EPT ~R X Read/Execute Execute Only NX Read Nothing Writable Readable EPT ~R X Read/Write/Execute Write/Execute NX Read/Write Write Constant Data Stack/Heap/mmap Program/Library Code
  • 115. FIN ● Code: <TBD> ● White Paper: <TBD> ● Email: ds@thyth.com ● Twitter: @dsThyth ● PGP: – 201a 7b59 a15b e5f0 bc37 08d3 bc7f 39b2 dfc0 2d75