1 Countering Code-Injection Attacks With Instruction-Set Randomization Gaurav S. Kc, Angelos D. Keromytis Columbia University Vassilis Prevelakis Drexel.

Slides:



Advertisements
Similar presentations
Operating Systems Components of OS
Advertisements

Practical Malware Analysis
Smashing the Stack for Fun and Profit
Introduction to Information Security ROP – Recitation 5 nirkrako at post.tau.ac.il itamarg at post.tau.ac.il.
Lecture 16 Buffer Overflow modified from slides of Lawrie Brown.
ITEC 352 Lecture 27 Memory(4). Review Questions? Cache control –L1/L2  Main memory example –Formulas for hits.
Buffer Overflow Prevention ”\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e \x89\xe3\x50\x53\x50\x54\x53\xb0\x3b\x50\xcd\x80” Presented to CRAB April.
Lecture 6 Machine Code: How the CPU is programmed.
Instruction-Set Randomization “Countering Code-Injection Attacks With Instruction-Set Randomization” G. Kc, A. Keromytis, and V. Prevelakis CCS October.
1 Operating Systems and Protection CS Goals of Today’s Lecture How multiple programs can run at once  Processes  Context switching  Process.
PC hardware and x86 3/3/08 Frans Kaashoek MIT
1 ICS 51 Introductory Computer Organization Fall 2006 updated: Oct. 2, 2006.
1 Lecture 5: Procedures Assembly Language for Intel-Based Computers, 4th edition Kip R. Irvine.
Memory Management. 2 How to create a process? On Unix systems, executable read by loader Compiler: generates one object file per source file Linker: combines.
Chapter 2: Impact of Machine Architectures What is the Relationship Between Programs, Programming Languages, and Computers.
1 RISE: Randomization Techniques for Software Security Dawn Song CMU Joint work with Monica Chew (UC Berkeley)
1 RAKSHA: A FLEXIBLE ARCHITECTURE FOR SOFTWARE SECURITY Computer Systems Laboratory Stanford University Hari Kannan, Michael Dalton, Christos Kozyrakis.
Lecture 16 Buffer Overflow
Efficient Instruction Set Randomization Using Software Dynamic Translation Michael Crane Wei Hu.
Attacks Using Stack Buffer Overflow Boxuan Gu
Web Application Access to Databases. Logistics Test 2: May 1 st (24 hours) Extra office hours: Friday 2:30 – 4:00 pm Tuesday May 5 th – you can review.
6.828: PC hardware and x86 Frans Kaashoek
Architecture Support for OS CSCI 444/544 Operating Systems Fall 2008.
Buffer Overflows : An In-depth Analysis. Introduction Buffer overflows were understood as early as 1972 The legendary Morris Worm made use of a Buffer.
Laface Operating System Design Booting a PC to run a kernel from Low memory VGA display.
Introduction: Exploiting Linux. Basic Concepts Vulnerability A flaw in a system that allows an attacker to do something the designer did not intend,
ITEC 352 Lecture 12 ISA(3). Review Buses Memory ALU Registers Process of compiling.
Mitigation of Buffer Overflow Attacks
Fall 2012 Chapter 2: x86 Processor Architecture. Irvine, Kip R. Assembly Language for x86 Processors 6/e, Chapter Overview General Concepts IA-32.
Lecture slides prepared for “Computer Security: Principles and Practice”, 3/e, by William Stallings and Lawrie Brown, Chapter 10 “Buffer Overflow”.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts.
Buffer Overflow CS461/ECE422 Spring Reading Material Based on Chapter 11 of the text.
CNIT 127: Exploit Development Ch 3: Shellcode. Topics Protection rings Syscalls Shellcode nasm Assembler ld GNU Linker objdump to see contents of object.
CNIT 127: Exploit Development Ch 1: Before you begin.
Operating Systems Security
Introduction to Information Security ROP – Recitation 5.
Wireless and Mobile Security
Chapter 2 Parts of a Computer System. 2.1 PC Hardware: Memory.
Full and Para Virtualization
Introduction Program File Authorization Security Theorem Active Code Authorization Authorization Logic Implementation considerations Conclusion.
Introduction Why are virtual machines interesting?
Where’s the FEEB?: Effectiveness of Instruction Set Randomization Nora Sovarel, David Evans, Nate Paul University of Virginia Computer Science USENIX Security.
Exploiting Instruction Streams To Prevent Intrusion Milena Milenkovic.
A Survey on Runtime Smashed Stack Detection 坂井研究室 M 豊島隆志.
October 1, 2003Serguei A. Mokhov, 1 SOEN228, Winter 2003 Revision 1.2 Date: October 25, 2003.
Memory Management. 2 How to create a process? On Unix systems, executable read by loader Compiler: generates one object file per source file Linker: combines.
DR. MIGUEL ÁNGEL OROS HERNÁNDEZ 2. Software de bajo nivel.
Hello world !!! ASCII representation of hello.c.
1 Introduction to Information Security , Spring 2016 Lecture 2: Control Hijacking (2/2) Avishai Wool.
E Virtual Machines Lecture 2 CPU Virtualization Scott Devine VMware, Inc.
Chapter 6 Limited Direct Execution Chien-Chung Shen CIS/UD
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
Introduction to Operating Systems Concepts
Chapter Overview General Concepts IA-32 Processor Architecture
Introduction to Information Security
Introduction to Operating Systems
Introduction to Information Security
Assembly language.
x86 Processor Architecture
William Stallings Computer Organization and Architecture 8th Edition
Jump Over ASLR: Attacking Branch Predictors to Bypass ASLR
Introduction to Operating Systems
Defeating Instruction Set Randomization Nora Sovarel
Fundamentals of Computer Organisation & Architecture
Machine-Level Programming: Introduction
Week 2: Buffer Overflow Part 1.
Introduction to Computer Systems
Program Assembly.
Computer Architecture and System Programming Laboratory
Presentation transcript:

