Korset: Code-based Intrusion Detection for Linux



Similar documents
Korset: Automated, Zero False-Alarm Intrusion Detection for Linux

Transparent Monitoring of a Process Self in a Virtual Environment

Intrusion Detection via Static Analysis

Automating Mimicry Attacks Using Static Binary Analysis

How to Sandbox IIS Automatically without 0 False Positive and Negative

Building accurate intrusion detection systems. Diego Zamboni Global Security Analysis Lab IBM Zürich Research Laboratory

Visualizing Information Flow through C Programs

PERFORMANCE TOOLS DEVELOPMENTS

Software Vulnerabilities

Applying Clang Static Analyzer to Linux Kernel

For a 64-bit system. I - Presentation Of The Shellcode

Compiler-Assisted Binary Parsing

Kernel Intrusion Detection System

RISC-V Software Ecosystem. Andrew Waterman UC Berkeley

Next, the driver runs the C compiler (cc1), which translates main.i into an ASCII assembly language file main.s.

Sequential Performance Analysis with Callgrind and KCachegrind

Bug hunting. Vulnerability finding methods in Windows 32 environments compared. FX of Phenoelit

Between Mutual Trust and Mutual Distrust: Practical Fine-grained Privilege Separation in Multithreaded Applications

Attacking Obfuscated Code with IDA Pro. Chris Eagle

Idea: Measuring the Effect of Code Complexity on Static Analysis Results

Return-oriented programming without returns

EECS 354 Network Security. Introduction

I Control Your Code Attack Vectors Through the Eyes of Software-based Fault Isolation. Mathias Payer, ETH Zurich

umps software development

Soft-Timer Driven Transient Kernel Control Flow Attacks and Defense

Hacking Techniques & Intrusion Detection. Ali Al-Shemery arabnix [at] gmail

Operating Systems and Networks

How to make the computer understand? Lecture 15: Putting it all together. Example (Output assembly code) Example (input program) Anatomy of a Computer

Static Analysis of Virtualization- Obfuscated Binaries

Sequential Performance Analysis with Callgrind and KCachegrind

Scanner. tokens scanner parser IR. source code. errors

X86-64 Architecture Guide

Measuring the Effect of Code Complexity on Static Analysis Results

System Calls and Standard I/O

Introduction. What is an Operating System?

Data Structure Reverse Engineering

Operating Systems. Privileged Instructions

GENERIC and GIMPLE: A New Tree Representation for Entire Functions

The C Programming Language course syllabus associate level

Secure Software Programming and Vulnerability Analysis

Embedded Software Development

Libmonitor: A Tool for First-Party Monitoring

The Plan Today... System Calls and API's Basics of OS design Virtual Machines

IOActive Security Advisory

Compilers and Tools for Software Stack Optimisation

Lecture 27 C and Assembly

Introduction. Compiler Design CSE 504. Overview. Programming problems are easier to solve in high-level languages

Multi-Threading Performance on Commodity Multi-Core Processors

How to Automatically and Accurately Sandbox Microsoft IIS

MPLAB TM C30 Managed PSV Pointers. Beta support included with MPLAB C30 V3.00

Attacking Host Intrusion Prevention Systems. Eugene Tsyrklevich

THE VELOX STACK Patrick Marlier (UniNE)

Encryption Wrapper. on OSX

Off-by-One exploitation tutorial

Linux Distributed Security Module 1

N-Variant Systems. Slides extracted from talk by David Evans. (provenance in footer)

Operating System Structure

Software Testing & Analysis (F22ST3): Static Analysis Techniques 2. Andrew Ireland

Lecture 16: System-Level I/O

International Journal of Enterprise Computing and Business Systems ISSN (Online) :

Continuous Integration/Testing and why you should assume every change breaks your code

Hunting Vulnerabilities with Graph Databases

8.5. <summary> Cppcheck addons Using Cppcheck addons Where to find some Cppcheck addons

Linux Kernel Rootkit : Virtual Terminal Key Logger

