Security Exploiting Overflows. Introduction r See the following link for more info: operating-systems-and-applications-in-

Slides:



Advertisements
Similar presentations
Buffer Overflows Nick Feamster CS 6262 Spring 2009 (credit to Vitaly S. from UT for slides)
Advertisements

Smashing the Stack for Fun and Profit
Exploring Security Vulnerabilities by Exploiting Buffer Overflow using the MIPS ISA Andrew T. Phillips Jack S. E. Tan Department of Computer Science University.
Procedure Calls Prof. Sirer CS 316 Cornell University.
CSc 352 Programming Hygiene Saumya Debray Dept. of Computer Science The University of Arizona, Tucson
Computer Security: Principles and Practice EECS710: Information Security Professor Hossein Saiedian Fall 2014 Chapter 10: Buffer Overflow.
Lecture 16 Buffer Overflow modified from slides of Lawrie Brown.
1 Memory Allocation Professor Jennifer Rexford COS 217.
Breno de MedeirosFlorida State University Fall 2005 Buffer overflow and stack smashing attacks Principles of application software security.
1 CHAPTER 8 BUFFER OVERFLOW. 2 Introduction One of the more advanced attack techniques is the buffer overflow attack Buffer Overflows occurs when software.
SCSC 555 Computer Security Chapter 10 Malicious software Part B.
Stack-Based Buffer Overflows Attacker – Can take over a system remotely across a network. local malicious users – To elevate their privileges and gain.
CMSC 414 Computer and Network Security Lecture 23 Jonathan Katz.
Gabe Kanzelmeyer CS 450 4/14/10.  What is buffer overflow?  How memory is processed and the stack  The threat  Stack overrun attack  Dangers  Prevention.
Teaching Buffer Overflow Ken Williams NC A&T State University.
Beyond Stack Smashing: Recent Advances in Exploiting Buffer Overruns Jonathan Pincus Microsoft Research Brandon Baker Microsoft Carl Hartung CSCI 7143:
Teaching Buffer Overflow Ken Williams NC A&T State University.
C and Data Structures Baojian Hua
Assembly תרגול 8 פונקציות והתקפת buffer.. Procedures (Functions) A procedure call involves passing both data and control from one part of the code to.
Netprog: Buffer Overflow1 Buffer Overflow Exploits Taken shamelessly from: netprog/overflow.ppt.
Andrea Bittau, Adam Belay, Ali Mashtizadeh, David Maziéres, Dan Boneh
Memory Layout C and Data Structures Baojian Hua
Control hijacking attacks Attacker’s goal: – Take over target machine (e.g. web server) Execute arbitrary code on target by hijacking application control.
CMSC 414 Computer and Network Security Lecture 20 Jonathan Katz.
University of Washington CSE 351 : The Hardware/Software Interface Section 5 Structs as parameters, buffer overflows, and lab 3.
Buffer overflows.
Fall 2008CS 334: Computer SecuritySlide #1 Smashing The Stack A detailed look at buffer overflows as described in Smashing the Stack for Fun and Profit.
Lecture 0 Appendix on Implementation Threats Material from Warren Page & Chpt 11, Information Security by Mark Stamp.
Computer Security and Penetration Testing
Introduction: Exploiting Linux. Basic Concepts Vulnerability A flaw in a system that allows an attacker to do something the designer did not intend,
Mitigation of Buffer Overflow Attacks
ITEC 352 Lecture 18 Functions in Assembly. Functions + Assembly Review Questions? Project due on Friday Exam –Average 76 Methods for functions in assembly.
CSCD 303 Essential Computer Security Spring 2013 Lecture 17 Buffer Overflow Attacks.
University of Washington Today Happy Monday! HW2 due, how is Lab 3 going? Today we’ll go over:  Address space layout  Input buffers on the stack  Overflowing.
Buffer Overflow CS461/ECE422 Spring Reading Material Based on Chapter 11 of the text.
Buffer Overflow. Introduction On many C implementations, it is possible to corrupt the execution stack by writing past the end of an array. Known as smash.
Lecture 8: Buffer Overflow CS 436/636/736 Spring 2013 Nitesh Saxena *Adopted from a previous lecture by Aleph One (Smashing the Stack for Fun and Profit)
Buffer Overflow Attack Proofing of Code Binary Gopal Gupta, Parag Doshi, R. Reghuramalingam, Doug Harris The University of Texas at Dallas.
What is exactly Exploit writing?  Writing a piece of code which is capable of exploit the vulnerability in the target software.
A Tool for Pro-active Defense Against the Buffer Overrun Attack D. Bruschi, E. Rosti, R. Banfi Presented By: Warshavsky Alex.
Buffer overflow and stack smashing attacks Principles of application software security.
Reminder Bomb lab is due tomorrow! Attack lab is released tomorrow!!
Web Security Firewalls, Buffer overflows and proxy servers.
Information Security - 2. A Stack Frame. Pushed to stack on function CALL The return address is copied to the CPU Instruction Pointer when the function.
Slides by Kent Seamons and Tim van der Horst Last Updated: Nov 11, 2011.
Announcements Partial Credit Due Date for Assignment 2 now due on Sat, Feb 27 I always seem to be behind and get tons of daily. If you me and.
VM: Chapter 7 Buffer Overflows. csci5233 computer security & integrity (VM: Ch. 7) 2 Outline Impact of buffer overflows What is a buffer overflow? Types.
Beyond Stack Smashing: Recent Advances In Exploiting Buffer Overruns Jonathan Pincus and Brandon Baker Microsoft Researchers IEEE Security and.
Chapter 10 Chapter 10 Implementing Subprograms. Implementing Subprograms  The subprogram call and return operations are together called subprogram linkage.
Software Security. Bugs Most software has bugs Some bugs cause security vulnerabilities Incorrect processing of security related data Incorrect processing.
@Yuan Xue Worm Attack Yuan Xue Fall 2012.
Lec. Waleed Bin Shahid.  You might have noticed a lot of issues related to software implementation.  The ultimate requirement of developer(s) is to.
Refs: rootshell, antionline, your favorite hacker site…
Mitigation against Buffer Overflow Attacks
Buffer Overflow Buffer overflows are possible because C doesn’t check array boundaries Buffer overflows are dangerous because buffers for user input are.
Introduction to Operating Systems
Protecting Memory What is there to protect in memory?
The Hardware/Software Interface CSE351 Winter 2013
Protecting Memory What is there to protect in memory?
Protecting Memory What is there to protect in memory?
ENERGY 211 / CME 211 Lecture 25 November 17, 2008.
CMSC 414 Computer and Network Security Lecture 21
Introduction to Operating Systems
CS 465 Buffer Overflow Slides by Kent Seamons and Tim van der Horst
Memory Allocation CS 217.
Software Security Lesson Introduction
CS703 - Advanced Operating Systems
Procedures and Calling Conventions
Understanding and Preventing Buffer Overflow Attacks in Unix
Return-to-libc Attacks
Presentation transcript:

