Defenses. Preventing hijacking attacks 1. Fix bugs: – Audit software Automated tools: Coverity, Prefast/Prefix. – Rewrite software in a type safe languange.

Slides:



Advertisements
Similar presentations
Buffer Overflows Nick Feamster CS 6262 Spring 2009 (credit to Vitaly S. from UT for slides)
Advertisements

Stack Protection Systems: (propolice, StackGuard, XP SP2) Hiroaki Etoh Tokyo Research Laboratory, IBM Japan.
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.
Basic Control Hijacking Attacks
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.
StackGuard: A Historical Perspective
Foundations of Network and Computer Security J J ohn Black Lecture #30 Nov 26 th 2007 CSCI 6268/TLEN 5831, Fall 2007.
Breno de MedeirosFlorida State University Fall 2005 Buffer overflow and stack smashing attacks Principles of application software security.
Buffer Overflows By Tim Peterson Joel Miller Dan Block.
1 Information Security – Theory vs. Reality , Winter 2011 Lecture 8: Control hijacking attacks Eran Tromer Slides credit: Dan Boneh, Stanford.
Intro to Exploitation Stack Overflows James McFadyen UTD Computer Security Group 10/20/2011.
1 Control Hijacking Attacks Buffer overflows and format string bugs.
Preventing Buffer Overflow Attacks. Some unsafe C lib functions strcpy (char *dest, const char *src) strcat (char *dest, const char *src) gets (char *s)
Windows XP SP2 Stack Protection Jimmy Hermansson Johan Tibell.
1 Control Hijacking Attacks Buffer overflows and format string bugs.
Control Hijacking Attacks Note: project 1 is out Section this Friday 4:15pm.
Buffer OVERFLOW Attacks and DEFENses Edward Chow
CMSC 414 Computer and Network Security Lecture 25 Jonathan Katz.
1 Buffer Overflow Attacks and Format String bugs.
Defenses from Malware. Preventing exploits Fix bugs: – Audit software Automated tools: Coverity, Prefast/Prefix. – Rewrite software in a type safe languange.
CS426Fall 2010/Lecture 111 Computer Security CS 426 Lecture 11 Software Vulnerabilities: Input Validation Issues & Buffer Overflows.
Eran Tromer Slides credit: Avishai Wool, Tel Aviv University
Lecture 16 Buffer Overflow
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow II: Defense Techniques Cliff Zou Spring 2012.
Buffer Overflow Attacks. Memory plays a key part in many computer system functions. It’s a critical component to many internal operations. From mother.
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow II: Defense Techniques Cliff Zou Spring 2013.
University of Washington CSE 351 : The Hardware/Software Interface Section 5 Structs as parameters, buffer overflows, and lab 3.
Exploits Against Software and How To Avoid Them Nicolas T. Courtois - University College of London.
Address Space Layout Permutation
Control Hijacking Attacks
Mitigation of Buffer Overflow Attacks
Lecture slides prepared for “Computer Security: Principles and Practice”, 3/e, by William Stallings and Lawrie Brown, Chapter 10 “Buffer Overflow”.
Buffer Overflow CS461/ECE422 Spring Reading Material Based on Chapter 11 of the text.
Avishai Wool, lecture Introduction to Information Security Lecture 1.
Exploitation possibilities of memory related vulnerabilities
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.
Control Hijacking Attacks Note: project 1 is out Section this Friday 2pm (Skilling 090)
On the Effectiveness of Address-Space Randomization Hovav Shacham, Matthew Page, Ben Pfaff, Eu-Jin Goh, Nagendra Modadugu, Dan Boneh.
A Survey on Runtime Smashed Stack Detection 坂井研究室 M 豊島隆志.
Buffer Overflows Taught by Scott Coté.-. _ _.-. / \.-. ((___)).-. / \ /.ooM \ / \.-. [ x x ].-. / \ /.ooM \ -/ \ /-----\-----/---\--\ /--/---\-----/-----\ / \-
CNIT 127: Exploit Development Ch 14: Protection Mechanisms.
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.
Control Hijacking Attacks Note: project 1 is out Section this Friday 4:15pm (Gates B03)
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.
Buffer Overflows: Attacks and Defenses for the Vulnerability of the Decade Crispin Cowan SANS 2000.
Chapter 10 Buffer Overflow 1. A very common attack mechanism o First used by the Morris Worm in 1988 Still of major concern o Legacy of buggy code in.
1 Introduction to Information Security , Spring 2016 Lecture 2: Control Hijacking (2/2) Avishai Wool.
CS703 - Advanced Operating Systems By Mr. Farhan Zaidi.
Control Hijacking: Defenses
Mitigation against Buffer Overflow Attacks
Basic Control Hijacking Attacks
Basic Memory Corruption Attacks
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow II: Defense Techniques Cliff Zou Spring 2016.
Introduction to Information Security
Basic Memory Corruption Attacks
CSC 495/583 Topics of Software Security Return-oriented programming
Software Security.
CS 465 Buffer Overflow Slides by Kent Seamons and Tim van der Horst
Preventing Buffer Overflow Attacks
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow II: Defense Techniques Cliff Zou Spring 2011.
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow II: Defense Techniques Cliff Zou Spring 2009.
CNT4704: Analysis of Computer Communication Network Special Topic: Buffer Overflow II: Defense Techniques Cliff Zou Fall 2011.
Presentation transcript:

