360 likes | 632 Views
ROPecker : A Generic and Practical Approach for Defending against ROP Attacks. Yueqiang Cheng , Zongwei Zhou , Miao Yu, Xuhua Ding, Robert H. Deng NDSS 2014. Background . Typical memory exploit involves code injection Put malicious code in a predictable location
E N D
ROPecker: A Generic and Practical Approach for Defending against ROP Attacks Yueqiang Cheng, Zongwei Zhou, Miao Yu, Xuhua Ding, Robert H. Deng NDSS 2014
Background • Typical memory exploit involves code injection • Put malicious code in a predictable location • Pass control to it • non-executable (NX), WX • Hardware support • AMD “NX” bit, Intel “XD” bit (in post-2004 CPUs) • NX block most (if not all) code injection exploits
Return-Oriented Programming stack actions code low 0x080484f4: pop %eax ret ... 0x080484f6: mov (%eax), %eax ret ... 0x080484cf: call %eax; ret … 0x08048675: sh\0 … 0x0804a014: system addr eax = 0x0804a014 esp eax = system addr Call system(sh) high
ROP cont. • 0x080484f4: • pop %eax • ret • Gadgets • Codesection: functionality • Linking section: control transfer • indirect jump instruction (e.g., ret, call %eax, jmp %eax) • Aligned and unaligned • For non-fixed length instruction sets (e.g., x86) • SparseDistribution & Small size • ret-based ROP jmp/call-based ROP
Last Branch Record (LBR) • Dedicated Registers • (srcip, dstip) • 16 pairs available • Enabled through MSR • Accessible in Ring-0 • NOT distinguish processes
Existing Approaches • Prevention • Randomization: • Address Layout Space Randomization (ALSR) • Binary stirring (CCS’12) • Control flow integrity • CCFIR (S&P’13) • Detection • Abnormal behaviors • kBouncer, DROP
Check Every Ret • & Call-Ret-Pair Checking & Ret Frequency Checking Existing Approaches Remove Gadgets & Instruction Randomization ROPdefender [AsiaCCS’11] Enforce Control Flow Integrity & Remove Gadgets HyperCrop [ICISS’11] DROP [ICISS '09] Performance Overhead Low High ILR and Smashing [Oakland’12] Return-less [EuroSys’10] G-Free [ACSAC’10] Binary Stirring [CCS’12] CFLocking [ACSAC '11] No rewriting Binary rewriting Program binary Source code Requirments
Goals Detection & Prevention • Generic • ret-based & jmp/call-based • Transparent • w/o source code • keep the binary integrity • Low performance overhead
Methodology • How to detect • A long sequence of gadgets • When to detect • Sliding window • Within, no intervention • Out of the window, check • Critical system calls
Detection • Call-ret violation • Jmp/call-based attack • CFI • Completeness and accuracy • Victim’s Execution consists of • a long sequence of gadgets • chained by indirect branch instructions.
Feasibility Gadget chain length • Normal execution • Max length 10 • ROP execution • Min length 17 • Detection length
Time to detect • A sliding window • Within the window, no detection • When jump out, perform detection • Imple. • Only within the window, the code is executable • When jump out, page fault • Critical syscalls • mmap, mprotect, execev
Feasibility • Sliding window size • large: better performance & worse accuracy • small: better accuracy & worse performance • ROP requirement • 20KB code size • 8KB (2 pages) or 16KB (4 pages)
Algorithm • Filter non-relevant events • Check the history • Gadget chain length in LBRs • Search the future • Gadget chain length in the future • Continue / Crash
LBR record • NOT distinguish processes • Search backwards • Until context switch • (kernel IP, user IP) • Useful records • (context switch, Latest branch] 16 at most
Execution emulator • Search the future execution • Possible gadgets • ret – predictable • jmp/call – need emulation • shadow environment • copy-on-write execution
Pre-processing Phase ROPT Offline Processing Phase Arbitrary Binary Code Disassembly Engine Inst. & Gadget lists Inst. & Gadget Bit-Vectors Conversion Engine • 6 bytes each time • Byte by byte • Instruction & gadgets info
IG Database • memory mapping • syscall interception • data structure analysis
Architecture Stack … Run-time Phase Offline Phase libn App X Binary lib1 … CPU Apps Execution Trace Pre-processor ROPecker Kernel Module Instruction & Gadget Database Kernel
Implementation • Prototype • Ubuntu12.04 with kernel 3.2.0-29 • A kernel module with 7K SLOC • Checking points • #PF exception • Critical system calls • open, close • mmap2, munmap, mprotect • execve
Evaluation • Accuracy • Application with ROP attack • Normal applications • Performance • Micro-benchmark • Cost for system call interception, #PF exception • Cost for ROP checking • Macro benchmark • Benchmark suite
Security Evaluation • Real attacks • ROPeme • Htediter (exploitDB) • Generated by Q • Gadgets inside 253 apps under /bin & /usr/bin • All detected
SPEC INT2006 Benchmarks: CPU 2.6 % performance lose
Disk I/O Performance: Bonnie++ 1.56 % performance overhead
Conclusion • Generic detection of ROP attack • Sliding window checks • Implementation & evaluation
Discussions • Short gadget chain • Long gadget • ROP within sliding window • Dynamic sliding window size • Dynamically-generated code • Sliding window thrashing