Security Exploiting Overflows

Introduction r See the following link for more info: operating-systems-and-applications-in- 2014/

Introduction r Buffer overflows are a major vulnerability  When a security alert contains the phrase “The most severe of these vulnerabilities allows a remote attacker to execute arbitrary code.”, the underlying problem is probably a buffer overflow.

The Security Problem  S ecurity must consider external environment of the system, and protect the system resources r Intruders (crackers) attempt to breach security r Threat is potential security violation r Attack is attempt to breach security r Attack can be accidental or malicious r Easier to protect against accidental than malicious misuse

Security Measure Levels r Security must occur at four levels to be effective: m Physical m Human Avoid social engineering, phishing, dumpster diving m Operating System m Network r Security is as weak as the weakest link in the chain

Background r Typical Attack Scenario: m Users enter data into a Web form m Web form is sent to server m Server writes data to buffer, without checking length of input data m Data overflows from buffer m Sometimes, overflow can enable an attack m Web form attack could be carried out by anyone with an Internet connection

Problem void foo(char *str) { char buf[10]; strcpy(buf,str); } … foo(“thisstringistolongforfoo”);

What Happens r This will cause the program to abort r Why? r To understand this you need some understanding of m C functions and the stack m A little knowledge of assembly m How system calls are made

Process Memory Layout r Continuous memory space for all process m Each with its physical space m Pretends you are in the same in virtual space 0xffffffff 0

