Lecture 15 Page 1 CS 236 Online Choosing Technologies Different technologies have different security properties –Operating systems –Languages –Object management.

Slides:



Advertisements
Similar presentations
CSc 352 Programming Hygiene Saumya Debray Dept. of Computer Science The University of Arizona, Tucson
Advertisements

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.
Stack-Based Buffer Overflows Attacker – Can take over a system remotely across a network. local malicious users – To elevate their privileges and gain.
Buffer Overflow Exploits CS-480b Dick Steflik. What is a buffer overflow? Memory global static heap malloc( ), new Stack non-static local variabled value.
Teaching Buffer Overflow Ken Williams NC A&T State University.
Teaching Buffer Overflow Ken Williams NC A&T State University.
Building Secure Software Chapter 9 Race Conditions.
1 Security and Software Engineering Steven M. Bellovin AT&T Labs – Research
Software Development Unit 6.
Security Exploiting Overflows. Introduction r See the following link for more info: operating-systems-and-applications-in-
Lecture 19 Page 1 CS 111 Online Symmetric Cryptosystems C = E(K,P) P = D(K,C) E() and D() are not necessarily the same operations.
Lecture 18 Page 1 CS 111 Online Access Control Security could be easy – If we didn’t want anyone to get access to anything The trick is giving access to.
Lecture 13 Page 1 CS 136, Fall 2014 Secure Programming Computer Security Peter Reiher December 2, 2014.
Computer Security and Penetration Testing
Lecture 16 Page 1 CS 236 Online SQL Injection Attacks Many web servers have backing databases –Much of their information stored in a database Web pages.
Attacking Applications: SQL Injection & Buffer Overflows.
Mitigation of Buffer Overflow Attacks
G53SEC 1 Reference Monitors Enforcement of Access Control.
240-Current Research Easily Extensible Systems, Octave, Input Formats, SOA.
Linux Security. Authors:- Advanced Linux Programming by Mark Mitchell, Jeffrey Oldham, and Alex Samuel, of CodeSourcery LLC published by New Riders Publishing.
Lecture 14 Page 1 CS 236 Online Race Conditions A common cause of security bugs Usually involve multiprogramming or multithreaded programs Caused by different.
Buffer Overflow Group 7Group 8 Nathaniel CrowellDerek Edwards Punna ChalasaniAxel Abellard Steven Studniarz.
Lecture 13 Page 1 CS 236 Online Principles for Secure Software Following these doesn’t guarantee security But they touch on the most commonly seen security.
Lecture 18 Page 1 CS 111 Online OS Use of Access Control Operating systems often use both ACLs and capabilities – Sometimes for the same resource E.g.,
Lecture 14 Page 1 CS 236 Online Variable Initialization Some languages let you declare variables without specifying their initial values And let you use.
Security Issues with PHP  PHP installation  PHP programming Willa Zhu & Eugene Burger.
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.
Lecture 4 Page 1 CS 111 Online Modularity and Virtualization CS 111 On-Line MS Program Operating Systems Peter Reiher.
Lecture 14 Page 1 CS 136, Fall 2014 Secure Programming, Continued Computer Security Peter Reiher December 4, 2014.
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.
Race conditions and synchronization issues Exploiting UNIX.
Lecture9 Page 1 CS 236 Online Operating System Security, Con’t CS 236 On-Line MS Program Networks and Systems Security Peter Reiher.
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 …
Lecture 4 Page 1 CS 111 Online Modularity and Memory Clearly, programs must have access to memory We need abstractions that give them the required access.
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.
Lec. Waleed Bin Shahid.  You might have noticed a lot of issues related to software implementation.  The ultimate requirement of developer(s) is to.
Hank Childs, University of Oregon April 6 th, 2015 CIS 330: _ _ _ _ ______ _ _____ / / / /___ (_) __ ____ _____ ____/ / / ____/ _/_/ ____/__ __ / / / /
Lecture 5 Page 1 CS 111 Online Process Creation Processes get created (and destroyed) all the time in a typical computer Some by explicit user command.
Lecture 14 Page 1 CS 236 Online Secure Programming CS 236 On-Line MS Program Networks and Systems Security Peter Reiher.
Lecture 17 Page 1 CS 136, Fall 2010 Secure Programming, Continued CS 136 Computer Security Peter Reiher November 30, 2010.
Secure Programming Dr. X
Secure Programming Computer Security Peter Reiher February 23, 2017
Major Problem Areas for Secure Programming
Protecting Memory What is there to protect in memory?
Lecture 1-Part 2: Operating-System Structures
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
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
Understanding and Preventing Buffer Overflow Attacks in Unix
Preventing Privilege Escalation
Testing & Security Dr. X.
Secure Programming CS 136 Computer Security Peter Reiher March 2, 2010
Outline Introduction Memory protection Buffer overflows
Outline Introduction Principles for secure software
Choosing Technologies
Presentation transcript:

Lecture 15 Page 1 CS 236 Online Choosing Technologies Different technologies have different security properties –Operating systems –Languages –Object management systems –Libraries Important to choose wisely –And understand the implications of the choice

Lecture 15 Page 2 CS 236 Online Choices and Practicalities You usually don’t get to choose the OS The environment you’re writing for dictates the choice –E.g., commercial software often must be written for Windows –Or Linux is the platform in your company Might not get choice in other areas, either –But exercise it when you can

