Computer Security: Principles and Practice First Edition by William Stallings and Lawrie Brown Lecture slides by Lawrie Brown Chapter 11 – Buffer Overflow.

Slides:



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

Defenses. Preventing hijacking attacks 1. Fix bugs: – Audit software Automated tools: Coverity, Prefast/Prefix. – Rewrite software in a type safe languange.
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.
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 3 Memory Management Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
CMSC 414 Computer and Network Security Lecture 22 Jonathan Katz.
K. Salah1 Buffer Overflow The crown jewel of attacks.
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.
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 24 Jonathan Katz.
Teaching Buffer Overflow Ken Williams NC A&T State University.
Teaching Buffer Overflow Ken Williams NC A&T State University.
1 RISE: Randomization Techniques for Software Security Dawn Song CMU Joint work with Monica Chew (UC Berkeley)
Lecture 16 Buffer Overflow
CMSC 414 Computer and Network Security Lecture 20 Jonathan Katz.
Buffer Overflow Attacks. Memory plays a key part in many computer system functions. It’s a critical component to many internal operations. From mother.
Address Obfuscation: An Efficient Approach to Combat a Broad Range of Memory Error Exploits Sandeep Bhatkar, Daniel C. DuVarney, and R. Sekar Stony Brook.
Java Security. Topics Intro to the Java Sandbox Language Level Security Run Time Security Evolution of Security Sandbox Models The Security Manager.
Shuo Chen, Jun Xu, Emre C. Sezer, Prachi Gauriar, and Ravishankar K. Iyer Brett Hodges April 8, 2010.
Security Exploiting Overflows. Introduction r See the following link for more info: operating-systems-and-applications-in-
Computer Security and Penetration Testing
Buffer Overflows : An In-depth Analysis. Introduction Buffer overflows were understood as early as 1972 The legendary Morris Worm made use of a Buffer.
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
Lecture slides prepared for “Computer Security: Principles and Practice”, 3/e, by William Stallings and Lawrie Brown, Chapter 10 “Buffer Overflow”.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
CNIT 127: Exploit Development Ch 4: Introduction to Format String Bugs.
CE Operating Systems Lecture 3 Overview of OS functions and structure.
Buffer Overflow CS461/ECE422 Spring Reading Material Based on Chapter 11 of the text.
Buffer Overflow Proofing of Code Binaries By Ramya Reguramalingam Graduate Student, Computer Science Advisor: Dr. Gopal Gupta.
Buffer Overflow Group 7Group 8 Nathaniel CrowellDerek Edwards Punna ChalasaniAxel Abellard Steven Studniarz.
Buffer Overflow Attack Proofing of Code Binary Gopal Gupta, Parag Doshi, R. Reghuramalingam, Doug Harris The University of Texas at Dallas.
A Tool for Pro-active Defense Against the Buffer Overrun Attack D. Bruschi, E. Rosti, R. Banfi Presented By: Warshavsky Alex.
Operating Systems Security
CNIT 127: Exploit Development Ch 8: Windows Overflows Part 2.
Lecture 13 Page 1 CS 236 Online Major Problem Areas for Secure Programming Certain areas of programming have proven to be particularly prone to problems.
A Survey on Runtime Smashed Stack Detection 坂井研究室 M 豊島隆志.
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.
Group 9. Exploiting Software The exploitation of software is one of the main ways that a users computer can be broken into. It involves exploiting the.
Foundations of Network and Computer Security J J ohn Black CSCI 6268/TLEN 5550, Spring 2013.
Security Attacks Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Slides by Kent Seamons and Tim van der Horst Last Updated: Nov 11, 2011.
CNIT 127: Exploit Development Ch 8: Windows Overflows Part 1.
1988 Morris Worm … estimated 10% penetration 2001 Code Red … 300,00 computers breached 2003 Slammer/Sapphire … 75,00 infections in 10 min Zotob …
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.
Buffer Overflows: Attacks and Defenses for the Vulnerability of the Decade Crispin Cowan SANS 2000.
Chapter 10 Buffer Overflow 1. A very common attack mechanism o First used by the Morris Worm in 1988 Still of major concern o Legacy of buggy code in.
1 Introduction to Information Security , Spring 2016 Lecture 2: Control Hijacking (2/2) Avishai Wool.
CS703 - Advanced Operating Systems By Mr. Farhan Zaidi.
@Yuan Xue Worm Attack Yuan Xue Fall 2012.
Computer Security: Principles and Practice
Mitigation against Buffer Overflow Attacks
Introduction to Operating Systems
Protecting Memory What is there to protect in memory?
Buffer Overflow & Software Security
Protecting Memory What is there to protect in memory?
Protecting Memory What is there to protect in memory?
Secure Software Development: Theory and Practice
Security mechanisms and vulnerabilities in .NET
CMSC 414 Computer and Network Security Lecture 21
Software Security.
Introduction to Operating Systems
CS 465 Buffer Overflow Slides by Kent Seamons and Tim van der Horst
Software Security Lesson Introduction
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow II: Defense Techniques Cliff Zou Spring 2009.
Understanding and Preventing Buffer Overflow Attacks in Unix
Return-to-libc Attacks
Presentation transcript:

