Buffer Overflow Prevention ”\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e \x89\xe3\x50\x53\x50\x54\x53\xb0\x3b\x50\xcd\x80” Presented to CRAB April.

Slides:



Advertisements
Similar presentations
Defenses. Preventing hijacking attacks 1. Fix bugs: – Audit software Automated tools: Coverity, Prefast/Prefix. – Rewrite software in a type safe languange.
Advertisements

Computer Security: Principles and Practice EECS710: Information Security Professor Hossein Saiedian Fall 2014 Chapter 10: Buffer Overflow.
Computer Security: Principles and Practice First Edition by William Stallings and Lawrie Brown Lecture slides by Lawrie Brown Chapter 11 – Buffer Overflow.
Lecture 16 Buffer Overflow modified from slides of Lawrie Brown.
Dynamic Taint Analysis for Automatic Detection, Analysis, and Signature Generation of Exploits on Commodity Software Paper by: James Newsome and Dawn Song.
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.
Instruction-Set Randomization “Countering Code-Injection Attacks With Instruction-Set Randomization” G. Kc, A. Keromytis, and V. Prevelakis CCS October.
Beyond Stack Smashing: Recent Advances in Exploiting Buffer Overruns Jonathan Pincus Microsoft Research Brandon Baker Microsoft Carl Hartung CSCI 7143:
Memory Management. 2 How to create a process? On Unix systems, executable read by loader Compiler: generates one object file per source file Linker: combines.
Achieving Trusted Systems by Providing Security and Reliability Ravishankar K. Iyer, Zbigniew Kalbarczyk, Jun Xu, Shuo Chen, Nithin Nakka and Karthik Pattabiraman.
1 RISE: Randomization Techniques for Software Security Dawn Song CMU Joint work with Monica Chew (UC Berkeley)
Lecture 16 Buffer Overflow
Efficient Instruction Set Randomization Using Software Dynamic Translation Michael Crane Wei Hu.
Address Obfuscation: An Efficient Approach to Combat a Broad Range of Memory Error Exploits Sandeep Bhatkar, Daniel C. DuVarney, and R. Sekar Stony Brook.
Address Space Layout Permutation
Security Exploiting Overflows. Introduction r See the following link for more info: operating-systems-and-applications-in-
Operating System Chapter 7. Memory Management Lynn Choi School of Electrical Engineering.
Web Application Access to Databases. Logistics Test 2: May 1 st (24 hours) Extra office hours: Friday 2:30 – 4:00 pm Tuesday May 5 th – you can review.
Carnegie Mellon Selected Topics in Automated Diversity Stephanie Forrest University of New Mexico Mike Reiter Dawn Song Carnegie Mellon University.
Introduction: Exploiting Linux. Basic Concepts Vulnerability A flaw in a system that allows an attacker to do something the designer did not intend,
Buffer Overflow Detection Stuart Pickard CSCI 297 June 14, 2005.
Computer Science Detecting Memory Access Errors via Illegal Write Monitoring Ongoing Research by Emre Can Sezer.
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”.
CNIT 127: Exploit Development Ch 4: Introduction to Format String Bugs.
Vigilante: End-to-End Containment of Internet Worms Authors : M. Costa, J. Crowcroft, M. Castro, A. Rowstron, L. Zhou, L. Zhang, and P. Barham In Proceedings.
nd Joint Workshop between Security Research Labs in JAPAN and KOREA An Enhanced Buffer Separation Scheme to Protect Security Sensitive Data against.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Memory: Relocation.
Buffer Overflow Attack-proofing by Transforming Code Binary Gopal Gupta Parag Doshi, R. Reghuramalingam The University of Texas at Dallas 11/15/2004.
CNIT 127: Exploit Development Ch 3: Shellcode. Topics Protection rings Syscalls Shellcode nasm Assembler ld GNU Linker objdump to see contents of object.
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.
Lecture 9: Buffer Ovefflows and ROP EEN 312: Processors: Hardware, Software, and Interfacing Department of Electrical and Computer Engineering Spring 2014,
Protecting C Programs from Attacks via Invalid Pointer Dereferences Suan Hsi Yong, Susan Horwitz University of Wisconsin – Madison.
Buffer overflow and stack smashing attacks Principles of application software security.
On the Effectiveness of Address-Space Randomization Hovav Shacham, Matthew Page, Ben Pfaff, Eu-Jin Goh, Nagendra Modadugu, Dan Boneh.
Dynamic Taint Analysis for Automatic Detection, Analysis, and Signature Generation of Exploits on Commodity Software Paper by: James Newsome and Dawn Song.
A Survey on Runtime Smashed Stack Detection 坂井研究室 M 豊島隆志.
Buffer Overflows Taught by Scott Coté.-. _ _.-. / \.-. ((___)).-. / \ /.ooM \ / \.-. [ x x ].-. / \ /.ooM \ -/ \ /-----\-----/---\--\ /--/---\-----/-----\ / \-
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.
Memory Management. 2 How to create a process? On Unix systems, executable read by loader Compiler: generates one object file per source file Linker: combines.
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.
Memory Management Chapter 5 Advanced Operating System.
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.
Memory Protection through Dynamic Access Control Kun Zhang, Tao Zhang and Santosh Pande College of Computing Georgia Institute of Technology.
Shellcode COSC 480 Presentation Alison Buben.
Mitigation against Buffer Overflow Attacks
Remix: On-demand Live Randomization
Buffer Overflow Buffer overflows are possible because C doesn’t check array boundaries Buffer overflows are dangerous because buffers for user input are.
Sabrina Wilkes-Morris CSCE 548 Student Presentation
Introduction to Operating Systems
The Hardware/Software Interface CSE351 Winter 2013
CS 465 Buffer Overflow Slides by Kent Seamons and Tim van der Horst
Defending against Stack Smashing attacks
Software Security Lesson Introduction
Format String.
CSC 495/583 Topics of Software Security Format String Bug (2) & Heap
Memory management Explain how memory is managed in a typical modern computer system (virtual memory, paging and segmentation should be described.
Program Execution in Linux
Understanding and Preventing Buffer Overflow Attacks in Unix
Return-to-libc Attacks
Presentation transcript:

Buffer Overflow Prevention ”\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e \x89\xe3\x50\x53\x50\x54\x53\xb0\x3b\x50\xcd\x80” Presented to CRAB April 27, 2004

Outline Buffer overflow review Prevention overview Randomized instruction sets Address randomization Solutions compared Conclusion

What is a Buffer Overflow? Intent  Arbitrary code execution Spawn a remote shell or infect with worm/virus  Denial of service Steps  Inject attack code into buffer  Redirect control flow to attack code  Execute attack code

Attack Possibilities Targets  Stack, heap, static area  Parameter modification (non-pointer data) E.g., change parameters for existing call to exec() Injected code vs. existing code Absolute vs. relative address dependencies Related Attacks  Integer overflows, double-frees  Format-string attacks

Typical Address Space 0x x code static data bss heap shared library stack kernel space 0x xC xFFFFFFFF From Dawn Song’s RISE: argument 2 argument 1 RA frame pointer locals buffer Attack code Address of Attack code

Examples (In)famous: Morris worm (1988)  gets() in fingerd Code Red (2001)  MS IIS.ida vulnerability Blaster (2003)  MS DCOM RPC vulnerability Mplayer URL heap allocation (2004) % mplayer –e ‘print “\””x1024;’`

Preventing Buffer Overflows Strategies  Detect and remove vulnerabilities (best)  Prevent code injection  Detect code injection  Prevent code execution Stages of intervention  Analyzing and compiling code  Linking objects into executable  Loading executable into memory  Running executable

Preventing Buffer Overflows Splint - Check array bounds and pointers Non-executable stack Stackguard – put canary before RA Libsafe – replace vulnerable library functions RAD – check RA against copy Analyze call trace for abnormality PointGuard – encrypt pointers Binary diversity – change code to slow worm propagation PAX – binary layout randomization by kernel Randomize system call numbers

Preventing Buffer Overflows Randomize code  Barrantes, Ackley, Forrest, Palmer, Stefanovic, Zovi, “Randomized Instruction Set Emulation to Disrupt Binary Code Injection Attacks,” ACM CCS Randomize location of code/data  Bhatkar, DuVarney, Sekar, “Address Obfuscation: an Efficient Approach to Combat a Broad Range of Memory Error Exploits,” USENIX Security 2003.

Randomized Instruction Sets Threat: binary code injection from network Goal: de-standardize each system in an externally unobservable way Solution:  Each program has a different and secret instruction set  Use translator to randomize instructions at load- time Limits: no defense against data-only modifications

Data Scrambled Code RISE: loading binary Code Data Valgrind / RISEMemory ELF binary file + Key

RISE: executing code Hardware Data Scrambled Code Valgrind / RISEMemory + Key Code

RISE: foreign code Hardware Data Scrambled Code Valgrind / RISEMemory + Key Code Injected from network Scrambled Code SIGILL

Complications Shared libraries  Usually code from libraries is shared among multiple processes  RISE scrambles shared code, at increased memory expense Protecting plaintext  Descrambled code blocks stored in trace cache  Make cache read-only except when updating Entanglement  Should not use same libraries as process emulated  Some libraries use dispatch tables stored in code

Performance 9 out of 14 attacks failed due to Valgrind itself Others were stopped by RISE RISE costs ~5% more than Valgrind (which is 4-50x slower than native) Keeping “key” and shared libs triples memory x86 opcode space is dense, so “random” instruction might not be illegal

RISE: locations of crash 6% 25% Percentage of runs Offset from start address to failure location

Address Randomization Threat: memory error exploits Goal: remove predictability from memory access Solution:  Relocate memory regions  Permute order of variables and code  Introduce random gaps between objects Limits: not all are easy to implement with common ABIs at load-time

Randomizing Obfuscations Randomize base addresses of memory regions  Stack: subtract large value  Heap: allocate large block  DLLs: link with dummy lib  Code/static data: convert to shared lib, or re-link at different address Makes absolute address- dependent attacks harder code static data bss heap shared library stack kernel space

Randomizing Obfuscations Permute the order of variables / routines  Local variables in stack frame  Order of static variables  Order of routines in DLLs or executable Makes relative-address dependent attacks harder Not implemented by authors

Randomizing Obfuscations Introduce random gaps between objects  Randomly pad stack frames Between frame pointer and local variables  Randomly pad successive malloc() calls  Randomly pad between static variables  Add gaps inside routines and jump s to skip them Helps randomize objects which must maintain relative order First two are implemented by authors

Performance A probabilistic approach, increasing attacker’s expected work Each failed attempt results in crash; at restart, randomization is different ~3000 attempts for P(success) = % overhead on execution time Limited protection for:  Modifications within heap-allocated blocks  Overflows of adjacent data within stack frame or static variables

Comparison RISE xxx

Conclusion Common weaknesses:  Overflows onto adjacent data  Read/write attacks  Double-pointer attacks  Lack of information at runtime Distinguishing pointers from non-pointers Determining sizes of data objects Distinguishing code from data Static analysis + Link & Load-time randomization can be very effective (for now)

References Barrantes, Ackley, Forrest, Palmer, Stefanovic, Zovi, “Randomized Instruction Set Emulation to Disrupt Binary Code Injection Attacks,” ACM CCS Bhatkar, DuVarney, Sekar, “Address Obfuscation: an Efficient Approach to Combat a Broad Range of Memory Error Exploits,” USENIX Security Cowan, Beattie, Johansen, Wagle, “PointGuard: Protecting Pointers From Buffer Overflow Vulnerabilities,” USENIX Security Wilander, Kamkar, “A Comparison of Publicly Available Tools for Dynamic Buffer Overflow Prevention,” NDSS 2003.