Bypassing Browser Memory Protections

Size: px
Start display at page:

Download "Bypassing Browser Memory Protections"

Transcription

1 Bypassing Browser Memory Protections Network Security Instructor: Dr. Shishir Nagaraja September 10, Introduction to the topic A number of memory protection mechanisms like GS, SafeSEH, DEP and ASLR have been employed in the Operating System by vendors, such mechanisms though at first site may appear to be secure, but there are loopholes in these techniques. These loopholes have been discussed in this paper. In particular the protection mechanisms in browsers and the way by which they can be circumvented, has been discussed in this paper at length. 2 Questions that the paper asks and how are those questions interesting This paper explores the memory protection mechanism in Windows and the way by which they can be circumvented. 3 How does it answer the questions In order to answer the questions that the paper asked by the paper, the author divides it into 3 sections SECTION 1: Available protection mechanisms. SECTION 2: Loopholes in these mechanisms. SECTION 3: Practically exploiting these loopholes. SECTION 1: AVAILABLE PROTECTION MECHANISMS 1. GS /GS option when enabled, prevents the return address of the functions from being overwritten due to buffer overflows. Also the compiler stores an arbitrary value on the stack at an address, just before the return address of a function. One disadvantage of GS protection is that the corrupt cookie value will only be detected when the function returns. If the function uses any other variable before this detection, then the attacker might take control of the execution. In order to prevent the above mentioned flaw, string buffer are placed after the other variables. Whereas, if the arguments contain pointers or string, they are copied before the variables. 2. SafeSEH: Safe Structured Exception Handler protection mechanism was designed to forbid attackers from overwriting exception handlers. Overwritten exception handlers may be exploited by first throwing 1

2 an exception, thus in effect redirecting the program flow to the exception handler and then executing the malicious code in the overwritten exception handlers. In order to forbid attackers from such an attack, /SafeSEH linker option contains a list of valid exception handlers stored in a table. When an exception occurs the exception thrown can be verified against a table of exception handlers. Windows server 2008 introduced a new Structured Exception Handling mechanism. It uses a linked list of exception handlers, with the last exception handler in the list being the FinalExceptionHandler function. This mechanism is useful as it prevents the attackers from overwriting exception handler records. In order to verify that a given exception handler is a valid one, the exception dispatcher traverses this linked list and checks that the last linked list node is still FinalException- Handler. Although this protection mechanism also has loopholes. One amongst them being: an attacker changes the NEXT pointer to point to a bogus Structured Exception Handler record, this bogus SEH in turn points to the FinalExceptionHandler function. HEAP PROTECTION: In order to abuse the heap protection, the attacker may overwrite the header of the heap block and create his own flink and blink pointers. When this memory block is coalesced with other free chunks, then the value at the flink pointer is written into the value at the blink pointer. Thus in effect we are performing a write operation, which in turn helps the attacker to execute the malicious code. The above problem may be done away by safe unlinking. In safe unlinking it is checked before performing each write that flink points to blink and blink points to flink. In addition to safe unlinking a cookie is added to the header of each heap block, in order to protect the header from being changed. This is the same technique as the one used in protecting the return address of a function in a stack with a cookie. 3. DATA EXECUTION PREVENTION: Data Execution Prevention or DEP is a method which when enabled provides protection by prohibiting an attacker from executing his code in the non-executable region of memory. In case a trusted process needs to execute its code, then it needs to call VirtualAlloc or VirtualProtect, to grant it executable memory In order to mark memory regions as executable or non-executable, NX bit or No Execute bit has been added to the page table of x86 family of CPU. Due to the non compatibility of some applications with DEP Protection, the following Data Execution Prevention policies are available: (a) OptIn: DEP protection is available for processes that specifically ask for it. (b) OptOut: DEP protection is by default given to all processes, except to those processes that explicitly opt out of it. (c) AlwaysOn: All processes are given a DEP protection. (d) AlwaysOff: DEP protection is not given to any process. 4. ASLR (ADDRESS SPACE LAYOUT RANDOMIZATION): ASLR randomizes the allocation of addresses to objects, in the virtual address space of each process. Because of the randomization it becomes difficult for an attacker to ascertain the position of a particular address. The five types of randomizations are discussed below: (a) Image Randomization: In Windows Vista ASLR is performed, by randomly placing both program executables and DLLs. Also randomization is optional and can be set in the registry key. 2

3 (b) Executable Randomization: In this we add or subtract a random delta value to the image base mentioned in the PE header. (c) DLL Randomization: DLL Randomization is different from Executable randomization. Since windows relies on relocations instead of position independent code, a DLL must be loaded at the same address in each process that uses it to allow the physical memory used by the DLL to be shared. (d) Heap Randomization: In this the starting position of the heap is randomized by calling RtlHeapCreate function. RtlHeapCreate function multiplies a 6-bit random value with 64K. This value is then used as an offset to the base address returned by the NtAllocateVirtualMemory. The memory region which is before this offset is freed. (e) Stack Randomization: Stack randomization in Windows Vista is done in 2 steps: i. First the stack base is randomly chosen by looking for consecutive regions in memory that are not mapped. Based on the 5-bit value X obtained from the timestamp counter, the Xth hole is searched for in memory, this procedure brings about the desired randomness, in generating the stack s base address. ii. Then an offset into this stack is chosen randomly SECTION 2: BYPASSING MEMORY PROTECTIONS In this section the loopholes in the above mentioned memory protection mechanisms are being discussed: 1. GS: In order to understand loopholes in GS protection, consider the following example (Reference: Bypassing Browser Protection by Alexander Sotirov and Mark Dowd): void gs1(char *src, int len) { struct { int a; int b; } buf; memcpy( & buf, src, len); } In this an unspecified number of bytes, which are stored in src are copied into buf structure. Since buf is not GS protected, this code is highly vulnerable. Such fixed size objects are highly vulnerable, as they are not protected by GS. There is also a possibility that stack data is overwritten before cookie verification. Stack data may be of 4 types: (a) string buffers. (b) exception handlers (c) function arguments (d) data of other functions 2. SafeSEH: (a) SafeSEH exception handlers can be put on the heap, this can be done when DEP is disabled. Now the attacker can exploit this by prutting his shellcode on the heap and by using an overwritten exception handler to point to this shellcode. (b) Heap protection can be bypassed by the following means: 3

