Major Problem Areas for Secure Programming

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

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.
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.
CMSC 414 Computer and Network Security Lecture 22 Jonathan Katz.
Part III Counter measures The best defense is proper bounds checking but there are many C/C++ programmers and some are bound to forget  Are there any.
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.
Teaching Buffer Overflow Ken Williams NC A&T State University.
Teaching Buffer Overflow Ken Williams NC A&T State University.
Andrea Bittau, Adam Belay, Ali Mashtizadeh, David Maziéres, Dan Boneh
System Calls 1.
Security Exploiting Overflows. Introduction r See the following link for more info: operating-systems-and-applications-in-
Exploitation: Buffer Overflow, SQL injection, Adobe files Source:
Chapter 6 Buffer Overflow. Buffer Overflow occurs when the program overwrites data outside the bounds of allocated memory It was one of the first exploited.
Lecture 13 Page 1 CS 136, Fall 2014 Secure Programming Computer Security Peter Reiher December 2, 2014.
Computer Security and Penetration Testing
Mitigation of Buffer Overflow Attacks
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 14 Page 1 CS 236 Online Variable Initialization Some languages let you declare variables without specifying their initial values And let you use.
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.
Web Security Firewalls, Buffer overflows and proxy servers.
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.
Lecture 14 Page 1 CS 136, Fall 2012 Secure Programming CS 136 Computer Security Peter Reiher November 15, 2012.
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.
Lecture 15 Page 1 CS 236 Online Choosing Technologies Different technologies have different security properties –Operating systems –Languages –Object management.
Lecture 5 Page 1 CS 111 Summer 2013 Bounded Buffers A higher level abstraction than shared domains or simple messages But not quite as high level as RPC.
Lecture 15 Page 1 CS 136, Fall 2011 Secure Programming CS 136 Computer Security Peter Reiher November 15, 2011.
Lecture 13 Page 1 CS 136, Spring 2016 Secure Programming Computer Security Peter Reiher May 17, 2016.
Lecture 14 Page 1 CS 236 Online Secure Programming CS 236 On-Line MS Program Networks and Systems Security Peter Reiher.
Secure Programming Dr. X
Secure Programming Computer Security Peter Reiher February 23, 2017
Shellcode COSC 480 Presentation Alison Buben.
Mitigation against Buffer Overflow Attacks
Software Security Buffer Overflows more countermeasures
CMSC 345 Defensive Programming Practices from Software Engineering 6th Edition by Ian Sommerville.
Protecting Memory What is there to protect in memory?
Bride of Buffer Overflow
Protecting Memory What is there to protect in memory?
Secure Programming Dr. X
Module 30 (Unix/Linux Security Issues II)
Protecting Memory What is there to protect in memory?
Outline Introduction Principles for secure software
Choosing Technologies
Secure Programming CS 136 Computer Security Peter Reiher May 20, 2014
CSC 495/583 Topics of Software Security Stack Overflows (2)
Swapping Segmented paging allows us to have non-contiguous allocations
CMSC 414 Computer and Network Security Lecture 21
Chapter 9 :: Subroutines and Control Abstraction
High Coverage Detection of Input-Related Security Faults
CS 465 Buffer Overflow Slides by Kent Seamons and Tim van der Horst
Bride of Buffer Overflow
Software Security Lesson Introduction
Outline Introduction Principles for secure software
The future of Software Security Dr. Si Chen
Understanding and Preventing Buffer Overflow Attacks in Unix
COMP755 Advanced Operating Systems
Testing & Security Dr. X.
Secure Programming CS 136 Computer Security Peter Reiher March 2, 2010
Outline Introduction Principles for secure software
Choosing Technologies
Presentation transcript:

Major Problem Areas for Secure Programming Certain areas of programming have proven to be particularly prone to problems What are they? How do you avoid falling into these traps?

Example Problem Areas Buffer overflows and other input verification issues Error handling Access control issues Race conditions Use of randomness Proper use of cryptography Trust Variable synchronization Variable initialization There are others . . .

Buffer Overflows The poster child of insecure programming One of the most commonly exploited types of programming error Technical details of how they occur discussed earlier Key problem is language does not check bounds of variables

Preventing Buffer Overflows Use a language with bounds checking Most modern languages other than C and C++ (and assembler) Not always a choice Or the right choice Not always entirely free of overflows Check bounds carefully yourself Avoid constructs that often cause trouble

Problematic Constructs for Buffer Overflows Most frequently C system calls: gets(), strcpy(), strcat(), sprintf(), scanf(), sscanf(), fscanf(), vfscanf(),vsprintf(), vscanf(), vsscanf(), streadd(), strecpy() There are others that are also risky

Why Are These Calls Risky? They copy data into a buffer Without checking if the length of the data copied is greater than the buffer Allowing overflow of that buffer Assumes attacker can put his own data into the buffer Not always true But why take the risk?

What Do You Do Instead? Many of the calls have variants that specify how much data is copied If used properly, won’t allow the buffer to overflow Those without the variants allow precision specifiers Which limit the amount of data handled

Is That All I Have To Do? No These are automated buffer overflows You can easily write your own Must carefully check the amount of data you copy if you do And beware of integer overflow problems

An Example Actual bug in OpenSSH server: u_int nresp; . . . nresp = packet_get_int(); If (nresp > 0) { response = xmalloc(nresp * sizeof(char *)); for (i=0; i<nresp;i++) response[i] = packet_get_string(NULL); } packet_check_eom();

Why Is This a Problem? nresp is provided by the user nresp = packet_get_int(); But we allocate a buffer of nresp entries, right? response = xmalloc(nresp * sizeof(char *)); So how can that buffer overflow? Due to integer overflow

How Does That Work? The argument to xmalloc() is an unsigned int Its maximum value is 232-1 4,294,967,295 sizeof(char *) is 4 What if the user sets nresp to 0x40000020? Multiplication is modulo 232 . . . So 4 * 0x40000020 is 0x80

What Is the Result? There are 128 entries in response[] And the loop iterates hundreds of millions of times Copying data into the “proper place” in the buffer each time A massive buffer overflow

Other Programming Tools for Buffer Overflow Prevention Software scanning tools that look for buffer overflows Of varying sophistication Use a C compiler that includes bounds checking Typically offered as an option Use integrity-checking programs Stackguard, Rational’s Purity, etc.

Canary Values One method of detecting buffer overflows Akin to the “canary in the mine” Place random value at end of data structure If value is not there later, buffer overflow might have occurred Implemented in language or OS

Data Execution Prevention (DEP) Buffer overflows typically write executable code somewhere DEP prevents this Page is either writable or executable So if overflow can write somewhere, can’t execute the code Present in Windows, Mac OS, etc. Doesn’t help against some advanced techniques

Randomizing Address Space (ASLR) Address Space Layout Randomization Randomly move around where things are stored Base address, libraries, heaps, stack Making it hard for attacker to write working overflow code Used in Windows, Linux, MacOS Not always used, not totally effective Several recent Windows problems from programs not using ASLR