Computer Security: Principles and Practice First Edition by William Stallings and Lawrie Brown Lecture slides by Lawrie Brown Chapter 11 – Buffer Overflow

Buffer Overflow  a very common attack mechanism from 1988 Morris Worm to Code Red, Slammer, Sasser and many others from 1988 Morris Worm to Code Red, Slammer, Sasser and many others  prevention techniques known  still of major concern due to legacy of widely deployed buggy legacy of widely deployed buggy continued careless programming techniques continued careless programming techniques

Buffer Overflow Basics  caused by programming error  allows more data to be stored than capacity available in a fixed sized buffer buffer can be on stack, heap, global data buffer can be on stack, heap, global data  overwriting adjacent memory locations corruption of program data corruption of program data unexpected transfer of control unexpected transfer of control memory access violation memory access violation execution of code chosen by attacker execution of code chosen by attacker

Buffer Overflow Example

Buffer Overflow Attacks  to exploit a buffer overflow an attacker must identify a buffer overflow vulnerability in some program must identify a buffer overflow vulnerability in some program inspection, tracing execution, fuzzing toolsinspection, tracing execution, fuzzing tools understand how buffer is stored in memory and determine potential for corruption understand how buffer is stored in memory and determine potential for corruption

A Little Programming Language History  at machine level all data an array of bytes interpretation depends on instructions used interpretation depends on instructions used  modern high-level languages have a strong notion of type and valid operations not vulnerable to buffer overflows not vulnerable to buffer overflows does incur overhead, some limits on use does incur overhead, some limits on use  C and related languages have high-level control structures, but allow direct access to memory hence are vulnerable to buffer overflow hence are vulnerable to buffer overflow have a large legacy of widely used, unsafe, and hence vulnerable code have a large legacy of widely used, unsafe, and hence vulnerable code

Function Calls and Stack Frames

Stack Buffer Overflow  occurs when buffer is located on stack used by Morris Worm used by Morris Worm “Smashing the Stack” paper popularized it “Smashing the Stack” paper popularized it  have local variables below saved frame pointer and return address hence overflow of a local buffer can potentially overwrite these key control items hence overflow of a local buffer can potentially overwrite these key control items  attacker overwrites return address with address of desired code program, system library or loaded in buffer program, system library or loaded in buffer

Programs and Processes

Stack Overflow Example

Another Stack Overflow

Shellcode  code supplied by attacker often saved in buffer being overflowed often saved in buffer being overflowed traditionally transferred control to a shell traditionally transferred control to a shell  machine code specific to processor and operating system specific to processor and operating system traditionally needed good assembly language skills to create traditionally needed good assembly language skills to create more recently have automated sites/tools more recently have automated sites/tools

Shellcode Development  illustrate with classic Intel Linux shellcode to run Bourne shell interpreter  shellcode must marshall argument for execve() and call it marshall argument for execve() and call it include all code to invoke system function include all code to invoke system function be position-independent be position-independent not contain NULLs (C string terminator) not contain NULLs (C string terminator)

Example Shellcode

Example Stack Overflow Attack

More Stack Overflow Variants  target program can be: a trusted system utility a trusted system utility network service daemon network service daemon commonly used library code, e.g. image commonly used library code, e.g. image  shellcode functions spawn shell spawn shell create listener to launch shell on connect create listener to launch shell on connect create reverse connection to attacker create reverse connection to attacker flush firewall rules flush firewall rules break out of choot environment break out of choot environment

Buffer Overflow Defenses  buffer overflows are widely exploited  large amount of vulnerable code in use despite cause and countermeasures known despite cause and countermeasures known  two broad defense approaches compile-time - harden new programs compile-time - harden new programs run-time - handle attacks on existing programs run-time - handle attacks on existing programs

Compile-Time Defenses: Programming Language  use a modern high-level languages with strong typing not vulnerable to buffer overflow not vulnerable to buffer overflow compiler enforces range checks and permissible operations on variables compiler enforces range checks and permissible operations on variables  do have cost in resource use  and restrictions on access to hardware so still need some code inC like languagesl so still need some code inC like languagesl