4 i. One of the reason for the security holes in heaps is because of the lookaside lists. Lookaside list is a linked list of free blocks on the heap. In the case of heap allocation, one block is removed from lookaside list, and this blocks flink pointer is written to the header of the lookaside list. This can be exploited by overwriting the header or the flink pointer of the link list, and then the attacker may write at the memory location of this forward pointer. ii. The attacker may exploit the inconsistent state of the heap, which occurs after the safe unlinking check fails. As this inconsistent state of the heap gives the attacker the ability to write his shellcode in the heap. iii. The attacker may take advantage of heap overflows by overwriting the application data. And in case the overwritten part consists of overwritten pointers, the attacker may thus successfully execute his shellcode. 3. Data Execution Prevention: (a) Contemporary applications such as Internet Explorer 7 do not have DEP protection as they are not linked with /NXcompat (b) DEP is effective if we can prohibit the attacker from writing data to executable memory locations. But in certain cases e.g., in JVM s allocation of objects, these objects are mapped into memory locations marked as readable, writable and executable. Thus such objects can be effectively used by the attacker in heap spraying attacks. (c) Another attack that is possible on DEP is the attacker using the system s APIs to mark the non-executable pages as executable. 4. ASLR (Address Space Layout Randomization) (a) There are well-known softwares available whose binaries have not been built with Visual Studio 2005 SP1 and don t have their /DynamicBase option passed to the linker. Thus their IMAGE DLL CHARACTERISTICS DYNAMIC BASE flag is not set, this rules out randomization. The above technique takes the attacker aware of the location of such executables and DLLs, thus making the memory vulnerable to such attacks. (b) The attacker may use heap spraying technique, in this technique the attacker fills the entire heap area by consecutively writing the NOP slide and his own shellcode. (c) Partial overloading involves modifying only the least significant bytes. Performing such overwrites may be helpful to the attacker, as the attacker just needs to set the pointer to his code to a relocatable memory address. SECTION 3: EXPLOITING THE BROWSER The below mentioned techniques may be employed to circumvent the browser protection: 1. Heap Spraying: The attacker may use heap spraying to fill the heap of the browser by consecutively repeating NOP slide and shellcode instructions. Since the virtual memory is limited, hence the attacker successfully guess the location of his data. 2. SEH overwrite with Flash Code reuse: If we wish to use the previous exploitation technique with GS protection, then we need to take an intersection of previous solution with overwriting an exception handler. This exception handler, now in turn points to the shell code in a vulnerable DLL. Now the above constraints can be easily fulfilled with Flash9f.ocx module, as this module does not apply ASLR protection technique by loading at a fixed address. Also this module doesn t have SafeSEH protection. Now since the jump from current stack pointer to the overwritten stack pointer is relative, hence the attacker adds the two to obtain the shellcode. 3. Exploiting Java s vulnerabilities: While Java Runtime Environment ensures the execution of Java applets, JVM ensures that these applets are sandboxed. Since JVM uses VirtualAlloc to allocate 4

5 memory and also for granting read, write and executable privileges to the memory block. Now due to this very vulnerability the attacker may use heap spraying to place his shellcode and in turn execute it. In order for the attack to be effective, the attacker needs to know the possible base addresses of heap. This can be easily determined, when we consider the fact that internal representations of most frequently used classes is kept in the disk cache called shared archive. The shared archive and the heap is allocated memory, after allocating memory to code cache and to the variables which are created before JVM is loaded. Thus the expected values of base addresses as mentioned in the paper is between 0x x And when the shared archives are not loaded, then the expected value of base address is around 0x Hence the attacker has a high probability of succeeding when he takes the base addresses around this value. 4. Exploiting.NET vulnerabilities:.net User interface controls used by Internet Explorer version 6 and above are claimed to be secure just like their Java counterparts, they are sandboxed inside the Internet Explorer program and are verified to be valid..net binaries are just like PE files, hence they are treated as images..net binaries set the page permissions according to the value in the PE header. This lets the attacker place their code inside the binary and acquire executable rights. Just like heap spraying, the.net binaries can also finish off the virtual memory locations. This technique is called Address space spraying. This is a more powerful attack than heap spraying as it successfully avoids ASLR and DEP protection. Also the attacker is able to guess where to locate the vulnerable binary by employing the following 2 steps: (a) By providing a binary which is sufficiently large so that it can be accommodated between 0x x (b) By providing a binary which does not fit between 0x x One major drawback of the above mentioned approaches is, since we want large binaries than downloading it will consume a large portion of the system bandwidth and of course, it will be time consuming. The following ways are used to deal with the above mentioned difficulty: (a) To put zeros at a large virtual memory area and then to put the data. (b) To compress the data which largely consists of NOP instructions, by employing gzip encoding. As it is mentioned in the paper that DLLs are 64K- consecutively aligned. Hence an attacker can design an attack such that he can send several 8k or smaller binaries. Also every binary will contain some malicious code, which the attacker wishes to execute. Hence with the added advantage of applying the page protection which the attacker wishes, address spraying attack is more powerful than heap spraying attacks. Disable Address Space Layout Randomization: ASLR does not take place if all of the following three conditions are met: 1. The binary is not participating in ASLR. 2. The binary is not IL-Only. 3. The MmMoveImages global variable is not set to -1 For the attack to take place, the following modifications to a standard.net control need to be carried out: 1. Set the ImageBase value in the PE Optional Header to the desired address. 2. Remove the DLL IMAGE CHARACTERISTICS DYNAMIC BASE flag from the DllCharacteristics value in the PE file header. 3. Change the version of COR header to make it below 2.5. Setting it to 2.4 is sufficient to break ASLR without impacting the.net control. (Reference: Bypassing Browser Memory Protections by Alexander Sotirov and Mark Dowd) 5. Java and.net stack spraying: Stack sizes are characterized into 2 types, namely: 5

