Program semantics-aware Intrusion Detection. Prof. Tzi-cker Chiueh Computer Science Department Stony Brook University

Similar documents
How to Sandbox IIS Automatically without 0 False Positive and Negative

Abstract. 1 Introduction

PRESENTED BY: SANTOSH SANGUMANI & SHARAN NARANG

Application Specific Sandboxing for Win32/Intel Binaries

A Binary Rewriting Defense against Stack based Buffer Overflow Attacks

Accurate and Automated System Call Policy-Based Intrusion Prevention

Runtime Integrity Checking for Exploit Mitigation on Embedded Devices

CNIT 127: Exploit Development. Ch 1: Before you begin. Updated

Detecting Manipulated Remote Call Streams

Checking Array Bound Violation Using Segmentation Hardware

CS 550 Operating Systems Spring System Call

Buffer Overflow. Jo, Heeseung

Module: Return-oriented Programming. Professor Trent Jaeger. CSE543 - Introduction to Computer and Network Security

BUFFER OVERFLOW. Jo, Heeseung

Module: Return-oriented Programming. Professor Trent Jaeger. CSE543 - Introduction to Computer and Network Security

ISA564 SECURITY LAB. Code Injection Attacks

Return-orientated Programming

Software Security II: Memory Errors - Attacks & Defenses

CS161 Midterm 1 Review

Buffer Overflow. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Real-World Buffer Overflow Protection in User & Kernel Space

Sandboxing Untrusted Code: Software-Based Fault Isolation (SFI)

CSE 127 Computer Security

Buffer Overflows Defending against arbitrary code insertion and execution

G Programming Languages - Fall 2012

W4118: PC Hardware and x86. Junfeng Yang

Computer Security. 04r. Pre-exam 1 Concept Review. Paul Krzyzanowski. Rutgers University. Spring 2018

COMP3441 Lecture 7: Software Vulnerabilities

Practical Malware Analysis

Protecting Against Unexpected System Calls

Control Abstraction. Hwansoo Han

ECE 471 Embedded Systems Lecture 22

Introduction to Operating Systems Prof. Chester Rebeiro Department of Computer Science and Engineering Indian Institute of Technology, Madras

Fundamentals of Linux Platform Security

Language-Based Protection

The Geometry of Innocent Flesh on the Bone

CMPSC 497 Buffer Overflow Vulnerabilities

Binding and Storage. COMP 524: Programming Language Concepts Björn B. Brandenburg. The University of North Carolina at Chapel Hill

0x1A Great Papers in Computer Security

Buffer Overflow. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

CPSC 213. Introduction to Computer Systems. Procedures and the Stack. Unit 1e

Outline. Classic races: files in /tmp. Race conditions. TOCTTOU example. TOCTTOU gaps. Vulnerabilities in OS interaction

Porting Linux to x86-64

Language Security. Lecture 40

Buffer Overflow. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

2 Sadeghi, Davi TU Darmstadt 2012 Secure, Trusted, and Trustworthy Computing Chapter 6: Runtime Attacks

Department of Electrical Engineering and Computer Science MASSACHUSETTS INSTITUTE OF TECHNOLOGY Fall Quiz I

Control-flow Enforcement Technology H.J. Lu. Intel November, 2018

Advanced Systems Security: Ordinary Operating Systems

Inject malicious code Call any library functions Modify the original code

by Marina Cholakyan, Hyduke Noshadi, Sepehr Sahba and Young Cha

0x1A Great Papers in Computer Security

MIPS Functions and Instruction Formats

Secure Software Programming and Vulnerability Analysis

CSE 127 Computer Security

The Kernel Abstraction. Chapter 2 OSPP Part I

Sample Midterm (Spring 2010)

Betriebssysteme und Sicherheit Sicherheit. Buffer Overflows

Beyond Stack Smashing: Recent Advances in Exploiting. Jonathan Pincus(MSR) and Brandon Baker (MS)

Lecture Notes for 04/04/06: UNTRUSTED CODE Fatima Zarinni.

0x1A Great Papers in Computer Security

Secure Software Development: Theory and Practice

HDFI: Hardware-Assisted Data-flow Isolation

Buffer Overflows: Attacks and Defenses for the Vulnerability of the Decade Review

Memory Safety (cont d) Software Security

CSE 127 Computer Security

Chapter 9 :: Subroutines and Control Abstraction

18-600: Recitation #4 Exploits

STING: Finding Name Resolution Vulnerabilities in Programs

CSE 361S Intro to Systems Software Lab Assignment #4

