Lecture 12 Overview.

Slides:



Advertisements
Similar presentations
Module R2 CS450. Next Week R1 is due next Friday ▫Bring manuals in a binder - make sure to have a cover page with group number, module, and date. You.
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.
CMSC 414 Computer and Network Security Lecture 22 Jonathan Katz.
Chapter 3 (Part 1) Network 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.
Last time Program security Flaws, faults, and failures
Stack-Based Buffer Overflows Attacker – Can take over a system remotely across a network. local malicious users – To elevate their privileges and gain.
Lecture 2 Page 1 CS 236, Spring 2008 Security Principles and Policies CS 236 On-Line MS Program Networks and Systems Security Peter Reiher Spring, 2008.
CMSC 414 Computer and Network Security Lecture 24 Jonathan Katz.
Chapter 15 : Attacking Compiled Applications Alexis Kirat - International Student.
By Brian Vees.  SQL Injection  Username Enumeration  Cross Site Scripting (XSS)  Remote Code Execution  String Formatting Vulnerabilities.
Web Security A how to guide on Keeping your Website Safe. By: Robert Black.
Information Networking Security and Assurance Lab National Chung Cheng University The Ten Most Critical Web Application Security Vulnerabilities Ryan J.W.
Building Secure Software Chapter 9 Race Conditions.
Computer Security and Penetration Testing
Buffer Overflow Attacks. Memory plays a key part in many computer system functions. It’s a critical component to many internal operations. From mother.
Static Analysis for Security Amir Bazine Per Rehnberg.
2-1 Last time What is our goal in this course? What is security? What is privacy? Who are the adversaries? Assets, vulnerabilities, threats, attacks and.
28/08/2015SJF L31 F21SF Software Engineering Foundations ASSUMPTIONS AND TESTING Monica Farrow EM G30 Material available on Vision.
Security Exploiting Overflows. Introduction r See the following link for more info: operating-systems-and-applications-in-
Prevent Cross-Site Scripting (XSS) attack
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.
Lecture 0 Appendix on Implementation Threats Material from Warren Page & Chpt 11, Information Security by Mark Stamp.
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.
Computer Security and Penetration Testing
BLENDED ATTACKS EXPLOITS, VULNERABILITIES AND BUFFER-OVERFLOW TECHNIQUES IN COMPUTER VIRUSES By: Eric Chien and Peter Szor Presented by: Jesus Morales.
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.
3-Protecting Systems Dr. John P. Abraham Professor UTPA.
1 In the good old days... Years ago… the WWW was made up of (mostly) static documents. –Each URL corresponded to a single file stored on some hard disk.
OSI and TCP/IP Models And Some Vulnerabilities AfNOG th May 2011 – 10 th June 2011 Tanzania By Marcus K. G. Adomey.
Lecture 14 Overview. Secure programs Security implies some degree of trust that the program enforces expected – confidentiality, – integrity, and – availability.
Lecture 14 Program Security CS 450/650 Fundamentals of Integrated Computer Security Slides are modified from Wayne Summers and Ian Goldberg.
SEC835 Runtime integrity and resource control. Application based Denial of Service Application can crash for many reasons and at any time due to programming.
Diagnostic Pathfinder for Instructors. Diagnostic Pathfinder Local File vs. Database Normal operations Expert operations Admin operations.
Security Attacks CS 795. Buffer Overflow Problem Buffer overflows can be triggered by inputs that are designed to execute code, or alter the way the program.
240-Current Research Easily Extensible Systems, Octave, Input Formats, SOA.
Overflow Examples 01/13/2012. ACKNOWLEDGEMENTS These slides where compiled from the Malware and Software Vulnerabilities class taught by Dr Cliff Zou.
Chapter-4 Software Security Why Software?  Why is software as important to security as crypto, access control and protocols?  Virtually all of information.
CSCE 548 Integer Overflows Format String Problem.
Lecture 16 Page 1 CS 236 Online Web Security CS 236 On-Line MS Program Networks and Systems Security Peter Reiher.
CPSC 6126 Computer Security Information Assurance.
A Tool for Pro-active Defense Against the Buffer Overrun Attack D. Bruschi, E. Rosti, R. Banfi Presented By: Warshavsky Alex.
Lecture 11 Overview. Key Management public-key encryption helps address key distribution problems have two aspects of this: – distribution of public keys.
Security Attacks CS 795. Buffer Overflow Problem Buffer overflow Analysis of Buffer Overflow Attacks.
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.
Sairajiv Burugapalli. This chapter covers three main categories of classic software vulnerability: Buffer overflows Integer vulnerabilities Format string.
David Evans CS201j: Engineering Software University of Virginia Computer Science Lecture 9: Designing Exceptionally.
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.
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.
VM: Chapter 7 Buffer Overflows. csci5233 computer security & integrity (VM: Ch. 7) 2 Outline Impact of buffer overflows What is a buffer overflow? Types.
Software Security. Bugs Most software has bugs Some bugs cause security vulnerabilities Incorrect processing of security related data Incorrect processing.
Secure Programming Dr. X
Major Problem Areas for Secure Programming
Buffer Overflows Incomplete Access Control
Introduction to Operating Systems
Protecting Memory What is there to protect in memory?
Protecting Memory What is there to protect in memory?
SQL and SQL*Plus Interaction
Secure Programming Dr. X
Protecting Memory What is there to protect in memory?
Text Book: Security in Computing
Introduction to Operating Systems
CS 465 Buffer Overflow Slides by Kent Seamons and Tim van der Horst
Software Security Lesson Introduction
Format String.
Security Principles and Policies CS 236 On-Line MS Program Networks and Systems Security Peter Reiher.
Understanding and Preventing Buffer Overflow Attacks in Unix
Format String Vulnerability
Presentation transcript:

