Protecting C Programs from Attacks via Invalid Pointer Dereferences Suan Hsi Yong, Susan Horwitz University of Wisconsin – Madison.

Slides:



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

Exploring Security Vulnerabilities by Exploiting Buffer Overflow using the MIPS ISA Andrew T. Phillips Jack S. E. Tan Department of Computer Science University.
Lecture 16 Buffer Overflow modified from slides of Lawrie Brown.
Various languages….  Could affect performance  Could affect reliability  Could affect language choice.
Hastings Purify: Fast Detection of Memory Leaks and Access Errors.
Breno de MedeirosFlorida State University Fall 2005 Buffer overflow and stack smashing attacks Principles of application software security.
A Practical Dynamic Buffer Overflow Detector (CRED) Olatunji Ruwase Monica S. Lam Transmeta Corp. Stanford University Network and Distributed Security.
SAFECode SAFECode: Enforcing Alias Analysis for Weakly Typed Languages Dinakar Dhurjati University of Illinois at Urbana-Champaign Joint work with Sumant.
CSE 451: Operating Systems Section 1. Why are you here? 9/30/102.
Introduction The Approach ’ s Overview A Language of Pointers The Type System Operational Semantics Type Safety Type Inference The Rest of C Experiments.
TaintCheck and LockSet LBA Reading Group Presentation by Shimin Chen.
Securing software by enforcing data-flow integrity Manuel Costa Joint work with: Miguel Castro, Tim Harris Microsoft Research Cambridge University of Cambridge.
Beyond Stack Smashing: Recent Advances in Exploiting Buffer Overruns Jonathan Pincus Microsoft Research Brandon Baker Microsoft Carl Hartung CSCI 7143:
Type-Safe Programming in C George Necula EECS Department University of California, Berkeley.
Pointers and Memory Allocation – part 2 -L. Grewe.
Run-Time Storage Organization
May 9, 2001OSQ Retreat 1 Run-Time Type Checking for Pointers and Arrays in C Wes Weimer, George Necula Scott McPeak, S.P. Rahul, Raymond To.
1 RISE: Randomization Techniques for Software Security Dawn Song CMU Joint work with Monica Chew (UC Berkeley)
May 22, 2002OSQ Retreat 1 CCured: Taming C Pointers George Necula Scott McPeak Wes Weimer
Checking Memory Safety with BLAST Dirk Beyer, et al. FASE 2005 KAIST CS750b 2006 Fall Seonggun Kim.
Lecture 16 Buffer Overflow
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow II: Defense Techniques Cliff Zou Spring 2012.
Statically Detecting Likely Buffer Overflow Vulnerabilities David Larochelle David Evans University of Virginia Department of Computer Science Supported.
Address Obfuscation: An Efficient Approach to Combat a Broad Range of Memory Error Exploits Sandeep Bhatkar, Daniel C. DuVarney, and R. Sekar Stony Brook.
Vulnerability-Specific Execution Filtering (VSEF) for Exploit Prevention on Commodity Software Authors: James Newsome, James Newsome, David Brumley, David.
Address Space Layout Permutation
Security Exploiting Overflows. Introduction r See the following link for more info: operating-systems-and-applications-in-
Buffer Overflow Defenses. ©2002, Jedidiah R. Crandall, Susan L. Gerhart, Jan G. Hogle. Buffer Overflow Defenses Author:
Introduction Overview Static analysis Memory analysis Kernel integrity checking Implementation and evaluation Limitations and future work Conclusions.
Buffer Overflow Detection Stuart Pickard CSCI 297 June 14, 2005.
Computer Science Detecting Memory Access Errors via Illegal Write Monitoring Ongoing Research by Emre Can Sezer.
Lecture slides prepared for “Computer Security: Principles and Practice”, 3/e, by William Stallings and Lawrie Brown, Chapter 10 “Buffer Overflow”.
Computer Science and Software Engineering University of Wisconsin - Platteville 2. Pointer Yan Shi CS/SE2630 Lecture Notes.
Buffer Overflow Defenses. ©2002, Jedidiah R. Crandall, Susan L. Gerhart, Jan G. Hogle. Buffer Overflow Defenses Author:
Overflow Examples 01/13/2012. ACKNOWLEDGEMENTS These slides where compiled from the Malware and Software Vulnerabilities class taught by Dr Cliff Zou.
The Fail-Safe C to Java translator Yuhki Kamijima (Tohoku Univ.)
Buffer Overflow Proofing of Code Binaries By Ramya Reguramalingam Graduate Student, Computer Science Advisor: Dr. Gopal Gupta.
CSCI Rational Purify 1 Rational Purify Overview Michel Izygon - Jim Helm.
Buffer Overflow Attack Proofing of Code Binary Gopal Gupta, Parag Doshi, R. Reghuramalingam, Doug Harris The University of Texas at Dallas.
Highly Scalable Distributed Dataflow Analysis Joseph L. Greathouse Advanced Computer Architecture Laboratory University of Michigan Chelsea LeBlancTodd.
An Undergraduate Course on Software Bug Detection Tools and Techniques Eric Larson Seattle University March 3, 2006.
A Tool for Pro-active Defense Against the Buffer Overrun Attack D. Bruschi, E. Rosti, R. Banfi Presented By: Warshavsky Alex.
Debugging via Run-Time Type Checking Title Page Alexey Loginov, Suan Yong, Susan Horwitz, Thomas Reps University of Wisconsin - Madison.
1 Lecture07: Memory Model 5/2/2012 Slides modified from Yin Lou, Cornell CS2022: Introduction to C.
Sampling Dynamic Dataflow Analyses Joseph L. Greathouse Advanced Computer Architecture Laboratory University of Michigan University of British Columbia.
Dynamic Taint Analysis for Automatic Detection, Analysis, and Signature Generation of Exploits on Commodity Software Paper by: James Newsome and Dawn Song.
A Survey on Runtime Smashed Stack Detection 坂井研究室 M 豊島隆志.
Slides by Kent Seamons and Tim van der Horst Last Updated: Nov 11, 2011.
Pointers1 WHAT IS A POINTER? Simply stated, a pointer is an address. A running program consists of three parts: execution stack, code, and data. They are.
Announcements You will receive your scores back for Assignment 2 this week. You will have an opportunity to correct your code and resubmit it for partial.
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.
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.
Memory Protection through Dynamic Access Control Kun Zhang, Tao Zhang and Santosh Pande College of Computing Georgia Institute of Technology.
Memory-Related Perils and Pitfalls in C
Dynamic Allocation in C
Buffer Overflow Defenses
YAHMD - Yet Another Heap Memory Debugger
Debugging Memory Issues
Seminar in automatic tools for analyzing programs with dynamic memory
Checking Memory Management
High Coverage Detection of Input-Related Security Faults
Memory Management III: Perils and pitfalls Mar 13, 2001
Runtime Monitoring of C Programs for Security and Correctness
Buffer Overflow Defenses
Code-Pointer Integrity
CETS: Compiler-Enforced Temporal Safety for C
Suan Hsi Yong University of Wisconsin – Madison
Run-time environments
Presentation transcript:

