230 likes | 351 Views
CS457 – Introduction to Information Systems Security Software 3. Elias Athanasopoulos elathan@ics.forth.gr. Software Exploitation – High Level. Exploit Code. HACKED. Vulnerable Software (e.g., web browser). Input (malicious web page). Renders malicious page. Introduce new control flows.
E N D
CS457 – Introduction to Information Systems SecuritySoftware 3 Elias Athanasopoulos elathan@ics.forth.gr
Software Exploitation – High Level Exploit Code HACKED Vulnerable Software (e.g., web browser) Input (malicious web page) Renders malicious page Introduce new control flows Exploit Runs Collect Gadgets Build ROP Chain Exec ROP Chain Elias Athanasopoulos
How the ROP chain works? –use esp as the instruction pointer TEXT Section (Code) ROP Chain Addr. of G1 G2; ret Addr. of G2 GN; ret Addr. of G3 G1; ret Addr. of GN G3; ret Elias Athanasopoulos
Heap Overflows Attacker does NOT control the stack! Jump to Gadget Vulnerability (VTableptr) …; ret Stack Heap Data Text (*)f() G1 High Address Low Address Elias Athanasopoulos
Stack Pivoting Execute the rest of the ROP chain Force %esp to point to heap Jump to Gadget Stack Pivoting Vulnerability (VTableptr) xchg %eax,%esp; ret Stack Heap Data Text (*)f() G1 High Address Low Address Elias Athanasopoulos
Defending ROP Elias Athanasopoulos
Randomization • ASLR • Address Space Layout Randomization • Fine-grained Randomization • Smashing the gadgets • Binary Stirring Elias Athanasopoulos
ASLR (demo) Elias Athanasopoulos
Fine-grained Randomization • Shuffle instructions, without changing the semantics Elias Athanasopoulos
Information Disclosure Bugs • String formatting bugs intmain() { charlocalStr[100]; printf("Username? "); fgets(localStr, sizeof(localStr), stdin); printf(localStr); printf("What is the access code? "); … } localStr= "AAAA %08x %08x %08x"; Elias Athanasopoulos
Just-in-time ROP Elias Athanasopoulos
Control-Flow Integrity (CFI) Elias Athanasopoulos
Ideal CFI Two problems: CFG discovery (especially in legacy apps) Performance in checks Elias Athanasopoulos
Coarse-grained (loose) CFI Elias Athanasopoulos
Gadgets under CFI Elias Athanasopoulos
Linking Gadgets under CFI Elias Athanasopoulos
Exploitation under CFI Elias Athanasopoulos
Run-time ROP detection (kBouncer) Elias Athanasopoulos
kBouncer Elias Athanasopoulos
kBouncer Checks • call-ret pairing • Coarse-grained CFI • Heuristics • Up to 20 instructions is considered a gadget • 6 gadgets in a row is considered an attack Elias Athanasopoulos
kBouncer Heuristics Elias Athanasopoulos
Bypassing kBouncer Elias Athanasopoulos
kBouncer bypass PoC Elias Athanasopoulos