Efficient Software Based Fault Isolation. Software Extensibility

Buffer Overflow Defenses

CPSC 213. Introduction to Computer Systems. Procedures and the Stack. Unit 1e

Practical and Efficient Exploit Mitigation for Embedded Devices

Software Vulnerabilities August 31, 2011 / CS261 Computer Security

Cyber Moving Targets. Yashar Dehkan Asl

W4118: interrupt and system call. Junfeng Yang

G Programming Languages Spring 2010 Lecture 4. Robert Grimm, New York University

THEORY OF COMPILATION

Remix: On-demand Live Randomization

Lecture Embedded System Security A. R. Darmstadt, Runtime Attacks

CS 740, Fall 2000 Homework Assignment 1

sottotitolo System Security Introduction Milano, XX mese 20XX A.A. 2016/17 Federico Reghenzani

Embedded TaintTracker: Lightweight Tracking of Taint Data against Buffer Overflow Attacks

Other array problems. Integer overflow. Outline. Integer overflow example. Signed and unsigned

Runtime Defenses against Memory Corruption

Return-Oriented Rootkits

Midterm Exam #2 April 20, 2016 CS162 Operating Systems

Linux Memory Layout. Lecture 6B Machine-Level Programming V: Miscellaneous Topics. Linux Memory Allocation. Text & Stack Example. Topics.

CNIT 127: Exploit Development. Ch 3: Shellcode. Updated

String Oriented Programming Exploring Format String Attacks. Mathias Payer

Confinement (Running Untrusted Programs)

Control Flow Integrity

Compilation /15a Lecture 7. Activation Records Noam Rinetzky

Applications. Cloud. See voting example (DC Internet voting pilot) Select * from userinfo WHERE id = %%% (variable)

Machine Programming 3: Procedures

SoK: Eternal War in Memory

Function Call Convention

INFLUENTIAL OPERATING SYSTEM RESEARCH: SECURITY MECHANISMS AND HOW TO USE THEM CARSTEN WEINHOLD

Profilers and Debuggers. Introductory Material. One-Slide Summary

Transcription:

Program semantics-aware Intrusion Detection Prof. Tzi-cker Chiueh Computer Science Department Stony Brook University chiueh@cs.sunysb.edu

Introduction Computer attacks that exploit software flaws Buffer overflow: heap/stack/format string Most common; building blocks for worm attacks Syntax loopholes: SQL injection, Directory traversal Race conditions: mostly local attacks Other attacks Social engineering Password cracking Denial of service

Control- Hijacking Attacks Network applications whose control gets hijacked because of software bugs: Most worms, including MSBlast, exploit such vulnerabilities Three-step recipe: Insert malicious code into the attacked application Sneaking weapons into a plane Trick the attacked application to transfer control to the inserted code Taking over the victim plane Execute damaging system calls as the owner of the attacked application process Hit a target with the plane

Stack Overflow Attack main() { input(); } input() { int i = 0;; int userid[5]; while ((scanf( %d, &(userid[i])))!= EOF) i ++; } STACK LAYOUT 128 Return address of input() 100 FP 124 Previous FP 120 Local variable i 116 userid[4] 112 userid[3] 108 userid[2] INT 80 104 userid[1] SP 100 userid[0]

Palladium (since 1999 ) Array bound checking: Preventing code insertion through buffer overflow Integrity check for control-sensitive data structure: Preventing unauthorized control transfer through over-writing return address, function pointer, and GOT System call policy check: Preventing attackers from issuing damaging system calls Repairable file service:quickly putting a compromised system back to normal order after detecting an intrusion

Array Bound Checking Prevent unauthorized modification of sensitive data structures (e.g., return address or bank account) through buffer overflowing The cleanest solution Check each pointer reference with respect to the limit of its associated object Figure out which is the associated object (shadow variable approach) Perform the limit check (major overhead) Current software-based array bound checking methods: 3-30 times slowdown

Segmentation Hardware X86 architecture s virtual memory hardware supports both segmentation and paging Virtual Address = Segment Selector + Offset segmentation base + offset <= limit Linear Address paging Physical Address

Checking Array bound using Segmentation Hardware (CASH) Exploiting segment limit check hardware to perform array bound checking for free Each array or buffer is treated as a separate segment and referenced accordingly offset = &(B[M]) B_Segment_Base; for (i = M; i < N; I++) { GS = B_Segment_Selector; B[i] = 5; for (i = M; i < N; i++) { } GS:offset = 5; offset += 4; }