Software Testing. Definition: Testing is a process of executing a program with data, with the sole intention of finding errors in the program.

Dynamic Spyware Analysis

Defense in Depth: Protecting Against Zero-Day Attacks

Using Code Coverage Tools in the Linux Kernel

System Calls Related to File Manipulation

Unix Security Technologies. Pete Markowsky <peterm[at] ccs.neu.edu>

AUTOMATED TEST GENERATION FOR SOFTWARE COMPONENTS

Lecture 7: Machine-Level Programming I: Basics Mohamed Zahran (aka Z)

Automated Repair of Binary and Assembly Programs for Cooperating Embedded Devices

CS 33. Multithreaded Programming V. CS33 Intro to Computer Systems XXXVII 1 Copyright 2015 Thomas W. Doeppner. All rights reserved.

6.828 Operating System Engineering: Fall Quiz II Solutions THIS IS AN OPEN BOOK, OPEN NOTES QUIZ.

MSc Computer Science Dissertation

Bypassing Browser Memory Protections in Windows Vista

This is DEEPerent: Tracking App behaviors with (Nothing changed) phone for Evasive android malware

Xen and XenServer Storage Performance

How To Trace

COS 318: Operating Systems

Language Processing Systems

Sandy. The Malicious Exploit Analysis. Static Analysis and Dynamic exploit analysis. Garage4Hackers

CS 377: Operating Systems. Outline. A review of what you ve learned, and how it applies to a real operating system. Lecture 25 - Linux Case Study

EXPLODE: a Lightweight, General System for Finding Serious Storage System Errors

Capability-Based Access Control

Return-oriented Programming: Exploitation without Code Injection

QEMU, a Fast and Portable Dynamic Translator

Dynamic Behavior Analysis Using Binary Instrumentation

Using the CoreSight ITM for debug and testing in RTX applications

Data Structure with C

Transcription:

Problem Korset Theory Implementation Evaluation Epilogue Korset: Code-based Intrusion Detection for Linux Ohad Ben-Cohen Avishai Wool Tel Aviv University

Problem Korset Theory Implementation Evaluation Epilogue Table of Contents why what how demo! evaluate

Problem Korset Theory Implementation Evaluation Epilogue Exploits HIDS Section 1: The Problem

Problem Korset Theory Implementation Evaluation Epilogue Exploits HIDS Exploit this void sayhi(char param) { char buf[96]; gets(buf); printf("hi %s, please don t hurt me!\n", buf); }

Problem Korset Theory Implementation Evaluation Epilogue Exploits HIDS Buffer Overflow

Problem Korset Theory Implementation Evaluation Epilogue Exploits HIDS Buffer Overflow

Problem Korset Theory Implementation Evaluation Epilogue Exploits HIDS Buffer Overflow

Problem Korset Theory Implementation Evaluation Epilogue Exploits HIDS Buffer Overflow

Problem Korset Theory Implementation Evaluation Epilogue Exploits HIDS Buffer Overflow

Problem Korset Theory Implementation Evaluation Epilogue Exploits HIDS Code Injection

Problem Korset Theory Implementation Evaluation Epilogue Exploits HIDS Defense

Problem Korset Theory Implementation Evaluation Epilogue Exploits HIDS Host-based Intrusion Detection Systems (HIDS s) To Identify Malicious Activities Pre-construct a model of normal behavior Monitor running processes Compare data to model Alarm when deviates

Problem Korset Theory Implementation Evaluation Epilogue Exploits HIDS Host-based Intrusion Detection Systems (HIDS s) To Identify Malicious Activities Pre-construct a model of normal behavior Monitor running processes Compare data to model Alarm when deviates Terms False Positives ( usability) False Negatives ( precision)

Problem Korset Theory Implementation Evaluation Epilogue Exploits HIDS Models of normal behavior

Problem Korset Theory Implementation Evaluation Epilogue Exploits HIDS Models of normal behavior 1. Machine Learning Automated Capable of detecting a wide range of attacks Statistical Have False Alarms