Protecting C Programs from Attacks via Invalid Pointer Dereferences Suan Hsi Yong, Susan Horwitz University of Wisconsin – Madison

Invalid Pointer Dereferences Buffer overruns –via pointers or arrays Stale pointers (pointers to freed memory)  Undesirable because –incorrect results –crash / corrupt data –security risk a[i]  *(a+i)

Security Risk Gain control –stack smashing (return address on stack) –function pointers, setjmp buffers, GOT Gain unauthorized access –e.g. changing argument to fopen Corrupt data / Disrupt service

Stack Smashing char buf[12]; char *p = &buf[0]; do { *p = getchar(); } while(*p++ != ‘\0’); buf p return address

Our Approach, for C Dynamically detect invalid writes via pointers –halt execution when detected Efficient (low overhead) No false positives No source code modification needed

Outline Introduction Previous Approaches Description of Approach Experiments Conclusion

Previous Approaches StackGuard: protects return addresses only +efficient +automatic –does not protect other memory locations –platform dependent StackShield: similar, but also protects function pointers

Fat Pointers  Record information about what a pointer should point to CCured, Cyclone +detects all invalid accesses –less flexibility in memory management: requires garbage collection (or region-based model, for Cyclone) –doesn’t handle all of C (rejects some legal C programs) –requires programmer changes to source

associate information with pointer: address and size of referent buf p Fat Pointers buf 12  char buf[12]; char *p = &buf[0]; do { *p = getchar(); } while(*p++ != ‘\0’); return address

associates information with target rather than pointer buf p Our Approach char buf[12]; char *p = &buf[0]; do { *p = getchar(); } while(*p++ != ‘\0’);                                   return address

char buf[12]; char *p = &buf[0]; do { *p = getchar(); } while(*p++ != ‘\0’); buf p                              Which Locations to Mark?   return address  naively: Mark All User-defined Locations

FN_PTR fp = &foo; char buf[12]; char *p = &buf[0]; do { *p = getchar(); } while(*p++ != ‘\0’); (*fp)(); buf p fp                              Which Locations to Mark?   Static Analysis, to permit marking fewer locations

Unsafe Pointers  a pointer p that may point to invalid memory: –p is assigned a non-pointer value, or –p is the result of pointer arithmetic, or –p may become stale only writes via unsafe pointers are checked at runtime –safe pointer dereferences are not checked –for efficiency, we don’t check reads a[i]  *(a+i)