Performance Overhead SVDPACK Volume Rendering 2D FFT Gaussian Elimination Matrix Multiply Edge Detection CASH 1.82% 3.26% 3.95% 1.61% 1.47% 2.23% BCC 120.00% 126.38% 72.19% 92.40% 143.77% 83.77%

Return Address Defense (RAD) To prevent the return address from being modified, keep a redundant copy of the return address when calling a procedure, and make sure that it has not been modified at procedure return Include the bookkeeping and checking code in the function prologue and epilogue, respectively

Binary RAD Prototype Aims to protect Windows Portable Executable (PE) binaries Implementing a fully operational disassembler for X86 architecture Inserting RAD code at function prolog and epilog without disturbing existing code Transparent initialization of RAR

Performance Overhead Program BIND DHCP Server PowerPoint Outlook Express Overhead 1.05% 1.23% 3.44% 1.29%

Repairable File Service (RFS) There is no such thing as unbreakable computer systems, e.g., insider job and social engineering A significant percentage of financial loss of computer security breaches is productivity loss due to unavailability of information and personnel Instead of aiming at 100% penetration proof, shift the battleground to fast recovery from intrusion: reliability vs. availability MTTF/(MTTF+MTTR) Key problem: Accurately identify the damaged file blocks and restore them quickly

RFS Architecture Transparent to protected network file server NFS Client NFS Client NFS Client Mirroring NFS Server RFS Protected NFS Server

Fundamental Issues Keeping the before image of all updates so that every update is undoable: transparent file server update logging Tracking inter-process dependencies for selective undo Contamination analysis based on inter-process dependencies and ID of the first detected intruder process, P All updates made by P and its children All updates by processes that read in contaminated blocks after P s birth time

RFS Prototype Implemented on Red Hat 7.1 Works for both NFSv2 and NFSv3 A client-side system call logger whose resulting log is tamper proof A wire-speed NFS request/response interceptor that deals with network/protocol errors A repair engine that performs contamination analysis and selective undo Undo operations are themselves undoable

Performance Results Client-side logging overhead is 5.4% Additional latency introduced by interceptor is between 0.2 to 1.5 msec When the write ratio is below 30%, there is no throughput difference between NFS and NFS/RFS Logging storage requirement: 709MBytes/day for a 250-user NFS server in a CS department a 100- Gbyte disk can support a detection window of 8 weeks

Program semantics-aware Intrusion Detection (PAID) As a last line of defense, prevent intruders from causing damages even when they successfully take control of a target victim application Key observation: Most damages can only be done through system calls, including denial of service attacks Idea: prohibit hijacked applications from making arbitrary system calls

System Call Policy/Model Manual specification: error-prone, labor intensive, non-scalable Machine learning: error-prone, training efforts required Our approach: Use compiler to extract the sites and ordering of system calls from the source code of any given application automatically Only host-based intrusion detection systems that guarantees zero false positives and very-close-to-zero false negatives System call policy is extracted automatically and accurately

PAID Architecture Compile Time Extraction Application Run Time Checking Application Compiler System Call Policy System Call Pattern Legitimacy Check User Kernel

The Mimicry Attack Hijack the control of a victim application by overwriting some control-sensitive data structure, such as return address Issue a legitimate sequence of system calls after the hijack point to fool the IDS until reaching a desired system call, e.g., exec() None of existing commercial or research host-based IDS can handle mimicry attacks

Mimicry Attack Details To mount a mimicry attack, attacker needs to Issue each intermediate system call without being detected Nearly all syscalls can be turned into no-ops For example (void) getpid() or open(null,0) Grab the control back during the emulation process Set up the stack so that the injected code can take control after each system call invocation

Countermeasures Checking system call argument values whenever possible Checking the return address chain on the stack to verify the call chain Minimize ambiguities in the system call model If (a>1) { open(..)} else {open(..); write(..)} Multiple calls to a function that contains a system call

Example main() { foo(); foo(); exit(); } Entry(main) call(foo) return(foo) Entry(foo) sys_foo sys_foo foo() { for(.){ sys_foo(); sys_foo(); } } call(foo) return(foo) Exit() Exit(main) Exit(foo)

System Call Policy Extraction From a given program, build a system call graph from its function call graph (FCG) and per-function reduced control flow graph (RCFG) For each system call, extract its memory location, and derive the following system call set Each system call site is in-lined with the actual code sequence of entering the kernel (e.g., INT 80), and thus can be uniquely identified