Problem Korset Theory Implementation Evaluation Epilogue Exploits HIDS Models of normal behavior 1. Machine Learning Automated Capable of detecting a wide range of attacks Statistical Have False Alarms False Alarms are inherent and inevitable if(time() < YEAR2009) read(...); else write(...);

Problem Korset Theory Implementation Evaluation Epilogue Exploits HIDS Models of normal behavior 1. Machine Learning Automated Capable of detecting a wide range of attacks Statistical Have False Alarms False Alarms are inherent and inevitable if(time() < YEAR2009) read(...); else write(...); 2. Program Policies Can be very accurate Eliminate False Alarms Tedious and demanding

Problem Korset Theory Implementation Evaluation Epilogue Exploits HIDS Models of normal behavior 1. Machine Learning Automated Capable of detecting a wide range of attacks Statistical Have False Alarms False Alarms are inherent and inevitable if(time() < YEAR2009) read(...); else write(...); 2. Program Policies Can be very accurate Eliminate False Alarms Tedious and demanding

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo Section 2: Korset

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo General Architecture

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo Model of Normal Behavior Control Flow Graph (CFG)

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo General Architecture

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo General Architecture

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo Stage #1: Model Preconstruction

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo Protect me

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo Assumption: System calls are the only way to inflict damage (Not entirely true...)

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo Protect me

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo Protect me

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo Protect me

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo Protect me

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo Protect me

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo Protect me

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo Protect me

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo Protect me

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo Protect me

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo Protect me

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo Model of Normal Behavior System call sequences Paths in the graph

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo Model of Normal Behavior System call sequences Paths in the graph No path in the graph Invalid system call sequence

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo Stage #2: Runtime Monitoring

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo Protecting

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo Protecting

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo Protecting

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo Protecting

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo Protecting

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo Protecting

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo Protecting

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo Protecting

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo Protecting

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo Protecting

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo Protecting

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo Protecting

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo In words Model of Normal Behavior Control Flow Graphs (CFG) Only System Calls Statically Preconstructed Once for every app Runtime Monitoring Monitor system calls emitted in run-time Simulate observed system calls on automata Always maintain a current node Terminate diverging processes

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo Code-based Intrusion Detection

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo Code-based Intrusion Detection First work by David Wagner and Drew Dean, 2001

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo Intrusion Detection via Static Analysis Pros Automated Provable zero false positives (assuming that code isn t self modifying)

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo Intrusion Detection via Static Analysis Pros Automated Provable zero false positives (assuming that code isn t self modifying) Cons Limited to code injection attacks High precision comes with a cost

Problem Korset Theory Implementation Evaluation Epilogue CIDS Demo Action!

Problem Korset Theory Implementation Evaluation Epilogue Context Insensitivity Non Determinism Section 3: Not so simple

Problem Korset Theory Implementation Evaluation Epilogue Context Insensitivity Non Determinism Functions

Problem Korset Theory Implementation Evaluation Epilogue Context Insensitivity Non Determinism Functions - Link CFGs

Problem Korset Theory Implementation Evaluation Epilogue Context Insensitivity Non Determinism And... Simplify

Problem Korset Theory Implementation Evaluation Epilogue Context Insensitivity Non Determinism Simplification Process Simple and Smooth u w u w v y z y z

Problem Korset Theory Implementation Evaluation Epilogue Context Insensitivity Non Determinism Challenge #1

Problem Korset Theory Implementation Evaluation Epilogue Context Insensitivity Non Determinism Functions Redux - Context Insensitivity Before linking

Problem Korset Theory Implementation Evaluation Epilogue Context Insensitivity Non Determinism Functions Redux - Context Insensitivity After linking

Problem Korset Theory Implementation Evaluation Epilogue Context Insensitivity Non Determinism Functions Redux - Context Insensitivity After linking... So?

Problem Korset Theory Implementation Evaluation Epilogue Context Insensitivity Non Determinism Functions Redux - Context Insensitivity After linking... So? Impossible execution paths are allowed E.g.: open-read-write