FN_PTR fp = &foo; char buf[12]; char *p = &buf[0]; do { *p = getchar(); } while(*p++ != ‘\0’); (*fp)(); Example: Unsafe Pointers pointers: unsafe safe p fp

Tracked Locations  a location that an unsafe pointer may point to –mirror is marked ok ( ) when allocated, and forbidden (  ) when freed. untracked locations always forbidden (  ) –never pointed-to by unsafe pointer points-to analysis needed

FN_PTR fp = &foo; char buf[12]; char *p = &buf[0]; do { *p = getchar(); } while(*p++ != ‘\0’); (*fp)(); Example: Tracked Locations pointers: unsafe safe p fp p buf fp locations: untracked tracked p buf points-to graph: foo fp

FN_PTR fp = &foo; char buf[12]; char *p = &buf[0]; do { *p = getchar(); } while(*p++ != ‘\0’); (*fp)(); Example: Allocation pointers: unsafe safe p fp p buf fp locations: untracked tracked                                             

FN_PTR fp = &foo; char buf[12]; char *p = &buf[0]; do { *p = getchar(); } while(*p++ != ‘\0’); (*fp)(); Example: Allocation pointers: unsafe safe p fp p buf fp locations: untracked tracked                                              fp

FN_PTR fp = &foo; char buf[12]; char *p = &buf[0]; do { *p = getchar(); } while(*p++ != ‘\0’); (*fp)(); Example: Allocation pointers: unsafe safe p fp p buf fp locations: untracked tracked buf fp                                 

FN_PTR fp = &foo; char buf[12]; char *p = &buf[0]; do { *p = getchar(); } while(*p++ != ‘\0’); (*fp)(); Example: Allocation pointers: unsafe safe p fp p buf fp locations: untracked tracked buf p fp                                 

FN_PTR fp = &foo; char buf[12]; char *p = &buf[0]; do { *p = getchar(); } while(*p++ != ‘\0’); (*fp)(); Example: Checking Writes pointers: unsafe safe p fp p buf fp locations: untracked tracked buf p fp                                 

FN_PTR fp = &foo; char buf[12]; char *p = &buf[0]; do { *p = getchar(); } while(*p++ != ‘\0’); (*fp)(); Example: Checking Writes pointers: unsafe safe p fp p buf fp locations: untracked tracked buf p fp                                 

FN_PTR fp = &foo; char buf[12]; char *p = &buf[0]; do { *p = getchar(); } while(*p++ != ‘\0’); (*fp)(); Example: Checking Writes pointers: unsafe safe p fp p buf fp locations: untracked tracked buf p fp                                 

FN_PTR fp = &foo; char buf[12]; char *p = &buf[0]; do { *p = getchar(); } while(*p++ != ‘\0’); (*fp)(); Example: Checking Writes buf p fp                                   pointers: unsafe safe p fp p buf fp locations: untracked tracked

Tool Overview C source file instru- mented C source file instru- mented exec- utable instru- mented C library unsafe pointers tracked variables Static Analysis Instrumenter C Compiler

Implementation Details Flow-insensitive Points-to Analysis [Das00] –near-linear time, good precision C source-to-source instrumenter [Ckit] –ANSI C compliant, portable Uninstrumented library functions may cause false positives or false negatives –write wrappers to be more precise

Outline Introduction Previous Approaches Description of Approach Experiments Conclusion

Experiments Tool successfully detected two simulated attacks via known vulnerabilities –cfingerd: buffer overrun attack –traceroute: modifying Global Offset Table entry via multiple-free bug

Performance Runtime Overhead (average 1.97×) Cyclone OldenSpec 95Spec 2000

Performance Runtime Overhead (average 1.97×) increasing size (LOC)

Comparing with CCured/Cyclone

Analysis/Instrument/Compile Time Slowdown vs. Compile Time (average 5×) increasing size (LOC)

Future Work Goal: Less unsafe pointers and tracked locations (for better performance and coverage) Array-bounds Check Elimination –98% of dereferences are array accesses Escape Analysis –currently all pointers to stack objects are unsafe Flow-Sensitive Analyses –better points-to analysis –dereferencing uninitialized pointer

Future Work Goal: Less unsafe pointers and tracked locations (for better performance and coverage) Array-bounds Check Elimination –98% of dereferences are array accesses Escape Analysis –currently all pointers to stack objects are unsafe Flow-Sensitive Analyses –better points-to analysis –dereferencing uninitialized pointer

Conclusion We present a tool for detecting invalid pointer dereferences that +has low runtime overhead +does not report false positives +is portable, and does not require programmer changes to source code +protects against a wide range of vulnerabilities, including stack smashing and using freed memory

Protecting C Programs from Attacks via Invalid Pointer Dereferences Suan Hsi Yong, Susan Horwitz University of Wisconsin – Madison – The End –

Related Work Dynamic Debugging Tools –Purify –Valgrind –Safe-C Static techniques –LCLint –ESC –PREfix