Software and Security Buffer Overflow 1.

Slides:



Advertisements
Similar presentations
Smashing the Stack for Fun and Profit
Advertisements

Defenses. Preventing hijacking attacks 1. Fix bugs: – Audit software Automated tools: Coverity, Prefast/Prefix. – Rewrite software in a type safe languange.
Integrity & Malware Dan Fleck CS469 Security Engineering Some of the slides are modified with permission from Quan Jia. Coming up: Integrity – Who Cares?
Exploring Security Vulnerabilities by Exploiting Buffer Overflow using the MIPS ISA Andrew T. Phillips Jack S. E. Tan Department of Computer Science University.
Chapter 1  Introduction 1 Chapter 1: Introduction.
Computer Security: Principles and Practice EECS710: Information Security Professor Hossein Saiedian Fall 2014 Chapter 10: Buffer Overflow.
CMSC 414 Computer and Network Security Lecture 22 Jonathan Katz.
1 CHAPTER 8 BUFFER OVERFLOW. 2 Introduction One of the more advanced attack techniques is the buffer overflow attack Buffer Overflows occurs when software.
Chapter 6 Weaknesses Exploited
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.
Buffer Overflow By: John Quach and Napoleon N. Valdez.
Teaching Buffer Overflow Ken Williams NC A&T State University.
Application and OS Attacks 1 Application and OS Attacks.
Computer Science 654 Lecture 4: Software Flaws and Malware
Teaching Buffer Overflow Ken Williams NC A&T State University.
Chapter 1  Introduction 1 Chapter 1: Introduction “Begin at the beginning,” the King said, very gravely, “and go on till you come to the end: then stop.”
Netprog: Buffer Overflow1 Buffer Overflow Exploits Taken shamelessly from: netprog/overflow.ppt.
Lecture 12 Overview.
Security Exploiting Overflows. Introduction r See the following link for more info: operating-systems-and-applications-in-
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.
Lecture 6: Buffer Overflow CS 436/636/736 Spring 2014 Nitesh Saxena *Adopted from a previous lecture by Aleph One (Smashing the Stack for Fun and Profit)
G53SEC 1 Software Security Overflows, overruns and (some) confusions.
Chapter 11 Software flaws and malware
BLENDED ATTACKS EXPLOITS, VULNERABILITIES AND BUFFER-OVERFLOW TECHNIQUES IN COMPUTER VIRUSES By: Eric Chien and Peter Szor Presented by: Jesus Morales.
Introduction: Exploiting Linux. Basic Concepts Vulnerability A flaw in a system that allows an attacker to do something the designer did not intend,
Automatic Diagnosis and Response to Memory Corruption Vulnerabilities Presenter: Jianyong Dai Jun Xu, Peng Ning, Chongkyung Kil, Yan Zhai, Chris Bookhot.
Chapter-4 Software Security Why Software?  Why is software as important to security as crypto, access control and protocols?  Virtually all of information.
Overflows & Exploits. In the beginning 11/02/1988 Robert Morris, Jr., a graduate student in Computer Science at Cornell, wrote an experimental, self-replicating,
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 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.
Operating Systems Security
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.
Buffer Overflows Taught by Scott Coté.-. _ _.-. / \.-. ((___)).-. / \ /.ooM \ / \.-. [ x x ].-. / \ /.ooM \ -/ \ /-----\-----/---\--\ /--/---\-----/-----\ / \-
David Evans CS201j: Engineering Software University of Virginia Computer Science Lecture 9: Designing Exceptionally.
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.
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.
1988 Morris Worm … estimated 10% penetration 2001 Code Red … 300,00 computers breached 2003 Slammer/Sapphire … 75,00 infections in 10 min Zotob …
Buffer Overflows: Attacks and Defenses for the Vulnerability of the Decade Crispin Cowan SANS 2000.
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.
Secure Programming Dr. X
Major Problem Areas for Secure Programming
Buffer Overflow Buffer overflows are possible because C doesn’t check array boundaries Buffer overflows are dangerous because buffers for user input are.
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?
Secure Programming Dr. X
Protecting Memory What is there to protect in memory?
CSC 495/583 Topics of Software Security Stack Overflows (2)
Secure Software Development: Theory and Practice
CMSC 414 Computer and Network Security Lecture 21
CS 465 Buffer Overflow Slides by Kent Seamons and Tim van der Horst
Software Security Lesson Introduction
Lecture 9: Buffer Overflow*
CSC 495/583 Topics of Software Security Format String Bug (2) & Heap
CS5123 Software Validation and Quality Assurance
Presentation transcript:

Software and Security Buffer Overflow 1

Why Software? Why is software important to security? Virtually all of information security is implemented in software If your software is subject to attack, your security is broken Regardless of strength of crypto, access control, security protocols, etc. Software is a poor foundation for security Buffer Overflow 2

Bad Software Bad software is everywhere! NASA Mars Lander (cost $165 million) Crashed into Mars Error in converting English and metric units of measure Denver airport Buggy baggage handling system Delayed airport opening by 11 months Cost of delay exceeded $1 million/day MV-22 Osprey Advanced military aircraft Lives have been lost due to faulty software Buffer Overflow 3

Software Issues Attackers “Normal” users Actively look for bugs and flaws Like bad software… …and try to make it misbehave Attack systems thru bad software “Normal” users Find bugs and flaws by accident Hate bad software… …but must learn to live with it Must make bad software work Buffer Overflow 4

Complexity “Complexity is the enemy of security”, Paul Kocher, Cryptography Research, Inc. system Lines of code (LOC) Netscape 17,000,000 Space shuttle 10,000,000 Linux 1,500,000 Windows XP 40,000,000 Boeing 777 7,000,000 A new car contains more LOC than was required to land the Apollo astronauts on the moon Buffer Overflow 5