Lecture 15 Page 3 CS 236 Online Operating System Choices Rarely an option If they are, does it matter? Probably not, any more –All major choices have poor security histories No, Linux is not necessarily safer than Windows –All have exhibited lots of problems –In many cases, problems are in the apps, anyway Exception if you get to choose really trusted platform –E.g., SE Linux or Trusted Solaris Not perfect, but better But at a cost

Lecture 15 Page 4 CS 236 Online Language Choices More likely to be possible –Though often hard to switch from what’s already being used If you do get the choice, what should it be?

Lecture 15 Page 5 CS 236 Online C and C++ Probably the worst security choice Far more susceptible to buffer overflows than other choices Also prone to other reliability problems Often chosen for efficiency –But is efficiency that important for your application?

Lecture 15 Page 6 CS 236 Online Java Less susceptible to buffer overflows Also better error handling than C/C++ Has special built-in security features –Which aren’t widely used But has its own set of problems E.g., exception handling issues And issues of inheritance 19 serious security flaws found between 1996 and 2001 Multiple serious security problems in 2012

Lecture 15 Page 7 CS 236 Online Scripting Languages Depends on language Javascript and CGIbin have awful security reputations Perl offers some useful security features But there are some general issues

Lecture 15 Page 8 CS 236 Online General Security Issues for Scripting Languages Might be security flaws in their interpreters –More likely than in compilers Scripts often easily examined by attackers –Obscurity of binary no guarantee, but it is an obstacle Scripting languages often used to make system calls –Inherently dangerous

Lecture 15 Page 9 CS 236 Online Other Choice Issues Which distributed object management system? –CORBA, DCOM, RMI,.net? –Each has different security properties Which existing components to include? Which authentication technology to use?

Lecture 15 Page 10 CS 236 Online Open Source vs. Closed Source Some argue open source software is inherently more secure The “more eyes” argument – –Since anyone can look at open source code, –More people will examine it –Finding more bugs –Increasing security

Lecture 15 Page 11 CS 236 Online Is the “Many Eyes” Argument Correct? Probably not At least not in general Linux has security bug history similar to Windows Other open source projects even worse –In many cases, nobody really looks at the code –Which is no better than closed source

Lecture 15 Page 12 CS 236 Online The Flip Side Argument “Hackers can examine open source software and find its flaws” Well, Windows’ security history is not a recommendation for this view Most commonly exploited flaws can be found via black-box approach –E.g., typical buffer overflows

Lecture 15 Page 13 CS 236 Online The Upshot? No solid evidence that open source or closed source produces better security Major exception is crypto –At least for crypto standards –Maybe widely used crypto packages –Criticality and limited scope means many eyeballs will really look at it

Lecture 15 Page 14 CS 236 Online Major Security Issues for Secure Design and Coding Buffer overflows Access control issues Race conditions Randomness and determinism Proper use of cryptography Trust management and input validation

Lecture 15 Page 15 CS 236 Online 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

Lecture 15 Page 16 CS 236 Online Preventing Buffer Overflows Use a language with bounds checking –Most modern languages other than C and C++ –Not always a choice –Or the right choice Check bounds carefully yourself Avoid constructs that often cause trouble

Lecture 15 Page 17 CS 236 Online 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

Lecture 15 Page 18 CS 236 Online 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?

Lecture 15 Page 19 CS 236 Online 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

Lecture 15 Page 20 CS 236 Online 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

Lecture 15 Page 21 CS 236 Online 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();

Lecture 15 Page 22 CS 236 Online 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

Lecture 15 Page 23 CS 236 Online How Does That Work? The argument to xmalloc() is an unsigned int Its maximum value is –4,294,967,295 sizeof(char *) is 4 What if the user sets nresp to 0x ? Multiplication is modulo –So 4 * 0x is 0x80

Lecture 15 Page 24 CS 236 Online 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

Lecture 15 Page 25 CS 236 Online 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.

Lecture 15 Page 26 CS 236 Online 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

Lecture 15 Page 27 CS 236 Online 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

Lecture 15 Page 28 CS 236 Online 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

Lecture 15 Page 29 CS 236 Online Access Control Issues Programs usually run under their user’s identity –With his privileges Some programs get expanded privileges –Setuid programs in Unix, e.g. Poor programming here can give too much access

Lecture 15 Page 30 CS 236 Online An Example Problem A program that runs setuid and allows a shell to be forked –Giving the caller a root environment in which to run arbitrary commands Buffer overflows in privileged programs usually give privileged access

Lecture 15 Page 31 CS 236 Online A Real World Example /sbin/dump from NetBSD Ran setgid as group tty –To notify sysadmins of important events –Never dropped this privilege Result: dump would start program of user’s choice as user tty –Allowing them to interact with other user’s terminals

Lecture 15 Page 32 CS 236 Online What To Do About This? Avoid running programs setuid –And avoid other privilege escalation mechanisms If you must, don’t make them root-owned Change back to the real caller as soon as you can –Limiting exposure Use tools like chroot() to compartmentalize

Lecture 15 Page 33 CS 236 Online chroot() Unix command to set up sandboxed environment Programs run with chroot() see different directory as the root of the file system Thus, can’t see anything not under that directory Other systems have different approaches

Lecture 15 Page 34 CS 236 Online chroot() In Action / usrbinjail libhome chroot jail Creates command shell that treats jail as root of file system usrbin lib >ls / lib

Lecture 15 Page 35 CS 236 Online Problems With This Approach Hard to set up right Confined program has to be able to do its legit work But should not see anything else Difficult to set up an effective but safe jail