Dynamic Branch Targets Not all branch targets are known at compile time: function pointers and indirect jumps Insert a notify system call to tell the kernel the target address of these indirect branch instructions The kernel moves the current cursor of the system call graph to the designated target accordingly Notification system call is itself protected

Asynchronous Control Transfer Setjmp/Longjmp At the time of setjmp(), store the current cursor At the time of longjmp(), restore the current cursor Signal handler When signal is delivered, store the current cursor After signal handler is done, restore the current cursor Dynamically linked library Load the library s system call graph at run time

From NFA to DFA Use graph in-lining to disambiguate the return address for a function with multiple call sites Every recursive call chain is in-lined and turned into self-recursive call Use system call stub in-lining to disambiguate two system calls that are identical and that are at two arms of a conditional branch Does not completely solve the problem: F1 system_call() Difficult to implement because some glibc functions are written in assembly Adding extra notify() for further disambiguation

PAID Example main() { foo(); foo(); exit(); } foo() { for(.){ sys_foo(); sys_foo(); } } Entry(main) sys_foo_call_site_1 sys_foo_call_site_2 sys_foo_call_site_1 sys_foo_call_site_2 exit_call_site_1 Exit(main) foo() { for(.){ } } { int ret; } asm ( movl sys_foo_n, %eax\n { int ret; }.); int $0x80\n sys_foo_call_site_1:\n movl %eax, ret\n asm ( movl sys_foo_n, %eax\n.); int $0x80\n sys_foo_call_site_2:\n movl %eax, ret\n

PAID Checks Ordering Site Insertion of random notify() at load time Different for different instance Stack return address check Ensure they are in the text area Checking performed in the kernel In most cases, only two comparisons are needed

Ordering Check Only main Call chain Call sequence setreuid Buffer Overflow read open stat setreuid read open stat write write Compromised

Ordering and Site Check main Call chain Call sequence int 0x80 Buffer Overflow Compromised setreuid read open stat write

Ordering, Site and Stack Check (1) main Call chain Call sequence int 0x80 Buffer Overflow setreuid read open stat write

Ordering, Site and Stack Check (2) main Call chain Call sequence int 0x80 Buffer Overflow Stack check passes exec

Random Insertion of Notify Calls main Call chain Call sequence int 0x80 Buffer Overflow notify Attack failed notify exec

Alternative Approach Check the return address chain on the stack every time a system call is made Every system call instance can be uniquely identified by a function call chain and the return address for the INT 80 instruction Main F1 F2 F4 system_call_1 vs. Main F3 F5 F4 system_call_1 Need to check the legitimacy of transitioning from one system call to another No graph or function in-lining is necessary

System Call Argument Check Start from each file name system call argument, e.g., open() and exec(), and compute a backward slice, Perform symbolic constant propagation through the slice, and the result could be A constant: static constant A program segment that depends on initializationtime inputs only: dynamic constant A program segment that depends on run-time inputs: dynamic variables

Dynamic Variables Derive partial constraints, e.g., prefix or suffix, /home/httpd/html Enforce the system call argument computation path by inserting null system calls between where dynamic inputs are entered and where the corresponding system call arguments are used

Vulnerabilities Call chain Call sequence int 0x80 notify Buffer Overflow Desired system call follows Immediately exec Buffer Overflow Argument replacement notify exec

Prototype Implementation GCC 3.1 and Gnu ld 2.11.94, Red Hat Linux 7.2 Compiles GLIBC successfully Compiles several production-mode network server applications successfully, including Apache-1.3.20, Qpopper-4.0, Sendmail-8.11.3, Wuftpd-2.6.0, etc.

Throughput Overhead PAID PAID/stack PAID/random PAID/stack random Apache Qpopper Sendmail Wuftpd 4.89% 5.39% 6.48% 7.09% 5.38% 5.52% 6.03% 6.22% 6.81% 7.73% 9.36% 10.44% 2.23% 2.69% 3.60% 4.38%

Conclusion Paid is the most efficient, comprehensive and accurate hostbased intrusion prevention (HIPS) system on Linux Automatically generates per-application system call policy System call policy is in the form of deterministic finite automata to eliminate ambiguities Extensive system call argument checks Can handle function pointers and asynchronous control transfers Guarantee no false positives Very small false negatives Can block most mimicry attacks

Future Work Support for threads Integrate it with SELinux Derive a binary PAID version for Windows platform Further reduce the latency/throughput overhead Reduce the percentage of dynamic variable category of system call arguments

For more information Project Page: http://www.ecsl.cs.sunysb.edu/paid Thank You!