Lines of Code and Bugs Conservative estimate: 5 bugs/1000 LOC Do the math Typical computer: 3,000 exe’s of 100K each Conservative estimate of 50 bugs/exe About 150k bugs per computer 30,000 node network has 4.5 billion bugs Suppose that only 10% of bugs security-critical and only 10% of those remotely exploitable Then “only” 4.5 million security-critical flaws! Buffer Overflow 6

Software Security Topics Program flaws (unintentional) Buffer overflow Incomplete mediation Race conditions Malicious software (intentional) Viruses Worms Other breeds of malware Buffer Overflow 7

Secure Software In software engineering, try to insure that a program does what is intended Secure software engineering requires that the software does what is intended… …and nothing more Absolutely secure software is impossible Absolute security is almost never possible! How can we manage the risks? Buffer Overflow 8

Program Flaws Program flaws are unintentional But still create security risks The 3 most common types of flaws Buffer overflow (smashing the stack) Incomplete mediation Race conditions Many other flaws can occur Here, we only consider buffer overflow Buffer Overflow 9

Buffer Overflow Buffer Overflow 10

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

Buffer Overflow Q: What happens when this is executed? int main(){ int buffer[10]; buffer[20] = 37;} Q: What happens when this is executed? A: Depending on what resides in memory at location “buffer[20]” Might overwrite user data or code Might overwrite system data or code Buffer Overflow 12

Simple Buffer Overflow Consider boolean flag for authentication Buffer overflow could overwrite flag allowing anyone to authenticate! Boolean flag buffer F O U R S C … T F In some cases, attacker need not be so lucky as to have overflow overwrite flag Buffer Overflow 13

Memory Organization Text == code Data == static variables low address Text == code Data == static variables Heap == dynamic data Stack == “scratch paper” Dynamic local variables Parameters to functions Return address text data heap   SP stack high address Buffer Overflow 14

Simplified Stack Example low  void func(int a, int b){ char buffer[10]; } void main(){ func(1, 2); : SP buffer ret return address SP a SP b SP high  Buffer Overflow 15

Smashing the Stack What happens if buffer overflows? ??? : Program “returns” to wrong location SP buffer overflow ret SP ret… A crash is likely NOT! overflow a SP b SP high  Buffer Overflow 16

Smashing the Stack Trudy has a better idea… Code injection low  Trudy has a better idea… : Code injection Trudy can run code of her choosing! SP evil code ret ret SP a SP b SP high  Buffer Overflow 17

Smashing the Stack Trudy may not know Solutions Address of evil code : Trudy may not know Address of evil code Location of ret on stack Solutions Precede evil code with NOP “landing pad” Insert lots of new ret NOP : NOP evil code ret ret ret : ret : Buffer Overflow 18

Stack Smashing Summary A buffer overflow must exist in the code Not all buffer overflows are exploitable Things must line up just right If exploitable, attacker can inject code Trial and error likely required Lots of help available online Smashing the Stack for Fun and Profit, Aleph One Also heap overflow, integer overflow, etc. Stack smashing is “attack of the decade” Buffer Overflow 19

Stack Smashing Example Program asks for a serial number that the attacker does not know Attacker does not have source code Attacker does have the executable (exe) Program quits on incorrect serial number Buffer Overflow 20

Example By trial and error, attacker discovers an apparent buffer overflow Note that 0x41 is “A” Looks like ret overwritten by 2 bytes! Buffer Overflow 21

Example Next, disassemble bo.exe to find The goal is to exploit buffer overflow to jump to address 0x401034 Buffer Overflow 22

Example Find that 0x401034 is “@^P4” in ASCII Byte order is reversed? Why? X86 processors are “little-endian” Buffer Overflow 23

Example Reverse the byte order to “4^P@” and… Success! We’ve bypassed serial number check by exploiting a buffer overflow Overwrote the return address on the stack Buffer Overflow 24

Example Attacker did not require access to the source code Only tool used was a disassembler to determine address to jump to Can find address by trial and error Necessary if attacker does not have exe For example, a remote attack Buffer Overflow 25

Example Source code of the buffer overflow Flaw easily found by attacker Even without the source code! Buffer Overflow 26

Stack Smashing Prevention 1st choice: employ non-executable stack “No execute” NX bit (if available) Seems like the logical thing to do, but some real code executes on the stack (Java does this) 2nd choice: use safe languages (Java, C#) 3rd choice: use safer C functions For unsafe functions, there are safer versions For example, strncpy instead of strcpy Buffer Overflow 27

Stack Smashing Prevention low  Canary Run-time stack check Push canary onto stack Canary value: Constant 0x000aff0d Or value depends on ret : buffer overflow canary overflow ret a high  b Buffer Overflow 28

Microsoft’s Canary Microsoft added buffer security check feature to C++ with /GS compiler flag Uses canary (or “security cookie”) Q: What to do when canary dies? A: Check for user-supplied handler Handler may be subject to attack Claimed that attacker can specify handler code If so, “safe” buffer overflows become exploitable when /GS is used! Buffer Overflow 29

ASLR Address Space Layout Randomization Randomize place where code is put into memory Makes most buffer overflow attacks probabilistic Vista does this (256 random layouts) Similar thing is done in Mac OS X Buffer Overflow 30

ASLR See work by Ulfar Erlingsson Slides can be found here Buffer Overflow 31

Buffer Overflow The “attack of the decade” for 90’s Will be the attack of the decade for 00’s Can be greatly reduced Use safe languages/safer functions Educate developers, use tools, etc. Buffer overflows will exist for a long time Legacy code Bad software development Buffer Overflow 32