Compile-Time Defenses: Safe Coding Techniques  if using potentially unsafe languages eg C  programmer must explicitly write safe code by design with new code by design with new code after code review of existing code, cf OpenBSD after code review of existing code, cf OpenBSD  buffer overflow safety a subset of general safe coding techniques (Ch 12) allow for graceful failure allow for graceful failure checking have sufficient space in any buffer checking have sufficient space in any buffer

Compile-Time Defenses: Language Extension, Safe Libraries  have proposals for safety extensions to C performance penalties performance penalties must compile programs with special compiler must compile programs with special compiler  have several safer standard library variants new functions, e.g. strlcpy() new functions, e.g. strlcpy() safer re-implementation of standard functions as a dynamic library, e.g. Libsafe safer re-implementation of standard functions as a dynamic library, e.g. Libsafe

Compile-Time Defenses: Stack Protection  add function entry and exit code to check stack for signs of corruption  use random canary e.g. Stackguard, Win /GS e.g. Stackguard, Win /GS check for overwrite between local variables and saved frame pointer and return address check for overwrite between local variables and saved frame pointer and return address abort program if change found abort program if change found issues: recompilation, debugger support issues: recompilation, debugger support  or save/check safe copy of return address e.g. Stackshield, RAD e.g. Stackshield, RAD

Run-Time Defenses: Non Executable Address Space  use virtual memory support to make some regions of memory non-executable e.g. stack, heap, global data e.g. stack, heap, global data need h/w support in MMU need h/w support in MMU long existed on SPARC / Solaris systems long existed on SPARC / Solaris systems recent on x86 Linux/Unix/Windows systems recent on x86 Linux/Unix/Windows systems  issues: support for executable stack code need special provisions need special provisions

Run-Time Defenses: Address Space Randomization  manipulate location of key data structures stack, heap, global data stack, heap, global data using random shift for each process using random shift for each process have large address range on modern systems means wasting some has negligible impact have large address range on modern systems means wasting some has negligible impact  also randomize location of heap buffers  and location of standard library functions

Run-Time Defenses: Guard Pages  place guard pages between critical regions of memory flagged in MMU as illegal addresses flagged in MMU as illegal addresses any access aborts process any access aborts process  can even place between stack frames and heap buffers at execution time and space cost at execution time and space cost

Other Overflow Attacks  have a range of other attack variants stack overflow variants stack overflow variants heap overflow heap overflow global data overflow global data overflow format string overflow format string overflow integer overflow integer overflow  more likely to be discovered in future  some cannot be prevented except by coding to prevent originally

Replacement Stack Frame  stack overflow variant just rewrites buffer and saved frame pointer so return occurs but to dummy frame so return occurs but to dummy frame return of calling function controlled by attacker return of calling function controlled by attacker used when have limited buffer overflow used when have limited buffer overflow e.g. off by one e.g. off by one  limitations must know exact address of buffer must know exact address of buffer calling function executes with dummy frame calling function executes with dummy frame

Return to System Call  stack overflow variant replaces return address with standard library function response to non-executable stack defences response to non-executable stack defences attacker constructs suitable parameters on stack above return address attacker constructs suitable parameters on stack above return address function returns and library function executes function returns and library function executes e.g.e.g. system(“shell commands”) attacker may need exact buffer address attacker may need exact buffer address can even chain two library calls can even chain two library calls

Heap Overflow  also attack buffer located in heap typically located above program code typically located above program code memory requested by programs to use in dynamic data structures, e.g. linked lists memory requested by programs to use in dynamic data structures, e.g. linked lists  no return address hence no easy transfer of control hence no easy transfer of control may have function pointers can exploit may have function pointers can exploit or manipulate management data structures or manipulate management data structures  defenses: non executable or random heap

Heap Overflow Example

Global Data Overflow  can attack buffer located in global data may be located above program code may be located above program code if has function pointer and vulnerable buffer if has function pointer and vulnerable buffer or adjacent process management tables or adjacent process management tables aim to overwrite function pointer later called aim to overwrite function pointer later called  defenses: non executable or random global data region, move function pointers, guard pages

Global Data Overflow Example

Summary  introduced basic buffer overflow attacks  stack buffer overflow details  shellcode  defenses compile-time, run-time compile-time, run-time  other related forms of attack replacement stack frame, return to system call, heap overflow, global data overflow replacement stack frame, return to system call, heap overflow, global data overflow