6 (a) Reserve size, is the largest size up to which the stack will grow to.this size is allocate from the virtual address space. (b) Commit size, represents the amount of physical memory that has been allocated. The size of the committed memory will be less than or equal to the size of the reserve memory. In both Java and.net have thread constructors, which can construct the stack of an arbitrary size. The attacker can take advantage of this feature by allocating a large stack size. He can also control the stack by controlling the type of data elements passed to the stack. (a) We create a function which doesn t contain arguments, nor does the function have any local variables. When we keep calling this function a substantially large number of times, an area in memory which contains a series of return addresses is created. Any of these addresses may be overwritten by the attacker to transfer the control flow to the attackers shellcode. This mechanism has been described in the paper as stack spraying with return addresses. (b) We can use the stack as pointers to the shellcode of the attacker. This is called stack spraying with pointers. 4 Methodology used to investigate the paper In order to explore the memory protection mechanism in Windows, the author first explains the available protection mechanisms. Then he describes the loopholes in these mechanisms. At last he describes, how these loopholes can be exploited by attackers, giving particular emphasis on browser security. 5 Weaknesses of the paper This paper talks only about Windows, it doesn t pay much attention to the loopholes in operating systems such as Solaris, Unix, etc. Particularly the stress is only on Windows Vista. 6 Results In spite of the memory protection techniques defined by microsoft, memory leaks still exist. 6

Is Exploitation Over? Bypassing Memory Protections in Windows 7

Is Exploitation Over? Bypassing Memory Protections in Windows 7 Is Exploitation Over? Bypassing Memory Protections in Windows 7 Alexander Sotirov alex@sotirov.net About me Exploit development since 1999 Published research into reliable exploitation techniques: Heap

More information

How to Impress Girls with Browser Memory Protection Bypasses

How to Impress Girls with Browser Memory Protection Bypasses How to Impress Girls with Browser Memory Protection Bypasses Mark Dowd & Alexander Sotirov markdowd@au1.ibm.com alex@sotirov.net Setting back browser security by 10 years Part I: Introduction Introduction

More information

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

CNIT 127: Exploit Development. Ch 14: Protection Mechanisms. Updated CNIT 127: Exploit Development Ch 14: Protection Mechanisms Updated 3-25-17 Topics Non-Executable Stack W^X (Either Writable or Executable Memory) Stack Data Protection Canaries Ideal Stack Layout AAAS:

More information

Runtime Defenses against Memory Corruption

Runtime Defenses against Memory Corruption CS 380S Runtime Defenses against Memory Corruption Vitaly Shmatikov slide 1 Reading Assignment Cowan et al. Buffer overflows: Attacks and defenses for the vulnerability of the decade (DISCEX 2000). Avijit,

More information

CS 161 Computer Security

CS 161 Computer Security Paxson Spring 2017 CS 161 Computer Security Discussion 2 Question 1 Software Vulnerabilities (15 min) For the following code, assume an attacker can control the value of basket passed into eval basket.

More information

SEH overwrite and its exploitability. Shuichiro Suzuki Fourteenforty Research Institute Inc. Research Engineer

SEH overwrite and its exploitability. Shuichiro Suzuki Fourteenforty Research Institute Inc. Research Engineer SEH overwrite and its exploitability Shuichiro Suzuki Fourteenforty Research Institute Inc. Research Engineer Agenda Theme and Goal Review of SEH overwrites Protection mechanisms for SEH overwrites Bypassing

More information

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

Beyond Stack Smashing: Recent Advances in Exploiting. Jonathan Pincus(MSR) and Brandon Baker (MS) Beyond Stack Smashing: Recent Advances in Exploiting Buffer Overruns Jonathan Pincus(MSR) and Brandon Baker (MS) Buffer Overflows and How they Occur Buffer is a contiguous segment of memory of a fixed

More information

Buffer Overflows: Attacks and Defenses for the Vulnerability of the Decade Review

Buffer Overflows: Attacks and Defenses for the Vulnerability of the Decade Review Buffer Overflows: Attacks and Defenses for the Vulnerability of the Decade Review Network Security Instructor:Dr. Shishir Nagaraja Submitted By: Jyoti Leeka September 24, 2011. 1 Introduction to the topic

More information

Memory corruption vulnerability exposure can be mitigated through memory hardening practices

Memory corruption vulnerability exposure can be mitigated through memory hardening practices Memory corruption vulnerability exposure can be mitigated through memory hardening practices OS vendors have a unique opportunity to fight memory corruption vulnerabilities through hardening the memory

More information

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

Department of Electrical Engineering and Computer Science MASSACHUSETTS INSTITUTE OF TECHNOLOGY Fall Quiz I Solutions Department of Electrical Engineering and Computer Science MASSACHUSETTS INSTITUTE OF TECHNOLOGY 6.893 Fall 2009 Quiz I Solutions All problems are open-ended questions. In order to receive credit you must

More information

CS 161 Computer Security

CS 161 Computer Security Paxson Spring 2011 CS 161 Computer Security Discussion 1 January 26, 2011 Question 1 Buffer Overflow Mitigations Buffer overflow mitigations generally fall into two categories: (i) eliminating the cause

More information