Problem Korset Theory Implementation Evaluation Epilogue Context Insensitivity Non Determinism Context Insensitivity A Function after linking... So? Impossible execution paths are allowed E.g.: open-read-write

Problem Korset Theory Implementation Evaluation Epilogue Context Insensitivity Non Determinism Hey before you link Not all functions emit/lead to system calls

Problem Korset Theory Implementation Evaluation Epilogue Context Insensitivity Non Determinism Graph Unlinking Do not link them

Problem Korset Theory Implementation Evaluation Epilogue Context Insensitivity Non Determinism Graph Unlinking Just ditch their calling nodes...

Problem Korset Theory Implementation Evaluation Epilogue Context Insensitivity Non Determinism Graph Inlining Inline CFGs of functions that issue system calls

Problem Korset Theory Implementation Evaluation Epilogue Context Insensitivity Non Determinism Graph Inlining Create Private Copies

Problem Korset Theory Implementation Evaluation Epilogue Context Insensitivity Non Determinism Graph Inlining Link Private Copies

Problem Korset Theory Implementation Evaluation Epilogue Context Insensitivity Non Determinism Graph Inlining Simplify Result

Problem Korset Theory Implementation Evaluation Epilogue Context Insensitivity Non Determinism Graph Inlining After Simplifying

Problem Korset Theory Implementation Evaluation Epilogue Context Insensitivity Non Determinism Graph Inlining Inlining Depth?

Problem Korset Theory Implementation Evaluation Epilogue Context Insensitivity Non Determinism Graph Inlining Inlining Depth? (currently - depth 1)

Problem Korset Theory Implementation Evaluation Epilogue Context Insensitivity Non Determinism Challenge #2

Problem Korset Theory Implementation Evaluation Epilogue Context Insensitivity Non Determinism Non Determinism Which write is it?

Problem Korset Theory Implementation Evaluation Epilogue Context Insensitivity Non Determinism %EIP?

Problem Korset Theory Implementation Evaluation Epilogue Context Insensitivity Non Determinism %EIP does not help

Problem Korset Theory Implementation Evaluation Epilogue Context Insensitivity Non Determinism Solution: Merge Nodes Solution: Merge nodes

Problem Korset Theory Implementation Evaluation Epilogue Context Insensitivity Non Determinism Non Determinism Solution: Merge nodes

Problem Korset Theory Implementation Evaluation Epilogue Context Insensitivity Non Determinism Merging cost Graph now allows impossible paths! b g o b g o r r r y g y g accepting: gry, grg, bry, org accepting: gry, grg, bry, org, brg, ory

Problem Korset Theory Implementation Evaluation Epilogue Context Insensitivity Non Determinism Minimizing Merging cost Don t merge, add

Problem Korset Theory Implementation Evaluation Epilogue Context Insensitivity Non Determinism the Deterministic Callgraph Automaton (DCA)

