Outline. Cyber Kill Chain. MTD Categories. Introduction of Moving Target Defense. How to defeat Buffer Overflow attacks?

Similar documents
Outline. AIT 682: Network and Systems Security. Introduction of Moving Target Defense. How to defeat Buffer Overflow attacks?

AIT 682: Network and Systems Security

Smart Attacks require Smart Defence Moving Target Defence

Survey of Cyber Moving Targets. Presented By Sharani Sankaran

Cyber Moving Targets. Yashar Dehkan Asl

Secure Software Development: Theory and Practice

CSE 565 Computer Security Fall 2018

Software Security II: Memory Errors - Attacks & Defenses

CSE 127: Computer Security Control Flow Hijacking. Kirill Levchenko

Beyond Stack Smashing: Recent Advances in Exploiting. Jonathan Pincus(MSR) and Brandon Baker (MS)

Program Security and Vulnerabilities Class 2

1/31/2007 C. Edward Chow. CS591 Page 1

Fundamentals of Computer Security

Software Security: Buffer Overflow Defenses

CS 161 Computer Security

20: Exploits and Containment

Runtime Defenses against Memory Corruption

Software Security: Buffer Overflow Attacks (continued)

Buffer overflow background

Software Security: Buffer Overflow Attacks

Basic Buffer Overflows

2 Sadeghi, Davi TU Darmstadt 2012 Secure, Trusted, and Trustworthy Computing Chapter 6: Runtime Attacks

CS 645: Lecture 3 Software Vulnerabilities. Rachel Greenstadt July 3, 2013

Security and Privacy in Computer Systems. Lecture 5: Application Program Security

Software Vulnerabilities August 31, 2011 / CS261 Computer Security

CSE 127: Computer Security. Memory Integrity. Kirill Levchenko

ECE 471 Embedded Systems Lecture 22

CMPSC 497 Buffer Overflow Vulnerabilities

Buffer Overflow and Protection Technology. Department of Computer Science,

CSE 509: Computer Security

On The Effectiveness of Address-Space Randomization. H. Shacham, M. Page, B. Pfaff, E.-J. Goh, N. Modadugu, and D. Boneh Stanford University CCS 2004

Heap Off by 1 Overflow Illustrated. Eric Conrad October 2007

Lecture 4 September Required reading materials for this class

Module: Return-oriented Programming. Professor Trent Jaeger. CSE543 - Introduction to Computer and Network Security

CNIT 127: Exploit Development. Ch 14: Protection Mechanisms. Updated

Betriebssysteme und Sicherheit Sicherheit. Buffer Overflows

ISA564 SECURITY LAB. Code Injection Attacks

Module: Return-oriented Programming. Professor Trent Jaeger. CSE543 - Introduction to Computer and Network Security

Inject malicious code Call any library functions Modify the original code

CS 161 Computer Security

CSCE 548 Building Secure Software Buffer Overflow. Professor Lisa Luo Spring 2018