1 Countering Code-Injection Attacks With Instruction-Set Randomization Gaurav S. Kc, Angelos D. Keromytis Columbia University Vassilis Prevelakis Drexel University

2 Overview of Technique Protect from code-injection attacks –create unique execution environment (instruction set) –invalidate attack vector –equally applicable for interpreted environments and native machine code (prototype designed for porting to hardware)

3 Outline Attack Techniques & Defense Mechanisms Instruction-Set Randomization (ISR) Using ISR to protect Linux processes in the Bochs x86 emulator Conclusions and Future Work

4 Attack Techniques Application-level attacks exploit flaws –Causes: Software bugs Poor programming practices Language features –Exploits: Buffer overflows, Format-string vulnerabilities Code-injection, Process subversion SQL / shell injection attacks

5 Defense Mechanisms Safer languages and libraries: Java, Cyclone, Libsafe, strl* Prevent and detect buffer overflows –Static code analyses: MOPS, MetaCompilation –Runtime stack protection: StackGuard, ProPolice,.NET /GS Sandboxing (profiling, monitoring) –Application-level sandboxes: Janus, Consh, ptrace, /proc –Kernel-based system-call interception: Tron, SubDomain –Virtual environments: VMWare, UML, Program shepherding, chroot Non-executable data areas –user stack/heap areas: PaX Team, SolarDesigner

6 Defense Mechanisms: problems Shortcomings of individual approaches –Languages/libraries: Stuck with C for systems, binary legacy applications –Prevent/detect overflows Bypass overflow-detection logic in stack –Application-level Sandboxing Overhead on system calls due to policy-based decision making –Non-executable data areas Protect only specific areas Best-effort ideology: grand unified scheme for protection, combining multiple techniques New proposed technique: –Instruction-set randomization: all injected code is disabled –Applicable across the board: Handle buffer overflow and SQL injection

7 Instruction sets of Attack code Match language / instruction set –SQL injection attacks –Embedded Perl code –x86 machine code Typical x86 shellcode "\xeb\x1f\x5e\x89\x76\x08\x31\xc0" "\x88\x46\x07\x89\x46\x0c\xb0\x0b" "\x89\xf3\x8d\x4e\x08\x8d\x56\x0c" "\xcd\x80\x31\xdb\x89\xd8\x40\xcd" "\x80\xe8\xdc\xff\xff\xff/bin/sh" x86 shellcode demystified 0xeb 1f : jmp IP + 1f 0x5e : pop %esi 0x : mov %esi, 08(%esi) 0x31 c0 : xor %eax, %eax 0x : mov %al, 07(%esi) 0x c : mov %eax, 0c(%esi) 0xb0 0b : mov 0b, %al 0x89 f3 : mov %esi, %ebx 0x8d 4e 08 : lea 08(%esi), %ecx 0x8d 56 0c : lea 0c(%esi), %edx 0xcd 80 : int $0x80 0x31 db : xor %ebx, %ebx 0x89 d8 : mov %ebx, %eax 0x40 : inc %eax 0xcd 80 : int $0x80 0xe8 dcffffff : call 0xdcffffff 1 2 execve prepare parameters

8 ISR: per-process instruction-set #1 reason for ISR: invalidate injected code Perl prototype: instruction-set randomization randomization of keywords, operators and function calls interpreter appends 9-digit “tag” to lexer tokens when loading parser rejects untagged code, e.g. injected Perl code foreach $k (sort keys %$tre) { $v = $tre->{$k}; die “duplicate key $k\n” if defined $list{$k} }; } foreach $k (sort keys %$tre) { $v = $tre->{$k}; die “duplicate key $k\n” if defined $list{$k} }; }

