Fall 2008CS 334: Computer SecuritySlide #1 Program Security Buffer Overflows Incomplete Access Control.

Slides:



Advertisements
Similar presentations
1/1/ / faculty of Electrical Engineering eindhoven university of technology Memory Management and Protection Part 3:Virtual memory, mode switching,
Advertisements

Lectures on File Management
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.
Names and Bindings.
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.
Chapter 3 Loaders and Linkers
Operating-System Structures
Chapter 3 (Part 1) Network Security
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.
CMSC 414 Computer and Network Security Lecture 24 Jonathan Katz.
Beyond Stack Smashing: Recent Advances in Exploiting Buffer Overruns Jonathan Pincus Microsoft Research Brandon Baker Microsoft Carl Hartung CSCI 7143:
Run time vs. Compile time
Memory Management 1 CS502 Spring 2006 Memory Management CS-502 Spring 2006.
CS-3013 & CS-502, Summer 2006 Memory Management1 CS-3013 & CS-502 Summer 2006.
Building Secure Software Chapter 9 Race Conditions.
Chap 3: Program Security.  Programming errors with security implications: buffer overflows, incomplete access control  Malicious code: viruses, worms,
Lecture 12 Overview.
CSE 451: Operating Systems Autumn 2013 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
CS252: Systems Programming Ninghui Li Final Exam Review.
System Calls 1.
Security Exploiting Overflows. Introduction r See the following link for more info: operating-systems-and-applications-in-
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.
Dr. José M. Reyes Álamo 1.  The 80x86 memory addressing modes provide flexible access to memory, allowing you to easily access ◦ Variables ◦ Arrays ◦
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.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
Chapter 2: Operating-System Structures. 2.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 2: Operating-System Structures Operating.
Attacking Applications: SQL Injection & Buffer Overflows.
Memory Management 3 Tanenbaum Ch. 3 Silberschatz Ch. 8,9.
Mitigation of Buffer Overflow Attacks
CIS 450 – Network Security Chapter 7 – Buffer Overflow Attacks.
Lecture slides prepared for “Computer Security: Principles and Practice”, 3/e, by William Stallings and Lawrie Brown, Chapter 10 “Buffer Overflow”.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Memory: Relocation.
Chapter 4 Memory Management Virtual Memory.
Chapter-4 Software Security Why Software?  Why is software as important to security as crypto, access control and protocols?  Virtually all of information.
RUN-Time Organization Compiler phase— Before writing a code generator, we must decide how to marshal the resources of the target machine (instructions,
Buffer Overflow Proofing of Code Binaries By Ramya Reguramalingam Graduate Student, Computer Science Advisor: Dr. Gopal Gupta.
CPSC 6126 Computer Security Information Assurance.
Operating Systems Security
Operating Systems CSE 411 CPU Management Sept Lecture 10 Instructor: Bhuvan Urgaonkar.
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.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Buffer overflow and stack smashing attacks Principles of application software security.
Security Attacks Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Embedding Assembly Code in C Programs תרגול 7 שילוב קוד אסמבלי בקוד C.
Lecture 5 Rootkits Hoglund/Butler (Chapters 1-3).
Writing Secure Programs. Program Security CSCE Farkas/Eastman - Fall Program Flaws Taxonomy of flaws: how (genesis) when (time) where (location)
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.
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.
Object Lifetime and Pointers
Buffer Overflows Incomplete Access Control
Mitigation against Buffer Overflow Attacks
Protecting Memory What is there to protect in memory?
Protecting Memory What is there to protect in memory?
Protecting Memory What is there to protect in memory?
Chapter 2: System Structures
Chapter 9 :: Subroutines and Control Abstraction
Machine Independent Features
CSE 451: Operating Systems Spring 2012 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
Format String.
Chapter 2: Operating-System Structures
Understanding and Preventing Buffer Overflow Attacks in Unix
COMP755 Advanced Operating Systems
Presentation transcript:

Fall 2008CS 334: Computer SecuritySlide #1 Program Security Buffer Overflows Incomplete Access Control

Fall 2008CS 334: Computer SecuritySlide #2 Why Program Security? Because program flaws are the gateway through which many attacks are launched: –Intrusion detection, network security (e.g. firewalls) are necessary because computers (and specifically the programs they run) are vulnerable to attack. Because understanding how programs are attacked can help you to write more secure code.

Fall 2008CS 334: Computer SecuritySlide #3 Secure Programs How do we define the term secure program? –Program that meets specification? Specifications can be incorrect, incomplete, or vague Consider example in text (p. 96) of “locked” computers that all used same keys How do we identify secure programs? –# of faults discovered and fixed during design, development, etc?

Fall 2008CS 334: Computer SecuritySlide #4 History: Fixing Faults Software engineering research has shown that software that has many faults early on is likely to have many others waiting to be found ``Penetrate and Patch’’: Analysts search for and repair faults –Badness: pressure to repair specific fault often causes tunnel vision (failure to consider context) –Faults often have non-obvious side effects in places other than immediate area of fault –Fixed faults can cause system performance or operation to suffer

Fall 2008CS 334: Computer SecuritySlide #5 Secure Programs Often (somewhat vaguely) based on the notion of expectation: does a program behave as the designer and users expect? Program security flaw: unexpected behavior –Lots of terminology(vulnerability, flaw, faults, failures, etc) –Who cares: only need to know cause (what fault caused the problem) and effect (what failure is visible to user)

Fall 2008CS 334: Computer SecuritySlide #6 Intention Textbooks makes big deal out of notion of malicious versus non-malicious Misleading: –Buffer overflow is non-malicious? Yes, because the flaw is often the result of an accidental oversight of the programmer No, because a buffer overflow attack can be, well, not good

Fall 2008CS 334: Computer SecuritySlide #7 Three Types of Vulnerabilities Buffer Overflow Incomplete Mediation Time-of-check to Time-of-Use (TOCTOU) Errors

Fall 2008CS 334: Computer SecuritySlide #8 Buffer Overflow Simply put, trying to squeeze too much stuff into too small a space Defn: a buffer (or array or string) is a space in which data can be held –Usually, programmer needs to have declared size of the buffer beforehand (but not always) –Also, size cannot always be determined through static analysis (may be run-time decision)

Fall 2008CS 334: Computer SecuritySlide #9 Buffer Overflow Is this access out of bounds? Upshot: compiler cannot identify all out-of- bounds accesses Hope that language run-time flags this (if bad). Many don’t (e.g. C)

Fall 2008CS 334: Computer SecuritySlide #10 Buffer Overflow Effect of overflow is that data outside buffer is overwritten Exact effect depends on what is overwritten –User’s data? –User’s program code? –System data? –System program code?

Fall 2008CS 334: Computer SecuritySlide #11 Buffer Overflow Details You read about them (“Smashing the Stack for Fun and Profit”). Two parts: –Buffer overrun operation that modifies control flow –Execution of the payload Other good references are –Pincus and Baker “Beyond Stack Smashing: Recent Advances in Exploiting Buffer Overruns” –DilDog “The Tao of Windows Buffer Overruns”

Fall 2008CS 334: Computer SecuritySlide #12 Trampolining Allows attacker to apply buffer overflow when the attacker doesn’t know absolute address of buffer ( buff ) Key insight: if a program register R contains a value relative to buff, control can be transferred to buff by first translating control to a sequence of instructions that indirectly transfers via R. –Key: finding such a sequence of instructions at a well-known or predictable address (this is the “trampoline”)

Fall 2008CS 334: Computer SecuritySlide #13 Another Enhancement Separate two parts of buffer overflow –Useful if the buffer being overrun is too small for payload –Attacker arranges for payload to be in another location, possibly executed later Payload in programs memory space? Stored in an environment variable (because typically accessible on linux systems from well-known address near base of the stack)

Fall 2008CS 334: Computer SecuritySlide #14 Heap Overflow Stack is used to store local variables Heap stores memory that is global and also memory that is dynamically allocated (e.g. via call to malloc() )

Fall 2008CS 334: Computer SecuritySlide #15 Arc Injection Attack Instead of supplying code, supply data that will lead to desired effect when programs existing code operates on it. –E.g. attacker supplies a command line that the program under attack will use to spawn another process Called arc injection because the attack causes a new arc (control-flow transfer) into the programs control flow graph, as opposed to code injection (e.g. smashing the stack) which also inserts a new node into graph

Fall 2008CS 334: Computer SecuritySlide #16 Arc Injection Basic Example Stack buffer overrun modifies saved return address to point to location in the program’s address space –Specifically to location within system function in C standard library –system function takes arbitrary command line as argument, checks arguments validity, loads it into a register R, and makes a call to create the process

Fall 2008CS 334: Computer SecuritySlide #17 Arc Injection Example (cont) Attacker arranges for R to point to attacker supplied string, then jumps directly to location target, bypassing validity check and assignment C standard library loads most processes at a well known location, so computing target’s absolute address is straightforward

Fall 2008CS 334: Computer SecuritySlide #18 Arc Injection Example (cont) How does attacker get R to point to attacker supplied string? –It can be trivial: programs routinely reuse registers, so it would not be unusual that the program uses R in the procedure in which a buffer overrun occurs (e.g., pointing to buff in code below). –Attacker simply writes command line string into buff and ensures that target’s location appears at correct offset in buffer to overwrite return address –Then on return, control is passed to middle of system function

Fall 2008CS 334: Computer SecuritySlide #19 Pointer Subterfuge Four flavors –Function-pointer clobbering –Data-pointer modification –Exception-handler hijacking –Virtual Pointer (VPTR)smashing Bottom line is that if you can control pointers, you can cause memory to be overwritten, etc.

Fall 2008CS 334: Computer SecuritySlide #20 Incomplete Mediation An Example: =(808) &parm2=2009Jan17 This URL causes the execution of code on the server that reads the two parameters parm1 and parm2. –There may be code on the client (browser) page that checks validity of parameters. –It’s likely also that the values were entered using forms that prohibit certain kinds of entries for various fields –But the parameters are packed into the URL line, which is user modifiable. So whatever checks were made are ineffective.

Fall 2008CS 334: Computer SecuritySlide #21 Incomplete Mediation The problem: the sensitive data was not completely mediated -- it was placed in an exposed uncontrolled condition A true-life example: &qy=20&price=10&ship=boat&shipcost=5&total=205 &qy=20&price=10&ship=boat&shipcost=5&total=25 original modifie d Question: why even transmit price data?!

Fall 2008CS 334: Computer SecuritySlide #22 TOCTOU Errors Time-of-check to Time-of-Use Errors Synchronization error: basically, exploitable gap between (time condition for accessing object is checked) and (time access actually occurs) Ex: Sculpture costs $100. Buyer counts $100 and places it on table. Seller turns around to write receipt, buyer takes $20 back and hands stack to seller (who assumes there is still $100 in stack) –Between time security was checked (counting bills) and object accessed (get sculpture) the condition changed

Fall 2008CS 334: Computer SecuritySlide #23 TOCTOU Error File system: –Data structure “work ticket” presented to access control module. –Work ticket requires “stamp” authorizing access –Module places copy of ticket in its own work area for checking validity of request, actual ticket remains in user address space. –User modifies data structure in its own address space while access control module is checking the requested file name, etc. –Ticket is validated by access control module (e.g. by returning an auxiliary ticket) –User uses modified data structure with ticket validation for illegal access

Fall 2008CS 334: Computer SecuritySlide #24 Privilege Escalation Access rights and privileges of programs are dictated by program context, which is typically dictated by user running program –You can modify, delete, etc, files you own, but not critical system files Privilege Escalation attack is one in which malicious code is launched by a user with low privilege but run with high privilege

Fall 2008CS 334: Computer SecuritySlide #25 Example (April 2006) Symantec Live Update –Runs with elevated privilege since it needs to download and install programs in system directory –Uses four modules, LU1, LU2, Sys3, and Sys4 First two are part of Live Update, other two are functions in the OS. –In some releases for Mac, Symantec allowed Live Update to locate Sys3 and Sys4 by using the PATH environment variable rather than specifying the location explicitly.

Fall 2008CS 334: Computer SecuritySlide #26 Example (April 2006) But the LU modules run with escalated privilege, and this is passed automatically to the Sys modules. So an attacker can write their own function, call it Sys3 or Sys4, and modify the PATH variable so that this is what is run when Live Update runs. The end result is a user written function running with elevated privileges!

Fall 2008CS 334: Computer SecuritySlide #27 Covert Channels A much researched topic Defn: Programs that communicate information to people who should not receive it. –Communication usually travels unnoticed, accompanying other communications Example: Student helping others cheat on multiple choice exam by coughing, wheezing, moving foot, etc, to indicate choice (a), (b), etc.

Fall 2008CS 334: Computer SecuritySlide #28

Fall 2008CS 334: Computer SecuritySlide #29 Covert Channels Problem: these are easy to create –Timing –Existence of files –Exact format of files Number of blank spaces in fields Incorrect (but unnoticed) information –Availability of resources Dynamically allocated memory available? File locked or unlocked?

Fall 2008CS 334: Computer SecuritySlide #30

Fall 2008CS 334: Computer SecuritySlide #31 File Lock Covert Channel

Fall 2008CS 334: Computer SecuritySlide #32 File Existence Channel Signaling 100

Fall 2008CS 334: Computer SecuritySlide #33 Timing Channel Pass information by using speed at which things happen Example: two process system where info passed by accepting(1) or rejecting(0) offered processing time