Hacking Blind BROP. Presented by: Brooke Stinnett. Article written by: Andrea Bittau, Adam Belay, Ali Mashtizadeh, David Mazie`res, Dan Boneh

Hackveda Training - Ethical Hacking, Networking & Security

Lecture 08 Control-flow Hijacking Defenses

Buffer. This time. Security. overflows. Software. By investigating. We will begin. our 1st section: History. Memory layouts

COMP3441 Lecture 7: Software Vulnerabilities

Lecture 1: Buffer Overflows

Play with FILE Structure Yet Another Binary Exploitation Technique. Abstract

Software Security: Buffer Overflow Defenses and Miscellaneous

We will focus on Buffer overflow attacks SQL injections. See book for other examples

Buffer Overflow. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

BUFFER OVERFLOW. Jo, Heeseung

Buffer Overflow. Jo, Heeseung

Return-orientated Programming

Buffer Overflow. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Buffer overflow is still one of the most common vulnerabilities being discovered and exploited in commodity software.

Lecture Embedded System Security A. R. Darmstadt, Runtime Attacks

Fundamentals of Linux Platform Security

Stack Vulnerabilities. CS4379/5375 System Security Assurance Dr. Jaime C. Acosta

Outline. Format string attack layout. Null pointer dereference

Buffer Overflow Attacks

SoK: Eternal War in Memory

Software Security (cont.): Defenses, Adv. Attacks, & More

Hacking Blind. Andrea Bittau, Adam Belay, Ali Mashtizadeh, David Mazières, Dan Boneh. Stanford University

C and C++ Secure Coding 4-day course. Syllabus

Secure Systems Engineering

ECS 153 Discussion Section. April 6, 2015

CNIT 127: Exploit Development. Ch 3: Shellcode. Updated

Ethical Hacking and Countermeasures: Web Applications, Second Edition. Chapter 3 Web Application Vulnerabilities

Introduction to Operating Systems Prof. Chester Rebeiro Department of Computer Science and Engineering Indian Institute of Technology, Madras

Vulnerabilities. Code Injection - Buffer overflows. Some Commonly Exploitable Flaws

Buffer Overflow. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Security and Authentication

Code with red border means vulnerable code. Code with green border means corrected code. This program asks the user for a password with the function

CMSC 414 Computer and Network Security

CS 161 Computer Security

Buffer overflows (a security interlude) Address space layout the stack discipline + C's lack of bounds-checking HUGE PROBLEM

(Early) Memory Corruption Attacks

ANATOMY OF AN ATTACK!

Memory corruption vulnerability exposure can be mitigated through memory hardening practices

Different attack manifestations Network packets OS calls Audit records Application logs Different types of intrusion detection Host vs network IT

Outline. Heap meta-data. Non-control data overwrite

How to Sandbox IIS Automatically without 0 False Positive and Negative

Internetwork Expert s CCNA Security Bootcamp. Common Security Threats

Department of Electrical Engineering and Computer Science MASSACHUSETTS INSTITUTE OF TECHNOLOGY Fall Quiz I

Applications. Cloud. See voting example (DC Internet voting pilot) Select * from userinfo WHERE id = %%% (variable)

Understanding Cisco Cybersecurity Fundamentals

Smashing the Buffer. Miroslav Štampar

Undermining Information Hiding (And What to do About it)

Moving Target Techniques: Cyber Resilience through Randomization, Diversity, and Dynamism

Endpoint Security - what-if analysis 1

The Geometry of Innocent Flesh on the Bone

Secure Programming I. Steven M. Bellovin September 28,

Is stack overflow still a problem?

Module: Program Vulnerabilities. Professor Trent Jaeger. CSE543 - Introduction to Computer and Network Security

UMSSIA LECTURE I: SOFTWARE SECURITY

Buffer overflow prevention, and other attacks

Linux Memory Layout. Lecture 6B Machine-Level Programming V: Miscellaneous Topics. Linux Memory Allocation. Text & Stack Example. Topics.

Sandboxing Untrusted Code: Software-Based Fault Isolation (SFI)

Our Narrow Focus Computer Networking Security Vulnerabilities. Outline Part II

Transcription:

Outline Introduction of Moving Target Defense AIT 682: Network and Systems Security Topic 10. Moving Target Defenser Instructor: Dr. Kun Sun How to defeat Buffer Overflow attacks? Address Space Layout Randomization How to defeat port scanning attacks? IP/port randomization 2 What is Moving Target Defense (MTD)? Aim to substantially increase the cost of attacks by deploying and operating networks/systems to makes them less deterministic, less homogeneous, and less static. Continually shift and change over time to increase complexity and cost for attackers, limit the exposure of vulnerabilities and opportunities for attack, and increase system resiliency. Dynamically altered in ways that are manageable by the defender yet make the attack space appear unpredictable to the attacker. http://cybersecurity.nitrd.gov/page/moving-target 3 What is Moving Target Defense (MTD)? Also known as Cyber Maneuver, Adaptive Cyber Defense Reactive! Proactive Static! dynamic Enables defenders to create, analyze, evaluate, and deploy mechanisms and strategies that are continually shift and change over time to increase complexity and cost for attackers limit the exposure of vulnerabilities and opportunities for attack, and increase system resiliency. Against the expert in defense, the enemy does not know where to attack. --SunTzu 4 Cyber Kill Chain MTD Categories Put forth by Lockheed Martin to decribe phases of a targetd attack 1. Reconnaissance: The attacker collects useful information about the target. 2. Access: The attacker tries to connect or communicate with the target to identify its properties (versions, vulnerabilities, configurations, etc.). 3. Exploit Development: The attacker develops an exploit for a vulnerability in the system in order to gain a foothold or escalate his privilege. 4. Attack Launch: The attacker delivers the exploit to the target. This can be through a network connection, using phishing-like attacks, or using a more sophisticated supply chain or gap jumping attack (e.g., infected USB drive). 5. Persistence: The attacker installs additional backdoors or access channels to keep his persistence access to the system. System-based MTD Software-based Application, OS, Data Hardware-based: processor, FPGA, platform Network-based MTD MAC layer: changing MAC address IP layer: IP randomization TCP (Traffic) layer: changing network protocol Session layer 5 6 1

Software-based MTD Goals Prevent unwanted modification Protect software against analysis Types 1. Dynamic Runtime Environment: Address Space Layout Randomization (ASLR), Instruction Set Randomization, 2. Dynamic software: In-place code randomization, Compiler-based Software Diversity 3. Dynamic Data Network-based MTD Network reconnaissance is the first step for attackers to collect network and host information and prepare for future targeted attacks. Goal: make the scanning results expire soon or give the attacker a different view of the target system Examples: IP randomization, Port randomization 7 8 How to analyze one MTD? Specific threat model Technical details Cost and benefit Weakness and Improvements Threat Model Data leakage attacks, e.g., steal crypto keys from memory Denial of Service attacks, i.e., exhaust or manipulate resources in the systems Injection attacks Code injection: buffer overflow, ROP, SQL injection Control injection: return-oriented programming (ROP) Spoofing attack, e.g., man-in-the-middle Authentication exploitation: cross-cite scripting (XSS) Scanning, e.g., port scanning Physical attack: malicious processor 9 10 Outline Introduction of Moving Target Defense How to defeat Buffer Overflow attacks? Address Space Layout Randomization How to defeat port scanning attacks? IP/port randomization Threat Model Data leakage attacks, e.g., steal crypto keys from memory Denial of Service attacks, i.e., exhaust or manipulate resources in the systems Injection attacks Code injection: buffer overflow, return-oriented programming (ROP) Control injection: return-oriented programming (ROP) Spoofing attack, e.g., man-in-the-middle Authentication exploitation: cross-cite scripting (XSS) Scanning, e.g., port scanning Physical attack: malicious processor 11 12 2

Buffer Overflow A9acks Also known as Buffer overrun, BOF. First major exploit: 1988 Internet Worm, Robert Morris. May exploit buffer overflow in fingerd service. 26 years old techniques Heartbleed attack, 2014 Due to implementation bug on OpenSSL library "Fail to check the length of Heartbeat request message Leaking encryption key and user/password Easy to fix, but might have been used as a zero-day attack for at least two years. Computer Buffer Buffer: A contiguous block of computer memory, can be used for Data: variables (static/global, dynamic/local), arrays Code: user programs, shared libraries, kernel programs. To shield User/kernel programs from each other, virtual memory is used Within a virtual memory address space, different OS/ CPUs have different ways to allocate buffers. On Linux, static/global variables allocated at load time on the data segment, dynamic/local variables are allocated at run time on the stack. 13 14 Segment Layout of Linux Process What are BOF a9acks? They attack corrupts data values in memory adjacent to a buffer by writing outside its bounds Stack-based exploitation Discover vulnerable code Overwrite the return address New return address points to alternate code Inject shellcode in to the stack or use existing code (returnoriented programming, ROP) Heap-based exploitation Insert instructions in to the heap and then trick the program in to executing them. http://duartes.org/gustavo/blog/post/anatomy-of-a-program-in-memory/ 15 16 Stack Frame Stack Overflow Example Suppose a web server contains a function: char a[30]; void func(char *str) { char buf[128]; Parameters Return address Stack Frame Pointer strcpy(buf, str) do-something(buf); } When the function is invoked the stack looks like: buf sfp ret-addr str Lower What memory if *str address is 136 bytes long? After strcpy: top of stack SP Local variables Stack Growth Buf+132 *str sfp* Ret* str top of stack 17 Direction of copy operation 18 3

Basic Stack Exploit Main problem: no range checking in strcpy(). Suppose *str is such that after strcpy stack looks like: *str ret Code for P Program P: exec( /bin/sh ) top of stack When func() exits, the user will be given a shell. Note: attack code runs in stack. To determine ret guess position of stack when func() is called. BOF MiIgaIons Proper programming language application Safe library usage Executable Space Protection Address Space Layout Randomization (ASLR) Deep Packet Inspection (DPI) Pointer Protection 19 20 Problem: Lack of Diversity Buffer overflow and return-to-libc exploits need to know the (virtual) address to hijack control Address of attack code in the buffer Address of a standard kernel library routine Same address is used on many machines Slammer infected 75,000 MS-SQL servers using same code on every machine Idea: introduce artificial diversity Make stack addresses, addresses of library routines, etc. unpredictable and different from machine to machine prevents attackers from using the same exploit code against all instantiations of the same program. Address Space Layout RandomizaIon (ASLR) Randomly choose base address of stack, heap, code segment Randomly pad stack frames and malloc() calls Randomize location of Global Offset Table Randomization can be done at compile- or linktime, or by rewriting existing binaries Threat: attack repeatedly probes randomized binary 21 22 Segment Layout of Linux Process with PaX PaX Linux kernel patch Goal: prevent execution of arbitrary code in an existing process s memory space Enable executable/non-executable memory pages Any section not marked as executable in ELF binary is non-executable by default Stack, heap, anonymous memory regions Access control in mmap(), mprotect() prevents unsafe changes to protection state at runtime Randomize address space layout http://duartes.org/gustavo/blog/post/anatomy-of-a-program-in-memory/ 23 http://pax.grsecurity.net 24 4

PaX ASLR PaX applies ASLR to ELF binaries and dynamic libraries. User address space consists of three areas Executable, mapped, stack Base of each area shifted by a random delta (on x86) Executable: 16-bit random shift Program code, uninitialized data, initialized data Mapped: 16-bit random shift Heap, dynamic libraries, thread stacks, shared memory Stack: 24-bit random shift Main user stack PaX RANDUSTACK Responsible for randomizing userspace stack Userspace stack is created by the kernel upon each execve() system call Allocates appropriate number of pages Maps pages to process s virtual address space Userspace stack is usually mapped at 0xBFFFFFFF, but PaX chooses a random base address In addition to base address, PaX randomizes the range of allocated memory 25 26 PaX RANDKSTACK Linux assigns two pages of kernel memory for each process to be used during the execution of system calls, interrupts, and exceptions PaX randomizes each process s kernel stack pointer before returning from kernel to userspace 5 bits of randomness Each system call is randomized differently By contrast, user stack is randomized once when the user process is invoked for the first time PaX RANDMMAP Linux heap allocation: do_mmap() starts at the base of the process s unmapped memory and looks for the first unallocated chunk which is large enough PaX: add a random delta_mmap to the base address before looking for new memory 16 bits of randomness 27 28 PaX RANDEXEC Randomizes location of ELF binaries in memory Problem if the binary was created by a linker which assumed that it will be loaded at a fixed address and omitted relocation information PaX maps the binary to its normal location, but makes it non-executable + creates an executable mirror copy at a random location Access to the normal location produces a page fault Page handler redirects to the mirror if safe Looks for signatures of return-to-libc attacks and may result in false positives Base-Address RandomizaIon Only the base address is randomized Layouts of stack and library table remain the same Relative distances between memory objects are not changed by base address randomization To attack, it s enough to guess the base shift A 16-bit value can be guessed by brute force Try 2 15 (on average) overflows with different values for addr of known library function how long does it take? Shacham et al. attacked Apache with return-to-libc 216 seconds If address is wrong, target will simply crash 29 30 5

Summary Improvements Randomness is a potential defense mechanism Many issues for proper implementation Serious limitations on 32-bit architecture On 32-bit systems, runtime randomization cannot provide more than 16-20 bits of entropy Move to 64-bit architecture At least 40 bits of randomization Entropy is high enough, and easy to detect attacks of this magnitude. Frequent Re-randomization Randomize the address space layout of a process more frequently after process creation. Adds no more than 1 bit of security against brute force attacks regardless of the frequency, 2n-1 vs. 2n It can mitigate the damage when the layout of a fixed randomized address space is leaked through other channels How about being combined with a crash detection and reaction mechanism called watcher? May not respond quick enough May suffer from DoS attack 31 32 Outline Threat Model Data leakage attacks, e.g., steal crypto keys from memory Denial of Service attacks, i.e., exhaust or manipulate resources in the systems Injection attacks Code injection: buffer overflow, SQL injection Control injection: return-oriented programming (ROP) Spoofing attack, e.g., man-in-the-middle Authentication exploitation: cross-cite scripting (XSS) Scanning, e.g., port scanning, IP scanning for targeted attack Physical attack: malicious processor Introduction of Moving Target Defense How to defeat Buffer Overflow attacks? Address Space Layout Randomization How to defeat port scanning attacks? IP/port randomization 33 34 VM-based Dynamic Virtualized Network Dynamic Virtualized Network Topology 3-level decoys VM level: KVM OS level: OpenVZ/LXC Process level: Honeyd Dynamic Network Topology Centralized controller in the hypervisor 35 36 6

Two Challenges in Network-based MTD AuthenIcaIon Framework 1. Service availability Authenticated clients should always know the new IP address/port number. When the IP and Port changes, the connection still maintained, minimizing service downtime. 2. Service Security Only the authenticated users can access the service. How to mitigate insider attacks? 37 38 Live VM MigraIon VMware vmotion Three execution states for moving a VM without service interruption Disk state: shared storage such as SAN and NAS Memory state: trace phase => pre-copy phase => switchover phase Network State: Virtual switch, virtual NIC Require source and destination hosts on the same subnet. Migration should be fast to prevent network connection timeout. Our solution in MTD Currently, no need to transmit the disk and memory states Source and destination hosts can be on different subnets. Allows longer connection timeout for migration Seamless TCP ConnecIon MigraIon Keep end-to-end transport connection alive through separating transport endpoint identification from network endpoint identification. Three components Connection virtualization Connection translation Connection migration 39 40 ConnecIon VirtualizaIon ConnecIon TranslaIon Internal address for applications; IP and Ports never changes for one connection External address for communications IP and Ports may change according to MTD requirements A map to translate between Internal address and External address At beginning, internal address == external addresses Server changes its IP address 41 42 7

Network MigraIon After the server changes its IP address and port, it will inform the client to update the internalexternal address mapping. Migration Steps: protected by a shared secret key Suspend a connection Keep connection alive Resume a connection Update internal-external endpoints mappings Server sends UPDATE packet Client sends UPDATE_ACK packet Both endpoints need to know the same internal address pair. ImplementaIon All in a kernel module in Linux Support both client and server mobility Connection Virtualization Intercept socket system calls Connection Translation Instrument Netfilter hooks Connection Migration Migration daemon 43 44 Intercept System Calls Overwrite the function pointers in the system call table Intercept Accept() Connect() Close() Getsockname() Getpeername() For outgoing traffic NF_IP_LOCAL_OUT for destination address translation NF_IP_POSTROUTING for source address translation For incoming traffic NF_IP_PREROUTING for destination address translation NF_IP_LOCAL_IN for source address translation Instrument NeWilter hooks 45 46 MigraIon Daemon A Kernel thread as a server process Initiate the suspension after receiving a suspend event from APM Active the connection migration helper Restore the connection after receiving a resumption event from APM Exchange UPDATE and UPDATE_ACK packets to update the internal to external address mapping Cost and LimitaIon Require a large number of decoys (fake node) Memory, CPU, network overhead High-interaction vs. low-interaction decoys Cannot prevent insider attacks 47 48 8

References "Survey of Cyber Moving Targets", H. Okhravi, M.A. Rabe, T.J. Mayberry, W.G. Leonard, T.R. Hobson, D. Bigelow, W.W. Streilein, Technical Report, MIT Lincoln Laboratory, 2013. "On the EffecIveness of Address-Space RandomizaIon", Hovav Shacham and Ma9hew Page and Ben Pfaff and Eu-Jin Goh and Nagendra Modadugu and Dan Boneh, CCS 2004. Gustavo Duarte, Anatomy of a Program in Memory, h9p://duartes.org/ gustavo/blog/post/anatomy-of-a-program-in-memory/ www.cs.utexas.edu/~shmat/courses/cs380s_fall09/04aslr.ppt 49 9