Process Memory Layout r Program code and constant m binary form m loaded libraries 0xffffffff 0 text

Process Memory Layout r Program code and constant m binary form m loaded libraries m known as “text” segment m space calculated at compile time 0xffffffff 0 text

Process Memory Layout r Data: initialized global data in the program m Example: int size = 100; r BSS: un-initialized global data in the program m Example: int length; 0xffffffff 0 text data bss

Process Memory Layout r Heap: dynamically-allocated spaces m Example: malloc, free m OS knows nothing about it space content m dynamically grows as program runs 0xffffffff 0 text data bss heap

Process Memory Layout r Stack: local variables in functions m support function call/return and recursive functions m grow to low address m Why? Historical 0xffffffff 0 text data bss heap stack

What is a Stack? r A stack is a contiguous block of memory used by functions r A stack pointer points to the top of stack r The stack consists of frames which are pushed when a function is called and popped when a function if finished. r A frame pointer points to the current frame in use

Stack Buffers r Suppose a web server contains the foo function from several slides ago void foo(char *str) { char buf[10]; strcpy(buf,str);} r When this function is invoked, a new frame is pushed onto the stack Top of stack Stack grows this way bufsfp ret addr str Local variables Frame of the calling function Execute code at this address after func() finishes Arguments Pointer to previous frame

Stack Buffer  Memory pointed to by str is copied onto stack void foo(char *str) { char buf[10]; strcpy(buf,str); } r If a string is longer than 10 bytes it is copied into buffer and will overwrite adjacent stack locations strcpy does NOT check whether the string at *str contains fewer than 10 characters buf str This will be interpreted as return address! overflow Top of stack Frame of the calling function

Exploitation r General idea: Provide servers very large strings that will overflow a buffer. r For a server with sloppy code: it’s easy to crash the server by overflowing a buffer.

Problem: No range checking r strcpy does not check input size m strcpy (buf,str) simply copies memory contents into bug starting from *str until “\0” is encountered, m Ignores the size of area allocated to buf r Many C library functions are unsafe m strcpy, strcat,gets,scanf,printf

Does Range Checking Help? r What if we used strncpy instead of strcpy? strncpy(char *dest, const char *src, size_t n) r Yes – assuming that the programmer has supplied the right value of “n”

Executing Attack Code r A variation of the buffer overflow would have the overflow change the return address to point to the attack code r The implication of this is that when the function returns, control is transferred to the attack code

Executing Attack Code r Suppose buf contains attacker-created string code str Frame of the calling function ret Attacker puts actual assembly instructions into his input string, e.g., binary code of execve(“/bin/sh”) In the overflow, a pointer back into the bufferr appears in the location where the system expects to find return address Top of stack r When function exits, code in the buffer will be executed, giving attacker a shell m Root shell depending on the victim program

Buffer Overflow Issue r Executable attack code is stored on stack, inside the buffer containing attacker’s string m Stack memory is suppose to contain only data, but.. r For the basic attack, overflow portion must contain correct address of attack code in the return position m The value in the RET position must point to the beginning of the attack assembly code –Otherwise you will have a crash m Attacker must correctly guess in which stack position the buffer will be in when the function is called

Safer Languages r Several modern languages have built-in protection against stack overflow. r Java and C# check every array reference to ensure that it is within bounds. r Java does not allow stack violations.