Secure Coding Techniques

Slides:



Advertisements
Similar presentations
Exploring Security Vulnerabilities by Exploiting Buffer Overflow using the MIPS ISA Andrew T. Phillips Jack S. E. Tan Department of Computer Science University.
Advertisements

Computer Architecture CSCE 350
The University of Adelaide, School of Computer Science
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.
Interrupts Chapter 8 – pp Chapter 10 – pp Appendix A – pp 537 &
Memory Management Questions answered in this lecture: How do processes share memory? What is static relocation? What is dynamic relocation? What is segmentation?
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.
Chapter 15 : Attacking Compiled Applications Alexis Kirat - International Student.
Day 11 Processes. Operating Systems Control Tables.
Beyond Stack Smashing: Recent Advances in Exploiting Buffer Overruns Jonathan Pincus Microsoft Research Brandon Baker Microsoft Carl Hartung CSCI 7143:
Teaching Buffer Overflow Ken Williams NC A&T State University.
Software and Software Vulnerabilities. Synopsis Array overflows Stack overflows String problems Pointer clobbering. Dynamic memory management Integer.
CSE 451: Operating Systems Autumn 2013 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
1 CS503: Operating Systems Part 1: OS Interface Dongyan Xu Department of Computer Science Purdue University.
System Calls 1.
Shuo Chen, Jun Xu, Emre C. Sezer, Prachi Gauriar, and Ravishankar K. Iyer Brett Hodges April 8, 2010.
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:
Computer Security and Penetration Testing
Buffer Overflows Lesson 14. Example of poor programming/errors Buffer Overflows result of poor programming practice use of functions such as gets and.
Attacking Applications: SQL Injection & Buffer Overflows.
Introduction: Exploiting Linux. Basic Concepts Vulnerability A flaw in a system that allows an attacker to do something the designer did not intend,
IT253: Computer Organization Lecture 3: Memory and Bit Operations Tonga Institute of Higher Education.
The ISA Level The Instruction Set Architecture (ISA) is positioned between the microarchtecture level and the operating system level.  Historically, this.
Copyright © 2005 Elsevier Chapter 8 :: Subroutines and Control Abstraction Programming Language Pragmatics Michael L. Scott.
Top Five Web Application Vulnerabilities Vebjørn Moen Selmersenteret/NoWires.org Norsk Kryptoseminar Trondheim
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
CNIT 127: Exploit Development Ch 4: Introduction to Format String Bugs.
1 CSE 451 Section 2: Interrupts, Syscalls, Virtual Machines, and Project 1.
Exploitation possibilities of memory related vulnerabilities
Buffer Overflow Attack Proofing of Code Binary Gopal Gupta, Parag Doshi, R. Reghuramalingam, Doug Harris The University of Texas at Dallas.
Operating Systems Security
Part I The Basic Idea software sequence of instructions in memory logically divided in functions that call each other – function ‘IE’ calls function.
Lecture 14 Page 1 CS 236 Online Variable Initialization Some languages let you declare variables without specifying their initial values And let you use.
Processes and Virtual Memory
JMU GenCyber Boot Camp Summer, Introduction to Penetration Testing Elevating privileges – Getting code run in a privileged context Exploiting misconfigurations.
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.
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.
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.
Buffer Overflows: Attacks and Defenses for the Vulnerability of the Decade Crispin Cowan SANS 2000.
Lecture 14 Page 1 CS 236 Online Secure Programming CS 236 On-Line MS Program Networks and Systems Security Peter Reiher.
Shellcode COSC 480 Presentation Alison Buben.
Mitigation against Buffer Overflow Attacks
Protecting Memory What is there to protect in memory?
Protecting Memory What is there to protect in memory?
Module 30 (Unix/Linux Security Issues II)
Protecting Memory What is there to protect in memory?
Crash Dump Analysis - Santosh Kumar Singh.
A Security Review Process for Existing Software Applications
Secure Software Development: Theory and Practice
Chapter 9 :: Subroutines and Control Abstraction
CS 465 Buffer Overflow Slides by Kent Seamons and Tim van der Horst
Chap. 8 :: Subroutines and Control Abstraction
Chap. 8 :: Subroutines and Control Abstraction
Software Security Lesson Introduction
Format String.
The University of Adelaide, School of Computer Science
Process Description and Control
Lecture Topics: 11/1 General Operating System Concepts Processes
Outline Introduction Memory protection Buffer overflows
Understanding and Preventing Buffer Overflow Attacks in Unix
Outline Introduction Memory protection Buffer overflows
Format String Vulnerability
Presentation transcript:

Secure Coding Techniques " ... the world outside your function should be treated as hostile and bent upon your destruction" [Writing Secure Code, Howard and LeBlanc] "Distrust and caution are the parents of security" - Benjamin Franklin

