CFIMon: Detecting Violation of Control Flow Integrity using Performance Counters Yubin Xia, Yutao Liu, Haibo Chen, Binyu Zang in DSN 2012 A.C. Chen 2012/09/18.

Slides:



Advertisements
Similar presentations
ROP is Still Dangerous: Breaking Modern Defenses Nicholas Carlini et. al University of California, Berkeley USENIX Security 2014 Presenter: Yue Li Part.
Advertisements

Defenses. Preventing hijacking attacks 1. Fix bugs: – Audit software Automated tools: Coverity, Prefast/Prefix. – Rewrite software in a type safe languange.
1 InfoShield: A Security Architecture for Protecting Information Usage in Memory Georgia Tech Weidong Shi – Georgia Tech Josh Fryman – Intel Corporation.
Integrity & Malware Dan Fleck CS469 Security Engineering Some of the slides are modified with permission from Quan Jia. Coming up: Integrity – Who Cares?
Exceptional Control Flow Processes Today. Control Flow Processors do only one thing: From startup to shutdown, a CPU simply reads and executes (interprets)
Ensuring Operating System Kernel Integrity with OSck By Owen S. Hofmann Alan M. Dunn Sangman Kim Indrajit Roy Emmett Witchel Kent State University College.
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.
Computer Organization and Architecture
CMSC 414 Computer and Network Security Lecture 22 Jonathan Katz.
LIFT: A Low-Overhead Practical Information Flow Tracking System for Detecting Security Attacks - F. Qin, C. Wang, Z. Li, H. Kim, Y. Zhou, Y. Wu (UIUC,
Breno de MedeirosFlorida State University Fall 2005 Buffer overflow and stack smashing attacks Principles of application software security.
TaintCheck and LockSet LBA Reading Group Presentation by Shimin Chen.
OS Fall ’ 02 Introduction Operating Systems Fall 2002.
OS Spring’03 Introduction Operating Systems Spring 2003.
Advanced OS Chapter 3p2 Sections 3.4 / 3.5. Interrupts These enable software to respond to signals from hardware. The set of instructions to be executed.
1 Last Class: Introduction Operating system = interface between user & architecture Importance of OS OS history: Change is only constant User-level Applications.
@ NCSU Zhi NCSU Xuxian Microsoft Research Weidong Microsoft NCSU Peng NCSU ACM CCS’09.
1 RISE: Randomization Techniques for Software Security Dawn Song CMU Joint work with Monica Chew (UC Berkeley)
1 RAKSHA: A FLEXIBLE ARCHITECTURE FOR SOFTWARE SECURITY Computer Systems Laboratory Stanford University Hari Kannan, Michael Dalton, Christos Kozyrakis.
Lecture 16 Buffer Overflow
Efficient Instruction Set Randomization Using Software Dynamic Translation Michael Crane Wei Hu.
What are Exception and Interrupts? MIPS terminology Exception: any unexpected change in the internal control flow – Invoking an operating system service.
CS252: Systems Programming Ninghui Li Final Exam Review.
1 CS503: Operating Systems Part 1: OS Interface Dongyan Xu Department of Computer Science Purdue University.
Vulnerability-Specific Execution Filtering (VSEF) for Exploit Prevention on Commodity Software Authors: James Newsome, James Newsome, David Brumley, David.
System Calls 1.
Shuo Chen, Jun Xu, Emre C. Sezer, Prachi Gauriar, and Ravishankar K. Iyer Brett Hodges April 8, 2010.
Address Space Layout Permutation
Operating System Support for Virtual Machines Samuel T. King, George W. Dunlap,Peter M.Chen Presented By, Rajesh 1 References [1] Virtual Machines: Supporting.
KGuard: Lightweight Kernel Protection against Return-to-User Attacks Authors: Vasileios P. Kemerlis Georgios Portokalidis Angelos D. Keromytis Presenter:
Operating Systems ECE344 Ashvin Goel ECE University of Toronto OS-Related Hardware.
1 UCR Code Reuse Attacks (II) Slide credits: some slides and figures adapted from David Brumley, AC Chen, and others.
Computer Science Detecting Memory Access Errors via Illegal Write Monitoring Ongoing Research by Emre Can Sezer.
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”.
Branch Regulation: Low-Overhead Protection from Code Reuse Attacks.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
CNIT 127: Exploit Development Ch 4: Introduction to Format String Bugs.
MICHALIS POLYCHRONAKIS(COLUMBIA UNIVERSITY,USA), KOSTAS G. ANAGNOSTAKIS(NIOMETRICS, SINGAPORE), EVANGELOS P. MARKATOS(FORTH-ICS, GREECE) ACSAC,2010 Comprehensive.
Title of Selected Paper: IMPRES: Integrated Monitoring for Processor Reliability and Security Authors: Roshan G. Ragel and Sri Parameswaran Presented by:
 Virtual machine systems: simulators for multiple copies of a machine on itself.  Virtual machine (VM): the simulated machine.  Virtual machine monitor.
Exploitation possibilities of memory related vulnerabilities
Buffer Overflow Attack Proofing of Code Binary Gopal Gupta, Parag Doshi, R. Reghuramalingam, Doug Harris The University of Texas at Dallas.
CISC Machine Learning for Solving Systems Problems Presented by: Suman Chander B Dept of Computer & Information Sciences University of Delaware Automatic.
Operating Systems Security
Operating Systems CSE 411 CPU Management Sept Lecture 10 Instructor: Bhuvan Urgaonkar.
Introduction to Information Security ROP – Recitation 5.
Processes and Virtual Memory
Efficient Software Based Fault Isolation Author: Robert Wahobe,Steven Lucco,Thomas E Anderson, Susan L Graham Presenter: Maitree kanungo Date:02/17/2010.
Processor Structure and Function Chapter8:. CPU Structure  CPU must:  Fetch instructions –Read instruction from memory  Interpret instructions –Instruction.
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 豊島隆志.
Lecture 5 Rootkits Hoglund/Butler (Chapters 1-3).
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.
Interrupts and Exception Handling. Execution We are quite aware of the Fetch, Execute process of the control unit of the CPU –Fetch and instruction as.
Memory Protection through Dynamic Access Control Kun Zhang, Tao Zhang and Santosh Pande College of Computing Georgia Institute of Technology.
Exceptional Control Flow
EnGarde: Mutually Trusted Inspection of SGX Enclaves
Exceptional Control Flow
Effective Data-Race Detection for the Kernel
Secure Software Development: Theory and Practice
Exceptional Control Flow: System Calls, Page Faults etc.
Continuous, Low Overhead, Run-Time Validation of Program Executions
Chapter 11 Processor Structure and function
Presentation transcript:

CFIMon: Detecting Violation of Control Flow Integrity using Performance Counters Yubin Xia, Yutao Liu, Haibo Chen, Binyu Zang in DSN 2012 A.C. Chen ADL

Outline Introduction Performance Monitoring Units (PMU) CFI Enforcement by CFIMon Implementation Experiment Performance Conclusion A.C. Chen ADL 2

INTRODUCTION 3

Motivation Many classes of security exploits usually involve introducing abnormal control flow transfers – Code-injection attack – Code-Reuse Attacks return-into-libc (RILC) return-oriented programming (ROP) jump-oriented programming (JOP) Countermeasures – non-executable stacks – Stack-Guard – safe C library – heuristic means – …. – usually designed for a specific problem A.C. Chen ADL 4

Some General Solutions…? Control flow integrity (CFI) [Abadi et al.] [Abadi et al.] – statically rewrites a program + dynamic inlined guards Suffer from coverage problems Control flow locking [Tyler Bletsch et al.] [Tyler Bletsch et al.] – recompiles a program difficult to be applied to legacy applications Architectural support to validate or enforce control flow integrity [Shi et al.] [Shi et al.] – need to re-design existing processors A.C. Chen ADL 5

In this Paper… Detect a set of attacks that cause abnormal control flow transfers --- CFIMon – without changes to existing hardware, source code or binaries – leverage the hardware support for performance counters to monitor the control flow integrity (CFI) A.C. Chen ADL 6

PERFORMANCE MONITORING UNITS (PMU) Hardware support for performance monitoring A.C. Chen ADL 7

Performance Monitoring Units (PMU) perfmon A.C. Chen ADL 8

2 Working Modes of PMU Interrupt-based mode (basic mode) – lacks precise instruction pointer information the reported IP may be up to tens of instructions away from the actual IP (instruction pointer) causing the event Precision mode – improve the precision and flexibility of PMUs – e.g. techniques used in Intel CPU: PEBS: Precise Event-Based Sampling BTS: Branch Trace Store LBR: Last Branch Record Event Filtering Conditional Counting A.C. Chen ADL 9

Precision Mode of Intel CPU ---Branch Trace Store (BTS) Mechanism Record all control transfer precisely into a predefined buffer – jump, call, return, interrupt and exception – also record the addresses of branch source and target Let a monitor get the trace in a batch – an interrupt will be delivered when the buffer is nearly full Obtain all the branch information of a running application, help users locate the vulnerabilities A.C. Chen ADL 10

CFI ENFORCEMENT BY CFIMON Offline Analysis and Online Detection A.C. Chen ADL 11

Main Idea The CFI of an application can be maintained if we can – get a legal set of branch target addresses for every branch – check whether the target address of every branch is within the corresponding legal set at runtime A.C. Chen ADL 12

Branch Classification in X86 ISA ---Direct Branch & Its Target Address Direct Branch – Direct jump jnz c2ef0 – Direct call callq 34df0 Since the code is read-only and cannot be modified during runtime, both the direct jump and direct call are considered safe one A.C. Chen ADL 13 (safe branch) √

Branch Classification in X86 ISA ---Indirect Branch & Its Target Address Indirect Branch – Indirect jump jmpq *%rdx not possible to gain the whole target address set just by static analysis – Indirect call callq *%rax its target address could be obtained by statically scanning the binary code of the application and the libraries it uses – Return retq its target address could also be obtained by scanning the binary code. A.C. Chen ADL 14 (unsafe branch) √ A call can only transfer control to the start of a function. In general, the target address of a return has to be the one next to a call Dynamic Training

CFIMon: 2 Phases Offline phase – build a legal set of target addresses for each branch instruction Online phase – diagnose possible attacks with legal sets following a number of rules determine the status of the branch as legal, illegal or suspicious A.C. Chen ADL 15

Offline Analysis --- obtain legal set: ret_se t, call_set Scans the binary of application and dynamic libraries to get – ret_set contains all addresses of the instructions next to each call special cases special cases special cases special cases – call_set contains all addresses of the first instruction of each function A.C. Chen ADL 16. add(3,4); printf(“TEST!”);. ret_set int add (int a, int b){ printf(“1 st inst.”);. } call_set

Offline Analysis --- obtain legal set: train_set Use training to collect branches trace ( recorded by BTS ) for each indirect jump, get the legal set of – train_set – there could be corner cases which are not covered considered as suspicious during online checking A.C. Chen ADL 17

Online Detection A.C. Chen ADL 18 special case? is direct branch? legal illegal suspicious ret_set call_set train_set yes no yes no yes no yes no is indirect call is return is indirect jump Consider the state of a branch depending on switch into different cases based on slide-window mechanism

Slide-Window Mechanism ---For Suspicious Branches The diagnose module makes a flexible decision depending on the pattern of the branches – maintain a window of the states of recent n branches – apply a rule of tolerating at most m suspicious branches in the recent n ones i.e., at most m suspicious branches are accepted in recent n branches A.C. Chen ADL 19

IMPLEMENTATION A.C. Chen ADL 20

Implementation Debian-6 with kernel version – 2GB 1066MHz main memory – Intel Core i5 processor with 4 cores Based on perf_events to implement the CFIMon – a unified kernel extension in Linux for user-level performance monitoring A.C. Chen ADL 21

CFIMon---Mainly 2 Components A kernel extension – operate the performance samples – monitor signals – provide the interfaces to user-level tool A user-level tool with 2 modules – diagnose module check the control flow integrity receives information from the OS to solve special cases such as signal handling – control module initialize the environment launch and synchronize with an application A.C. Chen ADL 22

A kernel extension Architecture A.C. Chen ADL 23 A user-level tool with 2 modules

CFIMon---Monitoring The user-level tool is the parent process of the application process, executed as a monitoring process – use ptrace to synchronize with the application process – run for security check at the critical point e.g. when the child process makes the exec system call A.C. Chen ADL 24

EVALUATION A.C. Chen ADL 25 Evaluate the detection ability of CFIMon

Experimental Samples Use several real-world applications as well as 2 demo programs to detect – Code-Injection Attacks – Return-to-libc Attacks – Return-oriented Programming (Samba, GPSd, and Wu- ftpd excluded) A.C. Chen ADL 26

Evaluation for Code-Injection Attacks Use the metasploit framework to generate nop- sled before the injected code – attack each application with injected code 5 times to test the false negatives – CFIMon detects all these attacks as expected report a security alarm For example, code-injection attack of Samba – heap overflow function lsa_trans_name and overwrite the function pointer destructor – CFIMon detected such attack since the branches have never appeared in the train_set A.C. Chen ADL 27 post-attack diagnosis

Evaluation for Return-to-libc Attacks CFIMon successfully detects all these attacks without experiencing false negatives Return-to-libc Attack of GPSd (ver. 2.7) – format string vulnerability in function gpsd_report – allows remote attackers to execute arbitrary libc function (e.g. system ) via certain GPS requests (via tcp port 2947 ) – CFIMon marks it and the following branches as suspicious since the branches have never appeared in the train_set – an alarm is triggered since the number of suspicious branches quickly exceeds the threshold A.C. Chen ADL 28 addr. of system addr. of …. suspicious branches window size = 20 tolerant at most 3 suspicious branches

Evaluation for Return-oriented Programming Attacks Similar to other evaluation, CFIMon successfully detects all these attacks without experiencing false negatives Return-oriented Programming Attack of Squid (ver. 2.5-STABLE1) – stack overflow bug in its helper module, ntlm, when authentication – smash the stack by supply arbitrary password of at most 300 bytes in function ntlm_check_auth – violates the rules of CFIMon which enforces that the target address of a return instruction must be the one next to a call A.C. Chen ADL 29

PERFORMANCE A.C. Chen ADL 30 Overhead evaluation

Performance Evaluation Quantitatively evaluate the performance of CFIMon using several real-world applications – Apache – Exim – Memcached – Wu-ftpd A.C. Chen ADL 31

Overhead Results Memory overhead is negligible – since the size of the tables ( ret_set, call_set and train_set) is quite small Performance overhead A.C. Chen ADL 32 Average overhead of CFIMon is only 6.1% Average overhead of pure BTS is 5.2%

CONCLUSION A.C. Chen ADL 33

Conclusion The proposed CFIMon leveraged the branch trace store (BTS) mechanism to detect violation of control flow integrity The performance result shows that CFIMon can be applied to some real-world server applications on off-the-shell systems in daily use A.C. Chen ADL 34

Q & A A.C. Chen ADL 35

Return-Without-Call There are several cases that the calling convention may be violated :calling convention – setjmp / longjmp Instead of returning to its own caller, the longjmp returns to the caller of setjmp (also a legal address) – Unix signal handling Instead of returning to the caller (OS), the handler returns to the interrupted process modify the OS to let the monitor omit the alarm when a signal handler returns A.C. Chen ADL 36

Calling Convention Stack Frame of A() Stack Frame of B() Stack Frame of C() Stack Frame of D() A.C. Chen ADL 37 High addr. Low addr. A() B()C() D()

setjmp/longjmp A.C. Chen ADL 38 second main

Precision Mode of Intel CPU ---PEBS, BTS PEBS (Precise Event-Based Sampling) – Precise Performance Counter – atomic ‐ freeze: record exact IP address precisely BTS (Branch Trace Store) – to capture all control transfer events jump, call, return, interrupt and exception – also record the addresses of branch source and target – enables the monitoring of the whole control flow of an application A.C. Chen ADL 39

Precision Mode of Intel CPU ---LBR, Event Filtering, Conditional Counting LBR (Last Branch Record) – to record the most recent branches into a register stack – the size of the register stack is small Event Filtering – to filter events not concerned with – currently only available in LBR not BTS Conditional Counting – to separate user-level events from kernel-level ones – only increment counter while the processor is running at a specific privilege level e.g. “only counting when at user mode” A.C. Chen ADL 40