Lecture 12 Overview

Secure programs Security implies some degree of trust that the program enforces expected confidentiality, integrity, and availability. Why is it so hard to write secure programs? Axiom (Murphy): Programs have bugs Corollary: Security-relevant programs have security bugs CS 450/650 Lecture 12: Program Security

Flaws, faults, and failures A flaw is a problem with a program A security flaw is a problem that affects security in some way Confidentiality, integrity, availability Flaws come in two types: faults and failures A fault is a mistake “behind the scenes” An error in the code, data, specification, process, etc. A fault is a potential problem CS 450/650 Lecture 12: Program Security

Flaws, faults, and failures A failure is when something actually goes wrong “Goes wrong” means deviation from desired behaviour, not necessarily from specified behaviour! A failure is the user/outside view The quantity and types of faults in requirements design and code implementation are often used as evidence of a product‘s quality or security CS 450/650 Lecture 12: Program Security

Finding and fixing faults Once you find some faults, fix them Usually by making small edits (called patches) to the program This is called “penetrate and patch” Patching sometimes makes things worse! Pressure to patch a fault is often high Fault may have caused other failures and a partial fix may cause inconsistencies or other problems The patch for this fault may introduce new faults, here or elsewhere! CS 450/650 Lecture 12: Program Security

Unexpected behaviour When a program's behaviour is specified, spec usually lists the things the program must do Most implementers wouldn't care if it did additional things as well But from a security / privacy point of view, extra behaviours could be bad! When implementing a security or privacy relevant program, consider “and nothing else” to be implicitly added to the spec CS 450/650 Lecture 12: Program Security

Types of security flaws: Genesis Some flaws are intentional Malicious flaws are intentionally inserted to attack If it's meant to attack some particular system, we call it a targeted malicious flaw Nonmalicious (but intentional) flaws are often features that are meant to be in the system are correctly implemented, but can cause a failure when used by an attacker Most security flaws are caused by unintentional program errors CS 450/650 Lecture 12: Program Security

Types of security flaws Most common sources of unintentional security flaws Buffer overflows Incomplete mediation TOCTTOU errors (race conditions)‏ CS 450/650 Lecture 12: Program Security

Buffer overflows The single most commonly exploited type of security flaw Simple example: #define LINELEN 1024 char buffer[LINELEN]; gets(buffer); or strcpy(buffer, argv[1]); CS 450/650 Lecture 12: Program Security

Buffer overflows problem? The gets and strcpy functions don't check that the string they're copying into the buffer will fit in the buffer! Some languages would give an exception here, and crash the program. Is this an OK solution C doesn't even notice something bad happened, and continues on its merry way the most commonly used language for systems programming CS 450/650 Lecture 12: Program Security

Where a Buffer Can Overflow CS 450/650 Lecture 12: Program Security

Smashing The Stack For Fun And Profit This is a classic (somewhat dated) exposition of how buffer overflow attacks work Upshot: if the attacker can write data past the end of an array on the stack, he can usually overwrite things like the saved return address When the function returns, it will jump to any address of his choosing Targets: programs on a local machine that run with setuid (superuser) privileges, or network daemons on a remote machine CS 450/650 Lecture 12: Program Security

Kinds of buffer overflows In addition to the classic attack which overflows a buffer on the stack to jump to shellcode, there are many variants: Attacks which work when a single byte can be written past the end of the buffer often caused by a common off-by-one error Overflows of buffers on the heap instead of the stack Jump to other parts of the program, or parts of standard libraries, instead of shellcode CS 450/650 Lecture 12: Program Security

Defences against buffer overflows Use a language with bounds checking And catch those exceptions! Non-executable stack memory page is either writable or executable Stack (and code) at random addresses Linux 2.6 does this “Canaries” that detect if the stack has been overwritten before return from each function This is a compiler feature CS 450/650 Lecture 12: Program Security