Lecture 4 September Required reading materials for this class

Lecture 4 September Required reading materials for this class EECS 261: Computer Security Fall 2007 Lecture 4 September 6 Lecturer: David Wagner Scribe: DK Moon 4.1 Required reading materials for this class Beyond Stack Smashing: Recent Advances in Exploiting Buffer

More information

Software Security II: Memory Errors - Attacks & Defenses

Software Security II: Memory Errors - Attacks & Defenses 1 Software Security II: Memory Errors - Attacks & Defenses Chengyu Song Slides modified from Dawn Song 2 Administrivia Lab1 Writeup 3 Buffer overflow Out-of-bound memory writes (mostly sequential) Allow

More information

Bypassing SEHOP. Stéfan Le Berre Damien Cauquil

Bypassing SEHOP. Stéfan Le Berre Damien Cauquil Bypassing SEHOP Stéfan Le Berre s.leberre@sysdream.com Damien Cauquil d.cauquil@sysdream.com Table of contents 0. Introduction...3 1. SEHOP specifications (short version)...3 2. Dealing with SEHOP when

More information

Digital Forensics Lecture 02 PDF Structure

Digital Forensics Lecture 02 PDF Structure Digital Forensics Lecture 02 PDF Structure PDF Files Structure Akbar S. Namin Texas Tech University Spring 2017 PDF Format and Structure Tools used Text editor (e.g., vi) ClamAV antivirus (http://www.clamav.net/lang/en/download/

More information

Software Security: Buffer Overflow Attacks

Software Security: Buffer Overflow Attacks CSE 484 / CSE M 584: Computer Security and Privacy Software Security: Buffer Overflow Attacks (continued) Autumn 2018 Tadayoshi (Yoshi) Kohno yoshi@cs.washington.edu Thanks to Dan Boneh, Dieter Gollmann,

More information

Smashing the Buffer. Miroslav Štampar

Smashing the Buffer. Miroslav Štampar Smashing the Buffer Miroslav Štampar (mstampar@zsis.hr) Summary BSidesVienna 2014, Vienna (Austria) November 22nd, 2014 2 Buffer overflow (a.k.a.) Buffer overrun An anomaly where a program, while writing

More information

CSE 509: Computer Security

CSE 509: Computer Security CSE 509: Computer Security Date: 2.16.2009 BUFFER OVERFLOWS: input data Server running a daemon Attacker Code The attacker sends data to the daemon process running at the server side and could thus trigger

More information

CSE 127 Computer Security

CSE 127 Computer Security CSE 127 Computer Security Stefan Savage, Fall 2018, Lecture 4 Low Level Software Security II: Format Strings, Shellcode, & Stack Protection Review Function arguments and local variables are stored on the

More information

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

Department of Electrical Engineering and Computer Science MASSACHUSETTS INSTITUTE OF TECHNOLOGY Fall Quiz I Department of Electrical Engineering and Computer Science MASSACHUSETTS INSTITUTE OF TECHNOLOGY 6.893 Fall 2009 Quiz I All problems are open-ended questions. In order to receive credit you must answer

More information

CSE 127 Computer Security

CSE 127 Computer Security CSE 127 Computer Security Stefan Savage, Spring 2018, Lecture 4 Low Level Software Security II: Format Strings, Shellcode, & Stack Protection Review Function arguments and local variables are stored on

More information

Software Vulnerabilities August 31, 2011 / CS261 Computer Security

Software Vulnerabilities August 31, 2011 / CS261 Computer Security Software Vulnerabilities August 31, 2011 / CS261 Computer Security Software Vulnerabilities...1 Review paper discussion...2 Trampolining...2 Heap smashing...2 malloc/free...2 Double freeing...4 Defenses...5

More information

Countermeasures in Modern Operating Systems. Yves Younan, Vulnerability Research Team (VRT)

Countermeasures in Modern Operating Systems. Yves Younan, Vulnerability Research Team (VRT) Countermeasures in Modern Operating Systems Yves Younan, Vulnerability Research Team (VRT) Introduction Programs in C/C++: memory error vulnerabilities Countermeasures (mitigations): make exploitation

More information

I run a Linux server, so we re secure

I run a Linux server, so we re secure Silent Signal vsza@silentsignal.hu 18 September 2010 Linux from a security viewpoint we re talking about the kernel, not GNU/Linux distributions Linux from a security viewpoint we re talking about the

More information

Software Security: Buffer Overflow Defenses

Software Security: Buffer Overflow Defenses CSE 484 / CSE M 584: Computer Security and Privacy Software Security: Buffer Overflow Defenses Fall 2017 Franziska (Franzi) Roesner franzi@cs.washington.edu Thanks to Dan Boneh, Dieter Gollmann, Dan Halperin,

More information

Software Security: Buffer Overflow Attacks (continued)

Software Security: Buffer Overflow Attacks (continued) CSE 484 / CSE M 584: Computer Security and Privacy Software Security: Buffer Overflow Attacks (continued) Spring 2015 Franziska (Franzi) Roesner franzi@cs.washington.edu Thanks to Dan Boneh, Dieter Gollmann,

More information

Bypassing Windows heap protections

Bypassing Windows heap protections Bypassing Windows heap protections Nicolas Falliere nicolas.falliere@gmail.com History Windows heap-based buffer overflows can be summarized in two categories. The first one covers overflows for Windows

More information

Identity-based Access Control

Identity-based Access Control Identity-based Access Control The kind of access control familiar from operating systems like Unix or Windows based on user identities This model originated in closed organisations ( enterprises ) like

More information

Robust Shell Code Return Oriented Programming and HeapSpray. Zhiqiang Lin

Robust Shell Code Return Oriented Programming and HeapSpray. Zhiqiang Lin CS 6V81-05: System Security and Malicious Code Analysis Robust Shell Code Return Oriented Programming and HeapSpray Zhiqiang Lin Department of Computer Science University of Texas at Dallas April 16 th,

More information

Buffer overflow prevention, and other attacks

Buffer overflow prevention, and other attacks Buffer prevention, and other attacks Comp Sci 3600 Security Outline 1 2 Two approaches to buffer defense Aim to harden programs to resist attacks in new programs Run time Aim to detect and abort attacks

More information

ENEE 457: Computer Systems Security. Lecture 16 Buffer Overflow Attacks

ENEE 457: Computer Systems Security. Lecture 16 Buffer Overflow Attacks ENEE 457: Computer Systems Security Lecture 16 Buffer Overflow Attacks Charalampos (Babis) Papamanthou Department of Electrical and Computer Engineering University of Maryland, College Park Buffer overflow

More information

Outline. Memory Exploit

Outline. Memory Exploit Outline CS 6V81-05: System Security and Malicious Code Analysis Robust Shell Code Return Oriented Programming and HeapSpray Zhiqiang Lin Department of Computer Science University of Texas at Dallas April

More information

CSE 565 Computer Security Fall 2018

CSE 565 Computer Security Fall 2018 CSE 565 Computer Security Fall 2018 Lecture 14: Software Security Department of Computer Science and Engineering University at Buffalo 1 Software Security Exploiting software vulnerabilities is paramount

More information

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

Department of Electrical Engineering and Computer Science MASSACHUSETTS INSTITUTE OF TECHNOLOGY Fall Quiz I Department of Electrical Engineering and Computer Science MASSACHUSETTS INSTITUTE OF TECHNOLOGY 6.858 Fall 2010 Quiz I All problems are open-ended questions. In order to receive credit you must answer

More information

Security and Exploit Mitigation. CMSC Spring 2016 Lawrence Sebald

Security and Exploit Mitigation. CMSC Spring 2016 Lawrence Sebald Security and Exploit Mitigation CMSC 421 - Spring 2016 Lawrence Sebald Security is of Supreme Importance in Systems As we have seen in the past two classes, even with sophisticated security systems, small

More information

Lecture 08 Control-flow Hijacking Defenses

Lecture 08 Control-flow Hijacking Defenses Lecture 08 Control-flow Hijacking Defenses Stephen Checkoway University of Illinois at Chicago CS 487 Fall 2017 Slides adapted from Miller, Bailey, and Brumley Control Flow Hijack: Always control + computation

More information

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

Sandboxing Untrusted Code: Software-Based Fault Isolation (SFI) Sandboxing Untrusted Code: Software-Based Fault Isolation (SFI) Brad Karp UCL Computer Science CS GZ03 / M030 9 th December 2011 Motivation: Vulnerabilities in C Seen dangers of vulnerabilities: injection

More information

20: Exploits and Containment

20: Exploits and Containment 20: Exploits and Containment Mark Handley Andrea Bittau What is an exploit? Programs contain bugs. These bugs could have security implications (vulnerabilities) An exploit is a tool which exploits a vulnerability

More information

Patching Exploits with Duct Tape: Bypassing Mitigations and Backward Steps

Patching Exploits with Duct Tape: Bypassing Mitigations and Backward Steps SESSION ID: EXP-R01 Patching Exploits with Duct Tape: Bypassing Mitigations and Backward Steps James Lyne Global Head of Security Research Sophos / SANS Institute @jameslyne Stephen Sims Security Researcher

More information

Outline. Format string attack layout. Null pointer dereference

Outline. Format string attack layout. Null pointer dereference CSci 5271 Introduction to Computer Security Day 5: Low-level defenses and counterattacks Stephen McCamant University of Minnesota, Computer Science & Engineering Null pointer dereference Format string

More information

Secure Software Development: Theory and Practice

Secure Software Development: Theory and Practice Secure Software Development: Theory and Practice Suman Jana MW 2:40-3:55pm 415 Schapiro [SCEP] *Some slides are borrowed from Dan Boneh and John Mitchell Software Security is a major problem! Why writing

More information

Play with FILE Structure Yet Another Binary Exploitation Technique. Abstract

Play with FILE Structure Yet Another Binary Exploitation Technique. Abstract Play with FILE Structure Yet Another Binary Exploitation Technique An-Jie Yang (Angelboy) angelboy@chroot.org Abstract To fight against prevalent cyber threat, more mechanisms to protect operating systems

More information

Betriebssysteme und Sicherheit Sicherheit. Buffer Overflows

Betriebssysteme und Sicherheit Sicherheit. Buffer Overflows Betriebssysteme und Sicherheit Sicherheit Buffer Overflows Software Vulnerabilities Implementation error Input validation Attacker-supplied input can lead to Corruption Code execution... Even remote exploitation

More information

Lecture 1: Buffer Overflows

Lecture 1: Buffer Overflows CS5431 Computer Security Practicum Spring 2017 January 27, 2017 1 Conficker Lecture 1: Buffer Overflows Instructor: Eleanor Birrell In November 2008, a new piece of malware was observed in the wild. This

More information

Writing Exploits. Nethemba s.r.o.

Writing Exploits. Nethemba s.r.o. Writing Exploits Nethemba s.r.o. norbert.szetei@nethemba.com Motivation Basic code injection W^X (DEP), ASLR, Canary (Armoring) Return Oriented Programming (ROP) Tools of the Trade Metasploit A Brief History

More information

Memory Safety (cont d) Software Security

Memory Safety (cont d) Software Security Memory Safety (cont d) Software Security CS 161: Computer Security Prof. Raluca Ada Popa January 17, 2016 Some slides credit to David Wagner and Nick Weaver Announcements Discussion sections and office

More information

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

Module: Program Vulnerabilities. Professor Trent Jaeger. CSE543 - Introduction to Computer and Network Security CSE543 - Introduction to Computer and Network Security Module: Program Vulnerabilities Professor Trent Jaeger 1 1 Programming Why do we write programs? Function What functions do we enable via our programs?

More information

CS399 New Beginnings. Jonathan Walpole

CS399 New Beginnings. Jonathan Walpole CS399 New Beginnings Jonathan Walpole Memory Management Memory Management Memory a linear array of bytes - Holds O.S. and programs (processes) - Each cell (byte) is named by a unique memory address Recall,

More information

Modern Buffer Overflow Prevention Techniques: How they work and why they don t

Modern Buffer Overflow Prevention Techniques: How they work and why they don t Modern Buffer Overflow Prevention Techniques: How they work and why they don t Russ Osborn CS182 JT 4/13/2006 1 In the past 10 years, computer viruses have been a growing problem. In 1995, there were approximately

More information

Inline Reference Monitoring Techniques

Inline Reference Monitoring Techniques Inline Reference Monitoring Techniques In the last lecture, we started talking about Inline Reference Monitors. The idea is that the policy enforcement code runs with the same address space as the code

More information

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

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 1 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 IsPasswordOK(), and compares it with the correct password.

More information

CSE 127 Computer Security

CSE 127 Computer Security CSE 127 Computer Security Alex Gantman, Spring 2018, Lecture 4 Low Level Software Security II: Format Strings, Shellcode, & Stack Protection Review Function arguments and local variables are stored on

More information

Intrusion Detection and Malware Analysis

Intrusion Detection and Malware Analysis Intrusion Detection and Malware Analysis Host Based Attacks Pavel Laskov Wilhelm Schickard Institute for Computer Science Software security threats Modification of program code viruses and self-replicating

More information

Memory: Overview. CS439: Principles of Computer Systems February 26, 2018

Memory: Overview. CS439: Principles of Computer Systems February 26, 2018 Memory: Overview CS439: Principles of Computer Systems February 26, 2018 Where We Are In the Course Just finished: Processes & Threads CPU Scheduling Synchronization Next: Memory Management Virtual Memory

More information

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

2 Sadeghi, Davi TU Darmstadt 2012 Secure, Trusted, and Trustworthy Computing Chapter 6: Runtime Attacks Runtime attacks are major threats to today's applications Control-flow of an application is compromised at runtime Typically, runtime attacks include injection of malicious code Reasons for runtime attacks

More information

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

Module: Return-oriented Programming. Professor Trent Jaeger. CSE543 - Introduction to Computer and Network Security CSE543 - Introduction to Computer and Network Security Module: Return-oriented Programming Professor Trent Jaeger 1 Anatomy of Control-Flow Exploits 2 Anatomy of Control-Flow Exploits Two steps in control-flow

More information

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

Stack Vulnerabilities. CS4379/5375 System Security Assurance Dr. Jaime C. Acosta 1 Stack Vulnerabilities CS4379/5375 System Security Assurance Dr. Jaime C. Acosta Part 1 2 3 An Old, yet Still Valid Vulnerability Buffer/Stack Overflow ESP Unknown Data (unused) Unknown Data (unused)

More information

Apology of 0days. Nicolás Waisman

Apology of 0days. Nicolás Waisman Apology of 0days Nicolás Waisman Who Am I? Senior Security Researcher and Regional Manager at Immunity, Inc. Research and Development of reliable Heap Overflow exploitation for CANVAS attack framework

More information

Advanced Systems Security: Program Diversity

Advanced Systems Security: Program Diversity Systems and Internet Infrastructure Security Network and Security Research Center Department of Computer Science and Engineering Pennsylvania State University, University Park PA Advanced Systems Security:

More information

Identifying and Analyzing Pointer Misuses for Sophisticated Memory-corruption Exploit Diagnosis

Identifying and Analyzing Pointer Misuses for Sophisticated Memory-corruption Exploit Diagnosis Identifying and Analyzing Pointer Misuses for Sophisticated Memory-corruption Exploit Diagnosis Mingwei Zhang ( ) Aravind Prakash ( ) Xiaolei Li ( ) Zhenkai Liang ( ) Heng Yin ( ) ( ) School of Computing,

More information

Buffer overflow background

Buffer overflow background and heap buffer background Comp Sci 3600 Security Heap Outline and heap buffer Heap 1 and heap 2 3 buffer 4 5 Heap Outline and heap buffer Heap 1 and heap 2 3 buffer 4 5 Heap Address Space and heap buffer

More information

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

Outline. Heap meta-data. Non-control data overwrite Outline CSci 5271 Introduction to Computer Security Day 5: Low-level defenses and counterattacks Stephen McCamant University of Minnesota, Computer Science & Engineering Non-control data overwrite Heap

More information

Secure Coding in C and C++

Secure Coding in C and C++ Secure Coding in C and C++ Dynamic Memory Management Lecture 5 Sept 21, 2017 Acknowledgement: These slides are based on author Seacord s original presentation Issues Dynamic Memory Management Common Dynamic

More information

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

Module: Program Vulnerabilities. Professor Trent Jaeger. CSE543 - Introduction to Computer and Network Security CSE543 - Introduction to Computer and Network Security Module: Program Vulnerabilities Professor Trent Jaeger 1 Programming Why do we write programs? Function What functions do we enable via our programs?

More information

CSC 591 Systems Attacks and Defenses Stack Canaries & ASLR

CSC 591 Systems Attacks and Defenses Stack Canaries & ASLR CSC 591 Systems Attacks and Defenses Stack Canaries & ASLR Alexandros Kapravelos akaprav@ncsu.edu How can we prevent a buffer overflow? Check bounds Programmer Language Stack canaries [...more ] Buffer

More information

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

Module: Program Vulnerabilities. Professor Trent Jaeger. CSE543 - Introduction to Computer and Network Security CSE543 - Introduction to Computer and Network Security Module: Program Vulnerabilities Professor Trent Jaeger 1 Programming Why do we write programs? Function What functions do we enable via our programs?

More information

ht IE exploit analysis

ht IE exploit analysis ht 2013 004 IE exploit analysis Martin Pozdena Zhongying Qiao Introduction Hacking Team leak from June 2015 revealed some 400 GB of company s internal data including their git repositories. This allowed

More information

0x1A Great Papers in Computer Security

0x1A Great Papers in Computer Security CS 380S 0x1A Great Papers in Computer Security Vitaly Shmatikov http://www.cs.utexas.edu/~shmat/courses/cs380s/ slide 1 Reference Monitor Observes execution of the program/process At what level? Possibilities:

More information

About unchecked management SMM & UEFI. Vulnerability. Patch. Conclusion. Bruno Pujos. July 16, Bruno Pujos

About unchecked management SMM & UEFI. Vulnerability. Patch. Conclusion. Bruno Pujos. July 16, Bruno Pujos July 16, 2016 1/45 Whoami RE, vulnerability research LSE 2015 Sogeti since 2/45 1 2 Reverse Exploitation 3 4 3/45 Agenda 1 4/45 Agenda 1 5/45 Unified Extended FIrmware is based on EFI Specification for

More information

Other array problems. Integer overflow. Outline. Integer overflow example. Signed and unsigned

Other array problems. Integer overflow. Outline. Integer overflow example. Signed and unsigned Other array problems CSci 5271 Introduction to Computer Security Day 4: Low-level attacks Stephen McCamant University of Minnesota, Computer Science & Engineering Missing/wrong bounds check One unsigned

More information

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

Buffer overflow is still one of the most common vulnerabilities being discovered and exploited in commodity software. Outline Morris Worm (1998) Infamous attacks Secure Programming Lecture 4: Memory Corruption II (Stack Overflows) David Aspinall, Informatics @ Edinburgh 23rd January 2014 Recap Simple overflow exploit

More information

CMPSC 497 Buffer Overflow Vulnerabilities

CMPSC 497 Buffer Overflow Vulnerabilities Systems and Internet Infrastructure Security Network and Security Research Center Department of Computer Science and Engineering Pennsylvania State University, University Park PA CMPSC 497 Buffer Overflow

More information

Kernel Self Protection

Kernel Self Protection Kernel Self Protection Kernel Summit 2016, Santa Fe Kees ( Case ) Cook keescook@chromium.org @kees_cook http://kernsec.org/wiki/index.php/kernel_self_protection_project http://www.openwall.com/lists/kernel-hardening/

More information

Homework 3 CS161 Computer Security, Fall 2008 Assigned 10/07/08 Due 10/13/08

Homework 3 CS161 Computer Security, Fall 2008 Assigned 10/07/08 Due 10/13/08 Homework 3 CS161 Computer Security, Fall 2008 Assigned 10/07/08 Due 10/13/08 For your solutions you should submit a hard copy; either hand written pages stapled together or a print out of a typeset document

More information

CSCD 303 Fall Lecture 15 Buffer Overflows

CSCD 303 Fall Lecture 15 Buffer Overflows CSCD 303 Fall 2017 Lecture 15 Buffer Overflows 1 Introduction Buffer overflow What s a buffer overflow? How do attackers exploit buffer overflows? Potential solutions 2 Vulnerabilities are Everywhere Some

More information

ECS 153 Discussion Section. April 6, 2015

ECS 153 Discussion Section. April 6, 2015 ECS 153 Discussion Section April 6, 2015 1 What We ll Cover Goal: To discuss buffer overflows in detail Stack- based buffer overflows Smashing the stack : execution from the stack ARC (or return- to- libc)

More information

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

CSCE 548 Building Secure Software Buffer Overflow. Professor Lisa Luo Spring 2018 CSCE 548 Building Secure Software Buffer Overflow Professor Lisa Luo Spring 2018 Previous Class Virus vs. Worm vs. Trojan & Drive-by download Botnet & Rootkit Malware detection Scanner Polymorphic malware

More information

Shellcode Analysis. Chapter 19

Shellcode Analysis. Chapter 19 Shellcode Analysis Chapter 19 What is Shellcode Shellcode a payload of raw executable code, attackers use this code to obtain interactive shell access. A binary chunk of data Can be generally referred

More information

Software Security: Buffer Overflow Defenses and Miscellaneous

Software Security: Buffer Overflow Defenses and Miscellaneous CSE 484 / CSE M 584: Computer Security and Privacy Software Security: Buffer Overflow Defenses and Miscellaneous Spring 2017 Franziska (Franzi) Roesner franzi@cs.washington.edu Thanks to Dan Boneh, Dieter

More information

Practical Techniques for Regeneration and Immunization of COTS Applications

Practical Techniques for Regeneration and Immunization of COTS Applications Practical Techniques for Regeneration and Immunization of COTS Applications Lixin Li Mark R.Cornwell E.Hultman James E. Just R. Sekar Stony Brook University Global InfoTek, Inc (Research supported by DARPA,

More information

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

Security and Privacy in Computer Systems. Lecture 5: Application Program Security CS 645 Security and Privacy in Computer Systems Lecture 5: Application Program Security Buffer overflow exploits More effective buffer overflow attacks Preventing buffer overflow attacks Announcement Project

More information

On Compilers, Memory Errors and Control-Flow Integrity

On Compilers, Memory Errors and Control-Flow Integrity On Compilers, Memory Errors and Control-Flow Integrity Advanced Compiler Design SS 2015 Antonio Hüseyin Barresi Zürich, 27.5.2015 CVE-2012-0158 is a buffer overflow Vulnerability in the ListView / TreeView

More information

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

Applications. Cloud. See voting example (DC Internet voting pilot) Select * from userinfo WHERE id = %%% (variable) Software Security Requirements General Methodologies Hardware Firmware Software Protocols Procedure s Applications OS Cloud Attack Trees is one of the inside requirement 1. Attacks 2. Evaluation 3. Mitigation

More information

String Oriented Programming Exploring Format String Attacks. Mathias Payer

String Oriented Programming Exploring Format String Attacks. Mathias Payer String Oriented Programming Exploring Format String Attacks Mathias Payer Motivation Additional protection mechanisms prevent many existing attack vectors Format string exploits are often overlooked Drawback:

More information

Is stack overflow still a problem?

Is stack overflow still a problem? Morris Worm (1998) Code Red (2001) Secure Programming Lecture 4: Memory Corruption II (Stack Overflows) David Aspinall, Informatics @ Edinburgh 31st January 2017 Memory corruption Buffer overflow remains

More information

Advanced Buffer Overflow

Advanced Buffer Overflow Pattern Recognition and Applications Lab Advanced Buffer Overflow Ing. Davide Maiorca, Ph.D. davide.maiorca@diee.unica.it Computer Security A.Y. 2016/2017 Department of Electrical and Electronic Engineering

More information

Secure Coding in C and C++ Dynamic Memory Management Lecture 5 Jan 29, 2013

Secure Coding in C and C++ Dynamic Memory Management Lecture 5 Jan 29, 2013 Secure Coding in C and C++ Dynamic Memory Management Lecture 5 Jan 29, 2013 Acknowledgement: These slides are based on author Seacord s original presentation Issues Dynamic Memory Management Common Dynamic

More information

PROCESS VIRTUAL MEMORY. CS124 Operating Systems Winter , Lecture 18

PROCESS VIRTUAL MEMORY. CS124 Operating Systems Winter , Lecture 18 PROCESS VIRTUAL MEMORY CS124 Operating Systems Winter 2015-2016, Lecture 18 2 Programs and Memory Programs perform many interactions with memory Accessing variables stored at specific memory locations

More information

Heap Off by 1 Overflow Illustrated. Eric Conrad October 2007

Heap Off by 1 Overflow Illustrated. Eric Conrad October 2007 Heap Off by 1 Overflow Illustrated Eric Conrad October 2007 1 The Attack Older CVS versions are vulnerable to an Off by 1 attack, where an attacker may insert one additional character into the heap CVS

More information

Bypassing Mitigations by Attacking JIT Server in Microsoft Edge

Bypassing Mitigations by Attacking JIT Server in Microsoft Edge Bypassing Mitigations by Attacking JIT Server in Microsoft Edge Ivan Fratric Infiltrate 2018 About me Security researcher at Google Project Zero Previously: Google Security Team, Academia (UNIZG) Doing

More information

Basic Buffer Overflows

Basic Buffer Overflows Operating Systems Security Basic Buffer Overflows (Stack Smashing) Computer Security & OS lab. Cho, Seong-je ( 조성제 ) Fall, 2018 sjcho at dankook.ac.kr Chapter 10 Buffer Overflow 2 Contents Virtual Memory

More information

Advanced Systems Security: Ordinary Operating Systems

Advanced Systems Security: Ordinary Operating Systems Systems and Internet Infrastructure Security Network and Security Research Center Department of Computer Science and Engineering Pennsylvania State University, University Park PA Advanced Systems Security:

More information

Run-time Environments

Run-time Environments Run-time Environments Status We have so far covered the front-end phases Lexical analysis Parsing Semantic analysis Next come the back-end phases Code generation Optimization Register allocation Instruction

More information

Run-time Environments

Run-time Environments Run-time Environments Status We have so far covered the front-end phases Lexical analysis Parsing Semantic analysis Next come the back-end phases Code generation Optimization Register allocation Instruction

More information

CS 161 Computer Security

CS 161 Computer Security Paxson Spring 2011 CS 161 Computer Security Homework 1 Due: Wednesday, February 9, at 9:59pm Instructions. Submit your solution by Wednesday, February 9, at 9:59pm, in the drop box labelled CS161 in 283

More information

CS 161 Computer Security

CS 161 Computer Security Paxson Spring 2013 CS 161 Computer Security Discussion 2 January 30, 2013 Question 1 Buffer Overflow Mitigations (10 min) Buffer overflow mitigations generally fall into two categories: (i) eliminating

More information

CSc 466/566. Computer Security. 20 : Operating Systems Application Security

CSc 466/566. Computer Security. 20 : Operating Systems Application Security 1/68 CSc 466/566 Computer Security 20 : Operating Systems Application Security Version: 2014/11/20 13:07:28 Department of Computer Science University of Arizona collberg@gmail.com Copyright c 2014 Christian

More information

Caching and Buffering in HDF5

Caching and Buffering in HDF5 Caching and Buffering in HDF5 September 9, 2008 SPEEDUP Workshop - HDF5 Tutorial 1 Software stack Life cycle: What happens to data when it is transferred from application buffer to HDF5 file and from HDF5

More information

Black Hat Webcast Series. C/C++ AppSec in 2014

Black Hat Webcast Series. C/C++ AppSec in 2014 Black Hat Webcast Series C/C++ AppSec in 2014 Who Am I Chris Rohlf Leaf SR (Security Research) - Founder / Consultant BlackHat Speaker { 2009, 2011, 2012 } BlackHat Review Board Member http://leafsr.com

More information

SoK: Eternal War in Memory

SoK: Eternal War in Memory SoK: Eternal War in Memory László Szekeres, Mathias Payer, Tao Wei, Dawn Song Presenter: Wajih 11/7/2017 Some slides are taken from original S&P presentation 1 What is SoK paper? Systematization of Knowledge

More information