Defenses

Preventing hijacking attacks 1. Fix bugs: – Audit software Automated tools: Coverity, Prefast/Prefix. – Rewrite software in a type safe languange (Java, ML) Difficult for existing (legacy) code … 2. Concede overflow, but prevent code execution 3. Add runtime code to detect overflows exploits – Halt process when overflow exploit detected – StackGuard, LibSafe, …

Marking memory as non-execute (W^X) Prevent overflow code execution by marking stack and heap segments as non-executable –NX-bit on AMD Athlon 64, XD-bit on Intel P4 Prescott NX bit in every Page Table Entry (PTE) – Deployment: Linux (via PaX project); OpenBSD Windows since XP SP2 (DEP) – Boot.ini : /noexecute=OptIn or AlwaysOn Limitations: – Some apps need executable heap (e.g. JITs). – Does not defend against `return-to-libc’ exploit

Examples: DEP controls in Vista DEP terminating a program

Return to libc Control hijacking without executing code args ret-addr sfp local buf stack exec() printf() “/bin/sh” libc.so

Response: randomization ASLR : ( Address Space Layout Randomization) – Map shared libraries to rand location in process memory  Attacker cannot jump directly to exec function – Deployment: Windows Vista:8 bits of randomness for DLLs – aligned to 64K page in a 16MB region  256 choices Linux (via PaX):16 bits of randomness for libraries – More effective on 64-bit architectures Other randomization methods: – Sys-call randomization: randomize sys-call id’s – Instruction Set Randomization ( ISR )

ASLR Example Booting Vista twice loads libraries into different locations: Note:ASLR is only applied to images for which the dynamic-relocation flag is set

Run time checking

Run time checking: StackGuard Many many run-time checking techniques … – we only discuss methods relevant to overflow protection Solution 1: StackGuard – Run time tests for stack integrity. – Embed “canaries” in stack frames and verify their integrity prior to function return. strretsfplocal top of stack canarystrretsfp local canary Frame 1Frame 2

Canary Types Random canary: – Choose random string at program startup. – Insert canary string into every stack frame. – Verify canary before returning from function. – To corrupt random canary, attacker must learn current random string. Terminator canary: Canary = 0, newline, linefeed, EOF – String functions will not copy beyond terminator. – Attacker cannot use string functions to corrupt stack.

StackGuard (Cont.) StackGuard implemented as a GCC patch. – Program must be recompiled. Minimal performance effects: 8% for Apache. Note: Canaries don’t offer fullproof protection. – Some stack smashing attacks leave canaries unchanged Heap protection: PointGuard. – Protects function pointers and setjmp buffers by encrypting them: XOR with random cookie – More noticeable performance effects

StackGuard variants - ProPolice ProPolice (IBM) - gcc (-fstack-protector) – Rearrange stack layout to prevent ptr overflow. args ret addr SFP CANARY arrays local variables Stack Growth No arrays or pointers Ptrs, but no arrays String Growth

MS Visual Studio /GS [2003] Compiler /GS option: – Combination of ProPolice and Random canary. – Triggers UnHandledException in case of Canary mismatch to shutdown process. Litchfield vulnerability report – Overflow overwrites exception handler – Redirects exception to attack code

Run time checking: Libsafe Solution 2: Libsafe (Avaya Labs) – Dynamically loaded library (no need to recompile app.) – Intercepts calls to strcpy (dest, src) Validates sufficient space in current stack frame: |frame-pointer – dest| > strlen(src) If so, does strcpy, otherwise, terminates application destret-addrsfp top of stack srcbufret-addrsfp libsafe main

More methods …  StackShield  At function prologue, copy return address RET and SFP to “safe” location (beginning of data segment)  Upon return, check that RET and SFP is equal to copy.  Implemented as assembler file processor ( GCC )  Control Flow Integrity (CFI)  A combination of static and dynamic checking  Statically determine program control flow  Dynamically enforce control flow integrity