CSE 509: Computer Security

Similar documents
CS 161 Computer Security

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

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

Lecture 07 Heap control data. Stephen Checkoway University of Illinois at Chicago

Lecture 4 September Required reading materials for this class

CMPSC 497 Buffer Overflow Vulnerabilities

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

Introduction to Computer Systems , fall th Lecture, Sep. 28 th

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

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

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

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

Software Security: Buffer Overflow Attacks

Runtime attacks are major threats to today's applications Control-flow of an application is compromised at runtime Typically, runtime attacks include

Dynamic Memory Allocation. Zhaoguo Wang

20: Exploits and Containment

CS 161 Computer Security

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

Program Security and Vulnerabilities Class 2

String Oriented Programming Exploring Format String Attacks. Mathias Payer

ECS 153 Discussion Section. April 6, 2015

Selected background on ARM registers, stack layout, and calling convention

Is stack overflow still a problem?

Software Security: Buffer Overflow Defenses

Software Vulnerabilities August 31, 2011 / CS261 Computer Security

CPSC 213. Introduction to Computer Systems. Procedures and the Stack. Unit 1e

BUFFER OVERFLOW. Jo, Heeseung

Buffer Overflow. Jo, Heeseung

ISA564 SECURITY LAB. Code Injection Attacks

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

This time. Defenses and other memory safety vulnerabilities. Everything you ve always wanted to know about gdb but were too afraid to ask

CSE 127 Computer Security

Return-orientated Programming

BUFFER OVERFLOW DEFENSES & COUNTERMEASURES

CSE / / 60567: Computer Security. Software Security 4

Advanced Buffer Overflow

CSE 127 Computer Security

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

CSE 127 Computer Security

Buffer overflows. Specific topics:

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

SYSTEM CALL IMPLEMENTATION. CS124 Operating Systems Fall , Lecture 14

CSE 127: Computer Security Control Flow Hijacking. Kirill Levchenko

Buffer Overflow. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Intrusion Detection and Malware Analysis

Secure Software Programming and Vulnerability Analysis

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

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

Betriebssysteme und Sicherheit Sicherheit. Buffer Overflows

Lecture 09 Code reuse attacks. Stephen Checkoway University of Illinois at Chicago CS 487 Fall 2017

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

Lecture 08 Control-flow Hijacking Defenses

Fundamentals of Computer Security

Smashing the Buffer. Miroslav Štampar

18-600: Recitation #4 Exploits

Computer Systems Lecture 9

Buffer Overflows Defending against arbitrary code insertion and execution

Heap Off by 1 Overflow Illustrated. Eric Conrad October 2007

Secure Systems Engineering

CPSC 213. Introduction to Computer Systems. Procedures and the Stack. Unit 1e

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

Advanced Buffer Overflow

Basic Buffer Overflows

Secure Programming Lecture 3: Memory Corruption I (Stack Overflows)

Memory Corruption 101 From Primitives to Exploit

putting m bytes into a buffer of size n, for m>n corrupts the surrounding memory check size of data before/when writing

CSC 591 Systems Attacks and Defenses Return-into-libc & ROP

Offensive Security My First Buffer Overflow: Tutorial

Buffer Overflow Attack (AskCypert CLaaS)

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

Roadmap: Security in the software lifecycle. Memory corruption vulnerabilities

Sample slides and handout

Software Security: Buffer Overflow Attacks (continued)

18-600: Recitation #4 Exploits (Attack Lab)

Secure Programming Lecture 4: Memory Corruption II (Stack & Heap Overflows)

Università Ca Foscari Venezia

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

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING

PRESENTED BY: SANTOSH SANGUMANI & SHARAN NARANG

Machine-Level Programming V: Advanced Topics

Advanced Systems Security: Control-Flow Integrity

CPSC 213. Introduction to Computer Systems. Procedures and the Stack. Unit 1e

Vulnerabilities in C/C++ programs Part I

CSE 351 Final Exam - Winter 2017

I Control Your Code Attack Vectors through the Eyes of Software-based Fault Isolation. Mathias Payer

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

CPEG421/621 Tutorial