9 ISR: per-process instruction-set ISR x86: proof-of-concept Randomized code segments in programs Use objcopy for randomizing program image –Bit re-ordering within n-bit blocks (n! possibilities) 0x89d8 : : mov %ebx, %eax 0x40fc : : inc %eax –n-bit XOR mask (2 n possibilities) 0x89d8 ^ 0xc924 0x40fc Processor reverses randomization when executing instructions –Fetch - decode - execute –Fetch - de-randomize - decode - execute

10 Prototype: instruction-set randomization on modified x86 hardware ISR-aware objcopy(1) –Randomize executable content ISR-aware x86 emulator –De-randomize, execute instructions ISR-aware Linux kernel –Intermediary between randomized processes and de-randomizing hardware

11 ISR-aware objcopy(1) objcopy – copy and translate object files Executable and Linking Format (ELF) New ELF section to store key Using the key, randomize instruction blocks in the code sections in statically-compiled executables static void copy_section(...) { if (isection->flags & (SEC_LOAD|SEC_CODE)) // randomize-this-section-before-copy }

12 ISR-aware Bochs x86 emulator Emulator for Intel x86 CPU, common I/O devices, and a custom BIOS x86 extensions for hardware support: –new 16-bit register ( gav ) to store de-randomizing key –new instruction ( gavl ) for loading key into register –In user-mode execution fetchDecode loop  { fetch, de-randomize, decode } loop

13 ISR-aware Linux kernel Process control-block (PCB) for storing process-specific key –loader reads key from file and stores in PCB –scheduler loads key into special-purpose register ( gav ) from PCB using new x86 instruction ( gavl ) when switching process –key protected from illegal access and malicious modifications

14 Summary: ISR for x86 SOURCE CODE MACHINE EXECUTABLE FILE gcc -static key RANDOMIZED EXECUTABLE FILE key randomize via objcopy fetch de-randomize decode Modified x86

15 x86 shellcode – de-randomized 0xeb 1f : jmp IP + 1f 0x5e : pop %esi 0x : mov %esi, 08(%esi) 0x31 c0 : xor %eax, %eax 0x : mov %al, 07(%esi) 0x c : mov %eax, 0c(%esi) 0xb0 0b : mov 0b, %al 0x89 f3 : mov %esi, %ebx 0x8d 4e 08 : lea 08(%esi), %ecx 0x8d 56 0c : lea 0c(%esi), %edx 0xcd 80 : int $0x80 0x31 db : xor %ebx, %ebx 0x89 d8 : mov %ebx, %eax 0x40 : inc %eax 0xcd 80 : int $0x80 0xe8 dcffffff : call 0xdcffffff 0xcd d6 : int $0xd7 0x24 c9 : and $0xc9,%al 0x24 97 : and $0x97,%al 0xad : lods %ds:(%esi),%eax 0xbf 2c f8 e4 41 : mov $0x41e4f82c,%edi 0x62 ce : bound %ecx,%esi 0xad : lods %ds:(%esi),%eax 0x8f 28 : popl (%eax) 0x79 2f : jns 4a 0x40 : inc %eax 0xd7 : xlat %ds:(%ebx) 0x44 : inc %esp 0x6a c1 : push $0xffffffc1 0xa9 9f a4 : test $0xa404289f,%eax 0xf8 : clc 0xff 40 fc : incl 0xfffffffc(%eax) 0x89 e9 : mov %ebp,%ecx 0x49 : dec %ecx 0xcc : int3 0x1e : push %ds 0xdb 36 : (bad) (%esi) 0xdb 59 b4 : fistpl 0xffffffb4(%ecx)

16 emulation overhead Maximum computation overhead: x10 2 Services: ipchains, sshd (lower latency than hi-speed network from Wyndham)

17 Related work Randomized instruction set emulation to disrupt binary code injection attacks Elena Gabriela Barrantes, David H. Ackley, Stephanie Forrest, Trek S. Palmer, Darko Stefanovic and Dino Dai Zovi. University of New Mexico Valgrind x86-x86 binary translator (emulator) to de-scramble instruction sequences scrambled by loader –Attach Valgrind emulator to each randomized process Using our approach, we can run entire OS in Bochs

18 Limitations & Future Work Disadvantages: –Precludes self-modifying code –Requires statically-built programs –Local users can determine key from file system Future considerations and extensions: –Dynamically re-randomize process (or specific modules) –Extend x86 prototype to other operating systems and processor combinations –Extend Perl prototype to other scripting languages: shell, TCL, php –Re-implement on programmable hardware, e.g. Transmeta Find thesis topic

19 Conclusions Breach happens!! Hard to prevent code injection. Defang an attack by disabling execution of injected code –Give control to attacker vs. impose self-DoS by killing process –Brute-forcing to attack system makes worms infeasible –No modifications to program source code General approach to prevent any type of code-injection attack –Can take advantage of special hardware –Applicable to scripting languages