Integer overflows Machine integers can represent only a limited set of numbers might not correspond to programmer's model Program assumes integer is always positive overflow will make (signed) integer wrap and become negative, which will violate assumption Program casts large unsigned integer to signed integer Result of a mathematical operation causes overflow Attacker can pass values to program that will trigger overflow CS 450/650 Lecture 12: Program Security

Lecture 13 Program Security (cont) CS 450/650 Fundamentals of Integrated Computer Security Slides are modified from Wayne Summers and Ian Goldberg

Types of security flaws Most common sources of unintentional security flaws Buffer overflows Incomplete mediation TOCTTOU errors (race conditions)‏ CS 450/650 Lecture 13: Program Security

Format string vulnerabilities Unfiltered user input is used as format string in printf(), fprintf(), sprintf(),. . . printf(buffer) instead of printf("%s", buffer) First one will parse buffer for %'s and use whatever is currently on the stack to process found format parameters printf("%s%s%s%s") will likely crash program printf("%x%x%x%x") will dump parts of the stack The %n format parameter will cause writes to the stack CS 450/650 Lecture 13: Program Security

Incomplete mediation Inputs to programs are often specified by untrusted users Web-based applications are a common example Users sometimes mistype data in forms Phone number: 51998884567 Email: iang#cs.uwaterloo.ca An application needs to ensure that what user has entered constitutes a meaningful request This is called mediation CS 450/650 Lecture 12: Program Security

Incomplete mediation Incomplete mediation occurs when the application accepts incorrect data from user Sometimes this is hard to avoid Phone number: 519-886-4567 This is a reasonable entry, that happens to be wrong CS 450/650 Lecture 12: Program Security

Incomplete mediation We focus on catching entries that are clearly wrong Not well formed DOB: 1980-04-31 Unreasonable values DOB: 1876-10-12 Inconsistent with other entries CS 450/650 Lecture 13: Program Security

Why do we care? What happens if someone fills in: DOB: 98764874236492483649247836489236492 Buffer overflow? DOB: '; DROP DATABASE clients -- SQL injection? We need to make sure that any user-supplied input falls within well-specified values known to be safe CS 450/650 Lecture 13: Program Security

Client-side mediation forms that do client-side mediation When you click “submit”, Javascript code will first run validation checks on the data you entered If you enter invalid data, a popup will prevent you from submitting it Related issue: client-side state Many web sites rely on the client to keep state for them Put hidden fields in the form which are passed back to the server when user submits the form CS 450/650 Lecture 13: Program Security

Client-side mediation Problem: what if the user Turns off Javascript? Edits the form before submitting it? Writes a script that interacts with the web server instead of using a web browser at all? Connects to the server “manually”? telnet server.com 80 Note that the user can send arbitrary (unmediated) values to the server this way The user can also modify any client-side state CS 450/650 Lecture 13: Program Security

Example At a bookstore website, user orders a copy of the course text. Server replies with a form asking the address to ship to. This form has hidden fields storing the user's order <input type=“hidden” name=“isbn” value=“0-13-239077-9”> <input type=“hidden” name=“quantity” value=“1”> <input type=“hidden” name=“unitprice” value=“111.00”> What happens if the user changes the “unitprice” value to “50.00” before submitting the form? CS 450/650 Lecture 13: Program Security

Defences against incomplete mediation Client-side mediation is an OK method to use in order to have a friendlier user interface but is useless for security purposes. You have to do server-side mediation whether or not you also do client-side CS 450/650 Lecture 13: Program Security

Defences against incomplete mediation For values entered by the user Always do very careful checks on the values of all fields These values can potentially contain completely arbitrary 8-bit data and be of any length For state stored by the client: Make sure the client has not modified the data in any way CS 450/650 Lecture 13: Program Security

Time-Of-Check To Time-Of-Use errors TOCTTOU (“TOCK-too”) errors Also known as “race condition” errors These errors occur when the following happens: User requests the system to perform an action The system verifies the user is allowed to perform the action The system performs the action So? CS 450/650 Lecture 13: Program Security

Example setuid allocates terminals to users a privileged operation supports writing contents of terminal to a log file first checks if the user has permissions to write to the requested file; if so, it opens the file for writing The attacker makes a symbolic link: logfile -> file_he_owns Between the “check” and the “open”, he changes it: logfile -> /etc/passwd CS 450/650 Fundamentals of Integrated Computer Security

The problem State of the system changed between the check for permission and the execution of operation File whose permissions were checked for writeability by the user (file_he_owns) wasn't the same file that was later written to (/etc/passwd)‏ Even though they had the same name (logfile) at different points in time CS 450/650 Lecture 12: Program Security