Problem Korset Theory Implementation Evaluation Epilogue Context Insensitivity Non Determinism the Deterministic Callgraph Automaton (DCA) Only system call nodes There are no ɛ-edges Need to check only direct descendants No control flow ambiguity No more than a single match Current state is always a single node Complexity Time: O( ) Space: O(1) ( - set of system calls)

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction Section 4: Implementation

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction General Architecture

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction General Architecture

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction General Architecture

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction Kernel guts The Monitoring Agent User Space example ELF executable System Calls Kernel Space Korset Monitoring Agent Kernel System Call Handler example.korset write read close read write close

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction Per process state sched.h struct task struct {... char korset graph; u32 korset node;... };

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction Monitoring Agent - via a new LSM hook entry.s ENTRY(system call)... GET THREAD INFO(%rcx) SAVE ARGS movq %rax,%rsi movq %rcx,%rdi call security system call cmpl $0, %eax jnz syscall noperm RESTORE ARGS... call sys call table(,%rax,8)...

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction Monitoring Agent - via a new LSM hook entry.s ENTRY(system call)... GET THREAD INFO(%rcx) SAVE ARGS movq %rax,%rsi movq %rcx,%rdi call security system call cmpl $0, %eax jnz syscall noperm RESTORE ARGS... call sys call table(,%rax,8)...

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction Monitoring Agent - via a new LSM hook entry.s ENTRY(system call)... GET THREAD INFO(%rcx) SAVE ARGS movq %rax,%rsi movq %rcx,%rdi call security system call cmpl $0, %eax jnz syscall noperm RESTORE ARGS... call sys call table(,%rax,8)...

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction Monitoring Agent - via a new LSM hook entry.s ENTRY(system call)... GET THREAD INFO(%rcx) SAVE ARGS movq %rax,%rsi movq %rcx,%rdi call security system call cmpl $0, %eax jnz syscall noperm RESTORE ARGS... call sys call table(,%rax,8)...

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction $ korset runtime monitor start

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction $ korset runtime monitor stop

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction Monitoring Agent Sum up Integrated into the Kernel s system call handler Uses and extends the Linux Security Module (LSM) interface Simulate automaton on observed system calls Terminate subverted applications Can dynamically update in-memory DCA Can dump updated DCA back to disk

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction Userland The Static Analyzer User Space example.c i = read(fd, buf, n); if (i == n) { write(fd, buf, n); } close(fd); gcc, ld,... Korset Static Analyzer System Calls example ELF executable example.korset read write close Kernel Space

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction $ korset static analyzer start

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction $ gcc -c foo.c -o foo.o

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction $ gcc -c bar.s -o bar.o

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction $ ar c foobar.a foo.o bar.o

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction $ gcc foo.o bar.o -o foobar

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction foo.o.kvcg

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction bar.o.kvcg

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction foobar.a.kvcg

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction foobar.korset

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction $ korset static analyzer stop

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction Static Analyzer Sum up Wraps the Linux build tools Transparently runs whenever user compiles, links or ar(chives) Creates DCAs for objects, libraries and executables

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction Constructing the Graphs

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction GCC saves the day

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction GCC saves the day

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction GCC saves the day

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction GCC saves the day

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction GCC saves the day

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction GCC saves the day

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction GCC saves the day GCC Plugins?

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction GCC saves the day $ gcc -dv -fdump-rtl-pass

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction Visualization of Compiler Graphs (VCG) Just parse and the CFG is yours graph: { title: "hack digit"... node: { title: "hack digit.0" }... edge: { sourcename: "hack digit.0" targetname: "hack digit.7" color: blue } node: { title: "hack digit.7" label: "note 7" }...

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction Creating CFGs for C files foo.0 note 6 insn 40 insn 41 insn 42 insn 8 jump_insn 9 code_label 11 insn 14 insn 16 insn 17 insn 18 call_insn 19 insn 21 code_label 22 insn 24 jump_insn 25 insn 45 note 47 jump_insn 46 END Use gcc s VCG output $ gcc -dv -fdump-rtl-pass -c foo.c void foo(void) { int i; for (i = 0; i < 10; i++) fwrite("hello!\n", 7, 1, stdout); } basic block 7

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction Simplification Process Simple and Smooth u w u w v y z y z

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction Creating CFGs for C files After simplifying VCG output void foo(void) { int i; for (i = 0; i < 10; i++) fwrite("hello!\n", 7, 1, stdout); } vcg-demo.o call fwrite foo.0 END

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction VCG Summary Neat.

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction VCG Summary Neat. Does not apply for Assembly files...

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction Creating CFGs for Assembly files Lots of Macros... #include <sysdep cancel.h> PSEUDO ( libc read, read, 3) ret PSEUDO END( libc read) libc hidden def ( libc read) weak alias ( libc read, read) libc hidden weak ( read) weak alias ( libc read, read) libc hidden weak (read)

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction Creating CFGs for Assembly files Disassemble corresponding object file: mov %rdx,0x18(%rsp) callq 35 < write nocancel+0x2c> R X86 64 PC32 libc enable asynccancel mov 0x8(%rsp),%rdi mov 0x10(%rsp),%rsi mov 0x18(%rsp),%rdx mov %rax,(%rsp) mov $0x1,%eax syscall

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction Creating CFGs for Assembly files Look for system and function calls: mov %rdx,0x18(%rsp) callq 35 < write nocancel+0x2c> R X86 64 PC32 libc enable asynccancel mov 0x8(%rsp),%rdi mov 0x10(%rsp),%rsi mov 0x18(%rsp),%rdx mov %rax,(%rsp) mov $0x1,%eax syscall

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction Creating CFGs for Assembly files Create a simplified matching graph Crude, ok for simple files Sound solution Requires a better flow analysis

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction Creating CFGs for stdin files something like this: $ gcc -x c++ -o output.o - redundant?

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction Creating CFGs for stdin files common glibc build: (echo #include <sysdep cancel.h> ; \ echo PSEUDO ( libc read, read, 3) ; \ echo ret ; \ echo PSEUDO END( libc read) ; \ echo libc hidden def ( libc read) ; \ echo weak alias ( libc read, read) ; \ echo libc hidden weak ( read) ; \ echo weak alias ( libc read, read) ; \ echo libc hidden weak (read) ; \ ) gcc c x assembler with cpp o read.o

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction Creating CFGs for stdin files Disassemble output file and build graph: (echo #include <sysdep cancel.h> ; \ echo PSEUDO ( libc read, read, 3) ; \ echo ret ; \ echo PSEUDO END( libc read) ; \ echo libc hidden def ( libc read) ; \ echo weak alias ( libc read, read) ; \ echo libc hidden weak ( read) ; \ echo weak alias ( libc read, read) ; \ echo libc hidden weak (read) ; \ ) gcc c x assembler with cpp o read.o

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction Creating CFGs for stdin files Result: a simplified matching graph

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction Is it enough? common glibc build: (echo #include <sysdep cancel.h> ; \ echo PSEUDO ( libc read, read, 3) ; \ echo ret ; \ echo PSEUDO END( libc read) ; \ echo libc hidden def ( libc read) ; \ echo weak alias ( libc read, read) ; \ echo libc hidden weak ( read) ; \ echo weak alias ( libc read, read) ; \ echo libc hidden weak (read) ; \ ) gcc c x assembler with cpp o read.o

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction Pay attention to symbol aliases common glibc build: (echo #include <sysdep cancel.h> ; \ echo PSEUDO ( libc read, read, 3) ; \ echo ret ; \ echo PSEUDO END( libc read) ; \ echo libc hidden def ( libc read) ; \ echo weak alias ( libc read, read) ; \ echo libc hidden weak ( read) ; \ echo weak alias ( libc read, read) ; \ echo libc hidden weak (read) ; \ ) gcc c x assembler with cpp o read.o

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction Collect symbol information objdump syms read.o: file format elf64 x86 64 SYMBOL TABLE: 00000000 g F.text 00000073 libc read 00000009 g F.text 00000014 read nocancel 00000000 w F.text 00000073 read 00000000 w F.text 00000073 read

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction Collect symbol information objdump syms read.o: file format elf64 x86 64 SYMBOL TABLE: 00000000 g F.text 00000073 libc read 00000009 g F.text 00000014 read nocancel 00000000 w F.text 00000073 read 00000000 w F.text 00000073 read

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction Add symbol aliases Before

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction Add symbol aliases After

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction Linking issues Not all functions are equal malloc.o: file format elf64 x86 64 SYMBOL TABLE: 000032e4 l F.text 0000009f malloc check 00001c46 l F.text 000000f2 free check 00000000 w UND 00000000 dso handle 0000395e g F.text 00000331 calloc 0000395e w F.text 00000331 calloc 00001b79 g F.text 000000cd cfree 00001b79 w F.text 000000cd cfree 00003e41 g F.text 000001cf malloc

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction Linking issues Not all functions are equal malloc.o: file format elf64 x86 64 SYMBOL TABLE: 000032e4 l F.text 0000009f malloc check 00001c46 l F.text 000000f2 free check 00000000 w UND 00000000 dso handle 0000395e g F.text 00000331 calloc 0000395e w F.text 00000331 calloc 00001b79 g F.text 000000cd cfree 00001b79 w F.text 000000cd cfree 00003e41 g F.text 000001cf malloc

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction Linking issues Not all functions are equal malloc.o: file format elf64 x86 64 SYMBOL TABLE: 000032e4 l F.text 0000009f malloc check 00001c46 l F.text 000000f2 free check 00000000 w UND 00000000 dso handle 0000395e g F.text 00000331 calloc 0000395e w F.text 00000331 calloc 00001b79 g F.text 000000cd cfree 00001b79 w F.text 000000cd cfree 00003e41 g F.text 000001cf malloc

Problem Korset Theory Implementation Evaluation Epilogue Overview Kernel Userland Construction Linking issues Not all functions are equal malloc.o: file format elf64 x86 64 SYMBOL TABLE: 000032e4 l F.text 0000009f malloc check 00001c46 l F.text 000000f2 free check 00000000 w UND 00000000 dso handle 0000395e g F.text 00000331 calloc 0000395e w F.text 00000331 calloc 00001b79 g F.text 000000cd cfree 00001b79 w F.text 000000cd cfree 00003e41 g F.text 000001cf malloc

Problem Korset Theory Implementation Evaluation Epilogue Runtime Precision Section 4: Evaluation

Problem Korset Theory Implementation Evaluation Epilogue Runtime Precision Micro-Benchmarks Overhead Percentage 120 110 100 90 80 70 60 50 40 30 20 10 0 Micro-Benchmarks write read write > /dev/null setuid BestCase BadCase WorstCase

Problem Korset Theory Implementation Evaluation Epilogue Runtime Precision Core-utils Benchmarks Overhead (%) Core-Utils Benchmark 1.3 1.2 1.1 1 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0 cp ls cat

Problem Korset Theory Implementation Evaluation Epilogue Runtime Precision Precision Analysis The Branching Factor

Problem Korset Theory Implementation Evaluation Epilogue Runtime Precision Graphs Analysis Glibc Graph Branching average branch degree 1000 100 10 1 э-less CFG basic DCA Final DCA 2 2 2 1 1 1 1 1 1 1 1 1 glibc DCA branching 108 108 108 108 108 108 118 33 33 33 33 33 33 33 36 36 18 9 6 6 4 0.1 open read write execve malloc gets fopen fread fwrite printf empty main

Problem Korset Theory Implementation Evaluation Epilogue Runtime Precision malloc() malloc() syscall 45 syscall 90 syscall 125 syscall 91

Problem Korset Theory Implementation Evaluation Epilogue Runtime Precision fwrite() syscall 90 syscall 197 syscall 54 syscall 45 syscall 108 syscall 140 syscall 4 syscall 125 fwrite() syscall 91

Problem Korset Theory Implementation Evaluation Epilogue Runtime Precision Empty main void main(void) { }

Problem Korset Theory Implementation Evaluation Epilogue Runtime Precision Empty main empty.c.49.stack

Problem Korset Theory Implementation Evaluation Epilogue Section 5: Sum up

Problem Korset Theory Implementation Evaluation Epilogue Sum up Summary Zero False Positives Intrusion Detection Negligible (/Bounded) Runtime Overhead Linux Kernel Prototype Automatic Analysis of the GNU C library Free Software (GPL ed) Status Proof of concept! Very limited, e.g.: only static linking

Problem Korset Theory Implementation Evaluation Epilogue http://www.korset.org

Problem Korset Theory Implementation Evaluation Epilogue THE END

Problem Korset Theory Implementation Evaluation Epilogue Thank You