putting m bytes into a buffer of size n, for m>n corrupts the surrounding memory check size of data before/when writing

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

Architecture-level Security Vulnerabilities

CSE 565 Computer Security Fall 2018

CYSE 411/AIT681 Secure Software Engineering Topic #8. Secure Coding: Pointer Subterfuge

Secure Programming Lecture 4: Memory Corruption II (Stack & Heap Overflows)

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

Security Workshop HTS. LSE Team. February 3rd, 2016 EPITA / 40

Buffer Overflow and Format String Overflow Vulnerabilities

Shellcode Analysis. Chapter 19

Buffer Overflows. CSE 351 Autumn Instructor: Justin Hsia

Lab 2: Buffer Overflows

Buffer Overflow Attacks

Transcription:

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 a buffer overflow which could cause the server to execute malicious code. VIRTUAL MEMORY ORGANIZATION: (Linux, 32 bit ) Kernel Environment Variables Comandline Arguments Runtime stack Libraries Heap Data and BSS Text/Code

Sample Code: void get_user (char buf) { int len; printf ( Username: ); scanf ( %s, buf); } void login (void) { char userame[64]; get_user (username); } Assumption: Attacker knows everything about the server. Stack Layout (Activation Record): Login return Username (64) Buf get_user return len

To attack the system, the attacker will pass: <machine code (64 bytes)> <address of username buf> This will overwrite the login return address with the address of username buffer (which contains the machine code the attacker wants to execute) Address of username buffer (machine code) Machine code passed by attacker Buf get_user return len If the user is uncertain of the address of the username buffer (machine code), he can increase the address to be stored at the return address so that it is in the middle of the buffer. If he is even more uncertain, he can create a launching pad by creating NOP to the start of the buffer. After NOPs, we place our malicious code, then the address of this code. More uncertainty, use brute force.

Trampoline: A clever solution to overcome this uncertainty is the following. When the username buffer is passed as a parameter to get_user(), the address of this buffer is stored in some register. Typically, when a function is to be called, all the registers are pushed on the stack, then the code pointer points the function to be called. Before returning from the function, the function does not clear the registers, instead the caller will pop the registers from the stack and restore the original values. Assume the value of the buffer is stored in some register R0. On return from the get_user() function, the address of the username[] buffer is in register R0. If after the return to login form get_user, there is a call of the form jmp %R0, then the attacker can use this instruction to jump to the attacker provided malicious code in the username buffer. For this, he will have to pass <machine code> <addr of jmp> to get_user() 0x1234 pusha 0x1235 call get_user 0x123B popa 0x2222 jmp %R0 pass <64 byte machine code> <0x2222> to get_user() function. Return to libc attack: inject data configure returns to pre existing code in libc System ( const char cmd): system () executes a shell command specified in command by calling /bin/sh c cmd and returns after cmd is executed. Disassembly of system() would look like: 0xABCD mov %R0,[%sp + 4] int 0x80 So, for system(), the stack looks like argument return %sp

0x1234 Dummy return 0xABCD After return, %sp points here cmd 0x1234 buf So we have to make the stack layout at the call to get_user() look like that for the system () call. So, the attacker stores <cmd> <0xABCD> <dummy return><0x1234> Other Code pointers: function pointers callbacks (local variables) structures V table/ V pointer (C++) function list (atexit) exception handlers combine with return to libc Arbitrary memory Write: void fun () { char buf[64]; int val; int ptr; <BUFFER OVERFLOW OF BUF> ptr = val; } can be user to transfer a lot of data (4 bytes at a time)

Heap Overflow: hdr hdr Data malloced data hdr data The memory blocks allocated via malloc/new contain some metadata along with each memory chunk allocated which contains information like size, flags, etc of the allocated memory. The memory chunks are stored in the form of a linked list, thus typical DS for a memory chunk would look like struct malloc_chunk { struct malloc_chunk next; struct malloc_chunk prev; }; When freeing a chunk of memory, it is removed from the allocated list. The code for the same will look like: hdr >next >prev = hdr >prev; which is (ptr + offset (prev)) = val;