Three Critical Programming Errors* accepting input from users without validating and sanitizing the input “… the number one killer of healthy software” Monster Mitigations [2011, The MITRE Corporation] allowing data placed in buffers to exceed the length of the buffer “Buffer overflows are Mother Nature's little reminder of that law of physics that says: if you try to put more stuff into a container than it can hold, you're going to make a mess.” Classic Buffer Overflow [2011, The MITRE Corporation] handling integers incorrectly “In the real world, 255+1=256. But to a computer program, sometimes 255+1=0, or 0-1=65535, or maybe 40,000+40,000=14464. […] When programmers forget that computers don't do math like people, bad things ensue - anywhere from crashes, faulty price calculations, infinite loops, and execution of code.” Integer Overflow [2011, The MITRE Corporation] *Responsible for 90% of the critical security vulnerabilities in 2006; SANS Institute. ** 2011 CWE/SANS Top 25 Most Dangerous Software Errors [2011, The MITRE Corporation]

March 23, 2017 – Three days, $833,000 acquiring 51 different bugs March 23, 2017 – Three days, $833,000 acquiring 51 different bugs. Targets: Microsoft, Apple, Adobe and Mozilla with extra incentives for SYSTEM or ROOT level privileges. [Pwn2Own, hosted by Zero Day Initiative, Trend Micro @ CanSecWest.] Mozilla Firefox - an integer overflow and an uninitialized buffer in the Windows kernel to escalate privileges Apple Safari - an info disclosure, 4 different type confusion bugs, and use-after-free vulnerability to escalate to root Adobe Reader - an info leak in Reader followed by a UAF to get code execution. Then leveraged a UAF in the kernel to gain SYSTEM-level privileges. Microsoft Edge - an arbitrary write in Chakra and a logic bug within the sandbox to escape the sandbox. Microsoft Windows - an integer overflow in the kernel to escalate privileges.

March 25, 2017 – Final Day: escaping the virtual machine, getting root, and how to go from guest to root. [Pwn2Own, hosted by Zero Day Initiative, Trend Micro @ CanSecWest.] a heap overflow in Microsoft Edge, a type confusion in the Windows kernel, and an uninitialized buffer in VMware Workstation for a complete virtual machine escape. two separate use-after-free (UAF) bugs in Microsoft Edge and then escalated to SYSTEM using a buffer overflow in the Windows kernel. Virtual Machine Escapes (Guest-to-Host) category: a Windows kernel UAF, a VMWare Workstation info leak, and an uninitialized buffer in Workstation to go guest-to-host. [VMware Tools were not installed in the guest.]

Buffer Overflows data can be stored: - in the program area - on the stack - in the heap in many systems, a memory area is either writable or executable but not both e.g. cannot write into program area → “heap error” buffer overflows in this configuration (program data area) are rare main … … data area 1 sr1 … data area 2 sr2 … JSR XXX DC.L data data area 3

Static Buffer Overflow (stack frame configuration) calling program: define return area push parameters on stack call routine parameter cleanup called program: set up stack frame with local area save registers … do stuff restore registers collapse frame return saved registers local area A6 → A6 old PC (return) parameters return area SP →

Static Buffer Overflow the local area of the routine contains the buffer for a string routine depends on a null terminated string BUT does not calculate the length of the string OR calculates string length but doesn’t verify it against the maximum length user input overflows the buffer intentional vs unintentional SP → saved registers local area A6 → A6 old PC (return) parameters

Static Buffer Overflow What would you like to do? replace the return address with the address of your routine trash the pointer/return for denial of service put payload in local area and execute now or later remember, you can use the frame pointer to do address calculations and local area does not “disappear” payload in local area modifies parameter on previously stacked frame

Heap-based Buffer Overflows heaps are dynamically allocated can overwrite key data can overwrite function pointers in memory can inject code and manipulate pointer to cause execution MS adds cookies to the heap. If cookies are missing/corrupt, raise a heap buffer s/w exception. hdr 1[nxt,prev,s,u] memory space 1 hdr 2[nxt,prev,s,u] memory space 2 header free free memory

Heap-based Buffer Overflows hdr 1[nxt,prev,s,u] memory space 1 hdr 2 memory space 2 header free free memory

Buffer Overflows Attacker’s goal: run own code with privilege To achieve the goal: attack code must be available in the original program’s address space inject the code (payload) on the stack (local variables) on the heap (malloc’d variables) in the static data area (DC,DS) already on user’s machine original program must jump to the attack code modify code addresses

Reading: Three Programming Errors Most Frequently Responsible for Critical Security Vulnerabilities [SANS, ©2007] Secure Coding Guide – Types of Security Vulnerabilities [© 2014 Apple Inc.] Understanding Pool Corruption Part 1 – Buffer Overflows (optional) [@2016 Microsoft] Pool is kernel mode memory used as a storage space for drivers (software that allows your computer to communicate with hardware or devices). If a driver uses more space than is allocated (a buffer overflow), they will write into the next driver’s space and corrupt that driver’s data. When this corrupted memory is run, things will not go well (typically, a blue screen). @RISK: The Consensus Security Vulnerability Alert: March 23, 2017 @RISK provides a weekly summary of (1) newly discovered attack vectors, (2) vulnerabilities with active new exploits, (3) explanations of how recent attacks worked.