Formal Reasoning of Security Vulnerabilities by Pointer Taintedness Semantics S. Chen, K. Pattabiraman, Z. Kalbarczyk and R. K. Iyer Center for Reliable.

Slides:



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

Dynamic Memory Allocation in C.  What is Memory What is Memory  Memory Allocation in C Memory Allocation in C  Difference b\w static memory allocation.
Defenses. Preventing hijacking attacks 1. Fix bugs: – Audit software Automated tools: Coverity, Prefast/Prefix. – Rewrite software in a type safe languange.
1/1/ / faculty of Electrical Engineering eindhoven university of technology Introduction Part 2: Data types and addressing modes dr.ir. A.C. Verschueren.
I/O: SPARC Assembly Department of Computer Science Georgia State University Georgia State University Updated Spring 2014.
What is a pointer? First of all, it is a variable, just like other variables you studied So it has type, storage etc. Difference: it can only store the.
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.
Review: Software Security David Brumley Carnegie Mellon University.
Breno de MedeirosFlorida State University Fall 2005 Buffer overflow and stack smashing attacks Principles of application software security.
Defeating Memory Corruption Attacks via Pointer Taintedness Detection Shuo Chen †, Jun Xu ‡, Nithin Nakka †, Zbigniew Kalbarczyk † and Ravi K. Iyer † ‡
Chapter 10.
TaintCheck and LockSet LBA Reading Group Presentation by Shimin Chen.
Teaching Buffer Overflow Ken Williams NC A&T State University.
Security Protection and Checking in Embedded System Integration Against Buffer Overflow Attacks Zili Shao, Chun Xue, Qingfeng Zhuge, Edwin H.-M. Sha International.
Teaching Buffer Overflow Ken Williams NC A&T State University.
1 Achieving Trusted Systems by Providing Security and Reliability (Research Project #22) Project Members: Ravishankar K. Iyer, Zbigniew Kalbarczyk, Jun.
Characterizing and Reasoning about Security Vulnerabilities Shuo Chen Center for Reliable and High-Performance Computing Coordinated Science Laboratory.
Achieving Trusted Systems by Providing Security and Reliability Ravishankar K. Iyer, Zbigniew Kalbarczyk, Jun Xu, Shuo Chen, Nithin Nakka and Karthik Pattabiraman.
In vfprintf(), if (fmt points to “%n”) then **ap = (character count) Achieving Trusted Systems by Providing Security and Reliability FORMAL REASONING ON.
Testing a program Remove syntax and link errors: Look at compiler comments where errors occurred and check program around these lines Run time errors:
Control hijacking attacks Attacker’s goal: – Take over target machine (e.g. web server) Execute arbitrary code on target by hijacking application control.
University of Washington CSE 351 : The Hardware/Software Interface Section 5 Structs as parameters, buffer overflows, and lab 3.
Security Exploiting Overflows. Introduction r See the following link for more info: operating-systems-and-applications-in-
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.
CSC3315 (Spring 2009)1 CSC 3315 Programming Languages Hamid Harroud School of Science and Engineering, Akhawayn University
Mathematical Modeling and Formal Specification Languages CIS 376 Bruce R. Maxim UM-Dearborn.
Computer Security and Penetration Testing
1 Enhancing Security of Real-World Systems with a Better Understanding of Threats Shuo Chen Candidate of Ph.D. in Computer Science Center for Reliable.
1 Enhancing Security of Real-World Systems with a Better Understanding of Threats Shuo Chen Candidate of Ph.D. in Computer Science Center for Reliable.
Computer Science Detecting Memory Access Errors via Illegal Write Monitoring Ongoing Research by Emre Can Sezer.
1 Enhancing Security of Real-World Systems with a Better Understanding of Threats Shuo Chen Ph.D. Candidate in Computer Science Center for Reliable and.
UniMAP Sem1-07/08EKT120: Computer Programming1 Week2.
Advanced Computer Architecture Lab University of Michigan USENIX Security ’03 Slide 1 High Coverage Detection of Input-Related Security Faults Eric Larson.
Exploitation possibilities of memory related vulnerabilities
CSCE 548 Integer Overflows Format String Problem.
Buffer Overflow Proofing of Code Binaries By Ramya Reguramalingam Graduate Student, Computer Science Advisor: Dr. Gopal Gupta.
Programming Languages and Design Lecture 3 Semantic Specifications of Programming Languages Instructor: Li Ma Department of Computer Science Texas Southern.
Buffer Overflow Attack Proofing of Code Binary Gopal Gupta, Parag Doshi, R. Reghuramalingam, Doug Harris The University of Texas at Dallas.
Part I The Basic Idea software sequence of instructions in memory logically divided in functions that call each other – function ‘IE’ calls function.
Computer Organization and Design Pointers, Arrays and Strings in C Montek Singh Sep 18, 2015 Lab 5 supplement.
1 Enhancing Security of Real-World Systems with a Better Understanding of the Threats Shuo Chen Candidate of Ph.D. in Computer Science Center for Reliable.
Buffer overflow and stack smashing attacks Principles of application software security.
Buffer Overflow Attack- proofing of Code Binaries Ramya Reguramalingam Gopal Gupta Gopal Gupta Department of Computer Science University of Texas at Dallas.
Dynamic Taint Analysis for Automatic Detection, Analysis, and Signature Generation of Exploits on Commodity Software Paper by: James Newsome and Dawn Song.
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.
ECE 526 – Network Processing Systems Design Microengine Programming Chapter 23: D. E. Comer.
Arrays in MIPS Assembly Computer Organization and Assembly Language: Module 6.
/ PSWLAB Evidence-Based Analysis and Inferring Preconditions for Bug Detection By D. Brand, M. Buss, V. C. Sreedhar published in ICSM 2007.
VM: Chapter 7 Buffer Overflows. csci5233 computer security & integrity (VM: Ch. 7) 2 Outline Impact of buffer overflows What is a buffer overflow? Types.
1 Enhancing Security of Real-World Systems with a Better Understanding of Threats Shuo Chen Ph.D. Candidate in Computer Science Center for Reliable and.
Protecting C and C++ programs from current and future code injection attacks Yves Younan, Wouter Joosen and Frank Piessens DistriNet Department of Computer.
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
Software Security. Bugs Most software has bugs Some bugs cause security vulnerabilities Incorrect processing of security related data Incorrect processing.
1 Introduction to Information Security , Spring 2016 Lecture 2: Control Hijacking (2/2) Avishai Wool.
Lecture 3 Translation.
CSC 482/582: Computer Security
Content Coverity Static Analysis Use cases of Coverity Examples
Buffer Overflow Buffer overflows are possible because C doesn’t check array boundaries Buffer overflows are dangerous because buffers for user input are.
The Hardware/Software Interface CSE351 Winter 2013
Module 30 (Unix/Linux Security Issues II)
Introduction to Information Security
Ken D. Nguyen Department of Computer Science Georgia State University
Format String.
CSC 495/583 Topics of Software Security Format String Bug (2) & Heap
Ken D. Nguyen Department of Computer Science Georgia State University
Understanding and Preventing Buffer Overflow Attacks in Unix
Format String Vulnerability
Presentation transcript:

Formal Reasoning of Security Vulnerabilities by Pointer Taintedness Semantics S. Chen, K. Pattabiraman, Z. Kalbarczyk and R. K. Iyer Center for Reliable and High-Performance Computing University of Illinois at Urbana-Champaign

Our Previous Work on Security Vulnerability Analysis Appears in DSN Appears in DSN Analyzed CERT and Bugtraq reports and the corresponding application source code. Analyzed CERT and Bugtraq reports and the corresponding application source code. Developed a state machine representation approach to decompose security vulnerabilities to a series of primitive operations, each indicating a simple predicate. Developed a state machine representation approach to decompose security vulnerabilities to a series of primitive operations, each indicating a simple predicate. The analyzed vulnerabilities include Stack Overflow, Heap Corruption, Integer Overflow, Format String Vulnerability, and others. The analyzed vulnerabilities include Stack Overflow, Heap Corruption, Integer Overflow, Format String Vulnerability, and others.

Use the func pointer. Malicious code executed. Use the negative integer as an array index to corrupt a func pointer Get a very large integer, which is converted into a negative Sendmail Signed Integer Overflow (Bugtraq #3163) addr_setuid unchanged tTvect[x]=i addr_setuid changed Execute code referred by addr_setuid convert str_i and str_x to integer i and x ( integer represented by str_x) > 2 31 x  100 x > 100 ? Execute MCode get text strings str_x and str_i ? x  x  100 Function pointer is corrupted Load the function pointer ( integer represented by str_x)  2 31 pFSM 1 pFSM 2 pFSM 3

Current Work

Motivation Our analysis on CERT advisories shows Our analysis on CERT advisories shows –Many vulnerabilities (  66%) due to incorrect pointer dereferences –A significant portion of vulnerabilities (  33.6%) due to errors in library functions or incorrect invocations of library functions Motivating questions Motivating questions –What is the common characteristic among most security vulnerabilities? –How to develop a generic reasoning approach to find a wide spectrum of security vulnerabilities?

Formal Analysis of Pointer Taintedness : a pointer value, including a return address, is derived directly or indirectly from user input. (formally defined using equational logic) Pointer Taintedness: a pointer value, including a return address, is derived directly or indirectly from user input. (formally defined using equational logic) It provides a unifying perspective for reasoning about a significant number of security vulnerabilities. It provides a unifying perspective for reasoning about a significant number of security vulnerabilities. The notion of pointer taintedness enables: The notion of pointer taintedness enables: –Static analysis: reasoning about the possibility of pointer taintedness by source code analysis; –Runtime checking: inserting assertions in object code to check pointer taintedness at runtime; –Hardware architecture-based support to detect pointer taintedness. Current focus: extraction of security specifications of library functions based on pointer taintedness semantics. Current focus: extraction of security specifications of library functions based on pointer taintedness semantics.

Examples Vulnerabilities Caused by Pointer Taintedness Format string vulnerability Format string vulnerability –Taint an argument pointer of functions such as printf, fprintf, sprintf and syslog. Stack buffer overflow (stack smashing) Stack buffer overflow (stack smashing) –Taint a return address. Heap corruption Heap corruption –Taint the free-chunk doubly-linked list of the heap. Glibc globbing vulnerabilities Glibc globbing vulnerabilities –User input resides in a location that is used as a pointer by the parent function of glob().

Stack Buffer Overflow Vulnerable code: char buf[100]; strcpy(buf,user_input); Return addr Frame pointer buf[99]…buf[1]buf[0] High Low Stack growth buf user_input Return address can be tainted.

Format String Vulnerability In vfprintf(), if (fmt points to “%n”) then **ap = (character count) Vulnerable code: recv(buf); printf(buf); /* should be printf(“%s”,buf) */ \xdd \xcc \xbb \xaa %d %d %d %n …%n%d%d%d0xaabbccdd fmt: format string pointer ap: argument pointer High Low Stack growth *ap is a tainted value. ap: argument pointer fmt: format string pointer

Heap Corruption Vulnerability Free chunk A Free chunk B fd=A bk=C Allocated buffer buf Free chunk C user input Vulnerable code: buf = malloc(1000); recv(sock,buf,1024); free(buf); In free(): B->fd->bk=B->bk; B->bk->fd=B->fd; When B->fd and B->bk are tainted, the effect of free() is to write a user specified value to a user specified address.

Semantic Definition of Pointer Taintedness

One-Slide Intro to Equational Logic Use term rewriting to establish proofs of theorems. Use term rewriting to establish proofs of theorems. Natural number addition expressed in the Maude system. Natural number addition expressed in the Maude system. 0 : Natural. s_ : Natural -> Natural. _+_ : Natural Natural -> Natural. vars N M : Natural Axiom: N + 0 = N. Axiom: N + s M = s (N + M). (s s s 0) + (s s 0) = s ((s s s 0) + (s 0)) = s( s((s s s 0) + 0)) = s(s((s s s 0)) = s s s s s 0 Intuitively, this is a proof of “3 + 2 = 5” in natural number algebra.

Semantics of a Memory Model A store represents a snapshot of the memory state at a point in the program execution. For each memory location, we can evaluate two properties: content and taintedness (true/false). Operations on memory locations: The fetch operation Ftch(S,A) gives the content of the memory address A in store S The location-taintedness operation LocT(S,A) gives the taintedness of the location A in store S Operations on expressions: The evaluation operation Eval(S,E) evaluates expression E in store S The expression-taintedness operation ExpT(S,E) computes the taintedness of expression E in store S.

Axioms of Eval and ExpT operations Eval(S, I) = I // I is an integer constant Eval(S, ^ E1) = Ftch(S, Eval(S,E1)) Eval(S, E1 + E2) = Eval(S, E1) + Eval(S, E2) Eval(S, E1 - E2) = Eval(S, E1) - Eval(S, E2) … ExpT (S, I) = false ExpT(S, ^ E1) = LocT(S,Eval(S,E1)) ExpT(S,E1 + E2) = ExpT(S,E1) or ExpT(S,E2) ExpT(S,E1 - E2) = ExpT(S,E1) or ExpT(S,E2) … E.g., is the expression (^100)–2 tainted in store S? ExpT(S, (^100)–2) = ExpT(S, (^100)) or ExpT(S, 2) = LocT(S,100) or false = LocT(S,100) Note: ^ is the dereference operator, ^100 gives the content in the location 100

Semantics of Language L Extend the semantics proposed by Goguen and Malcolm Extend the semantics proposed by Goguen and Malcolm The following operations (arithmetic/logic) are defined: The following operations (arithmetic/logic) are defined: – +, -, *, /, %, !, &&, ||, !=, ==, …… The following instructions are defined: The following instructions are defined: –mov [Exp1] <- Exp2 –branch (Condition) Label –call FuncName(Exp1,Exp2,…) Axioms defining mov instruction semantics Axioms defining mov instruction semantics –Specify the effects of applying mov instruction on a store –Allow taintedness to propagate from Exp2 to [Exp1]. Axioms defining the semantics of recv (similarly, scanf, recvfrom: user input functions) Axioms defining the semantics of recv (similarly, scanf, recvfrom: user input functions) – –Specify the memory locations tainted by the recv call.

Extracting Function Specifications by Theorem Prover C source code of a library function Code in language L Automatically translated to Language L Critical instruction – indirect writes For each mov [^ E1] <- E2, generate theorems: a) E1 should not be tainted b) The mov instruction should not taint any location outside the buffer pointed by E1 Theorem generation Theorem prover A set of sufficient conditions that imply the validity of the theorems. They are the security specifications of the analyzed function.

Example: strcpy() char * strcpy (char * dst, char * src) { char * res; 0: res =dst; while (*src!=0) { 1: *dst=*src; dst++; src++; } 2: *dst=0; return res; } 0: mov [res] <- ^ dst lbl(#while#6) branch (^ ^ src is 0) #ex#while#6 1: mov [^ dst] <- ^ ^ src mov [dst] <- (^ dst) + 1 mov [src] <- (^ src) + 1 branch true #while#6 lbl(#ex#while#6) 2: mov [^ dst] <- 0 mov [ret] <- ^ res Translate to Language L a) Suppose S1 is the store before Line L1, then LocT(S1,dst) = false b) If S0 is the store before Line L0, and S2 is the store after Line L1, then I LocT(S2,I) = LocT(S0, I) c) Suppose S3 is the store before Line L2, then LocT(S3,dst) = false Theorem generation Theorem prover

Specifications Suggested by Theorem Prover Specifications that are extracted by the theorem proving approach Specifications that are extracted by the theorem proving approach –srclen <= dstsize –The buffers src and dst do not overlap in such a way that the buffer dst covers the string terminator of the src string. –The buffers dst and src do not cover the function frame of strcpy. –Initially, dst is not tainted Documented in Linux man page Not documented Suppose when function strcpy() is called, the size of destination buffer (dst) is dstsize, the length of user input string (src) is srclen Suppose when function strcpy() is called, the size of destination buffer (dst) is dstsize, the length of user input string (src) is srclen

Other Examples A simplied version of printf() A simplied version of printf() –55 lines of C code –Four security specifications are extracted, including one indicating –Four security specifications are extracted, including one indicating format string vulnerability Function free() of a heap management system Function free() of a heap management system –36 lines of C code –Seven security specifications are extracted, including several specifications indicating vulnerabilities. –Seven security specifications are extracted, including several specifications indicating heap corruption vulnerabilities. Socket read functions of Apache HTTPD and NULL HTTPD Socket read functions of Apache HTTPD and NULL HTTPD –The Apache function is proved to be free of pointer taintedness. –Two (known) vulnerabilities are exposed in the theorem proving process of NULL HTTPD function.

Conclusions A common characteristic of many categories of widely exploited security vulnerabilities: pointer taintedness A common characteristic of many categories of widely exploited security vulnerabilities: pointer taintedness A memory model and a language can be formally defined using equational logic to allow reasoning of pointer taintedness. A memory model and a language can be formally defined using equational logic to allow reasoning of pointer taintedness. A theorem proving approach is developed to extract security specifications from library function code, based pointer taintedness analysis. A theorem proving approach is developed to extract security specifications from library function code, based pointer taintedness analysis.

Future Directions Provide higher degree of automation on the theorem generation and theorem proving process. Provide higher degree of automation on the theorem generation and theorem proving process. Apply the pointer taintedness analysis on a substantial number of commonly used library functions to extract their security specifications. Apply the pointer taintedness analysis on a substantial number of commonly used library functions to extract their security specifications. Compiler techniques for inserting “guarding code” to check unproved properties at runtime. Compiler techniques for inserting “guarding code” to check unproved properties at runtime. Architecture supports for pointer taintedness detection. A module working with RSE (Reliability and Security Engine). Architecture supports for pointer taintedness detection. A module working with RSE (Reliability and Security Engine).