UniSan: Proactive Kernel Memory Initialization to Eliminate Data Leakages

Similar documents
Preventing Use-after-free with Dangling Pointers Nullification

SECURING SOFTWARE SYSTEMS BY PREVENTING INFORMATION LEAKS

HDFI: Hardware-Assisted Data-flow Isolation

Cling: A Memory Allocator to Mitigate Dangling Pointers. Periklis Akritidis

Breaking Kernel Address Space Layout Randomization (KASLR) with Intel TSX. Yeongjin Jang, Sangho Lee, and Taesoo Kim Georgia Institute of Technology

Kernel Self Protection

A program execution is memory safe so long as memory access errors never occur:

Runtime Defenses against Memory Corruption

Honours/Master/PhD Thesis Projects Supervised by Dr. Yulei Sui

Kruiser: Semi-synchronized Nonblocking Concurrent Kernel Heap Buffer Overflow Monitoring

SoK: Eternal War in Memory

HA2lloc: Hardware-Assisted Secure Allocator

unsigned char memory[] STACK ¼ 0x xC of address space globals function KERNEL code local variables

Improving Error Checking and Unsafe Optimizations using Software Speculation. Kirk Kelsey and Chen Ding University of Rochester

Thwarting unknown bugs: hardening features in the mainline Linux kernel

Remix: On-demand Live Randomization

Software Security II: Memory Errors - Attacks & Defenses

Baggy bounds with LLVM

Identifying Memory Corruption Bugs with Compiler Instrumentations. 이병영 ( 조지아공과대학교

Advanced Programming & C++ Language

Fast, precise dynamic checking of types and bounds in C

o Code, executable, and process o Main memory vs. virtual memory

Precise Garbage Collection for C. Jon Rafkind * Adam Wick + John Regehr * Matthew Flatt *

In Java we have the keyword null, which is the value of an uninitialized reference type

Run-time Environments

CSC 591 Systems Attacks and Defenses Stack Canaries & ASLR

Run-time Environments

Making C Less Dangerous

Version:1.1. Overview of speculation-based cache timing side-channels

TI2725-C, C programming lab, course

Shreds: S H R E. Fine-grained Execution Units with Private Memory. Yaohui Chen, Sebassujeen Reymondjohnson, Zhichuang Sun, Long Lu D S

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING

CSC 1600 Memory Layout for Unix Processes"

Advanced Debugging and the Address Sanitizer

Homework 3 CS161 Computer Security, Fall 2008 Assigned 10/07/08 Due 10/13/08

Dynamic Memory Allocation: Advanced Concepts

New features in AddressSanitizer. LLVM developer meeting Nov 7, 2013 Alexey Samsonov, Kostya Serebryany

HexType: Efficient Detection of Type Confusion Errors for C++ Yuseok Jeon Priyam Biswas Scott A. Carr Byoungyoung Lee Mathias Payer

CSC C69: OPERATING SYSTEMS

Ironclad C++ A Library-Augmented Type-Safe Subset of C++

Limitations of the stack

CS527 Software Security

CSE 565 Computer Security Fall 2018

in memory: an evolution of attacks Mathias Payer Purdue University

Secure Virtual Architecture: Using LLVM to Provide Memory Safety to the Entire Software Stack

DEBUGGING: DYNAMIC PROGRAM ANALYSIS

Dnmaloc: a more secure memory allocator

Finding User/Kernel Pointer Bugs with Type Inference p.1

System Assertions. Andreas Zeller

Topics in Software Security Vulnerability

[0569] p 0318 garbage

CSci 4061 Introduction to Operating Systems. Programs in C/Unix

Version:2.1. Overview of speculation-based cache timing side-channels

Run-time Environments. Lecture 13. Prof. Alex Aiken Original Slides (Modified by Prof. Vijay Ganesh) Lecture 13

CS356: Discussion #6 Assembly Procedures and Arrays. Marco Paolieri

Code: analysis, bugs, and security

CS-527 Software Security

6.172 Performance Engineering of Software Systems Spring Lecture 9. P after. Figure 1: A diagram of the stack (Image by MIT OpenCourseWare.

Buffer overflow prevention, and other attacks

Lecture 14. No in-class files today. Homework 7 (due on Wednesday) and Project 3 (due in 10 days) posted. Questions?

ECE 598 Advanced Operating Systems Lecture 10

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017

COMP26120: Linked List in C (2018/19) Lucas Cordeiro

Inference of Memory Bounds

QPSI. Qualcomm Technologies Countermeasures Update

Enhanced Operating System Security Through Efficient and Fine-grained Address Space Randomization

Dissecting a 17-year-old kernel bug

T-SGX: Eradicating Controlled-Channel

Buffer Overflow Defenses

Causes of Software Failures

Class Information ANNOUCEMENTS

Memory Management Basics

SoK: Eternal War in Memory Laszlo Szekeres, Mathias Payer, Tao Wei, and Dawn Song In: Oakland 14

Inception: System-Wide Security Testing of Real- World Embedded Systems Software Nassim Corteggiani (Maxim Integrated / EURECOM) Giovanni Camurati

Bug Hunting and Static Analysis

A Novel Approach to Explain the Detection of Memory Errors and Execution on Different Application Using Dr Memory.

Software security, secure programming

Buffer Overflow Attacks

Transparent Pointer Compression for Linked Data Structures

System Administration and Network Security

Memory management. Johan Montelius KTH

APISan: Sanitizing API Usages through Semantic Cross-checking

The benefits and costs of writing a POSIX kernel in a high-level language

CS 430 Spring Mike Lam, Professor. Data Types and Type Checking

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

COMP 3704 Computer Security

Android Kernel Security

Operating Systems. 11. Memory Management Part 3 Kernel Memory Allocation. Paul Krzyzanowski Rutgers University Spring 2015

Control-Flow Hijacking: Are We Making Progress? Mathias Payer, Purdue University

Lecture 14 Notes. Brent Edmunds

18-642: Code Style for Compilers

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

Enforcing Kernel Security Invariants with Data Flow Integrity

Software Vulnerabilities August 31, 2011 / CS261 Computer Security

Last week. Data on the stack is allocated automatically when we do a function call, and removed when we return

10.1. CS356 Unit 10. Memory Allocation & Heap Management

Improving Integer Security for Systems with KINT. Xi Wang, Haogang Chen, Zhihao Jia, Nickolai Zeldovich, Frans Kaashoek MIT CSAIL Tsinghua IIIS

6.828: OS/Language Co-design. Adam Belay


SoK: Eternal War in Memory

Transcription:

UniSan: Proactive Kernel Memory Initialization to Eliminate Data Leakages Kangjie Lu, Chengyu Song, Taesoo Kim, Wenke Lee School of Computer Science, Georgia Tech

Any Problem Here? /* File: drivers/usb/core/devio.c*/ /* define data structure usbdevfs_connectinfo */ struct usbdevfs_connectinfo{ unsigned int devnum; unsignedchar slow; }; /* create and initialize object ci struct usbdevfs_connectinfoci = {.devnum = ps->dev->devnum,.slow = ps->dev->speed == USB_SPEED_LOW }; /* copy ci to user space */ copy_to_user(arg, &ci, sizeof(ci)); 3-byte padding Information leak!

Security Mechanisms in OS Kernels kaslr: Randomizing the address of code/data Memory Code/data Memory Code/data Memory Code/data? 1 st boot 2 nd boot 3 rd boot n boot Preventing code-reuse and privilege escalation attacks StackGuard: Inserting random canary in stack Preventing stack corruption-based attacks

The Assumption of Effectiveness Assumption: No information leak Memory Randomized address kaslr Random canary StackGuard A single information leak renders these security mechanisms ineffective!

Infoleak in the OS (Linux) Kernel According to the CVE database Number 60 # of reported Infoleak bugs in the Linux kernel 40 20 0 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 These security mechanisms are often bypassed in reality Sensitive data (e.g., cryptographic keys) can also be leaked.

Our research aims to eliminate information leaks in OS kernels

Causes of Infoleaks Uninitialized data read: Reading data before initialization, which may contain uncleared sensitive data Out-of-bound read: Reading across object boundaries Use-after-free: Using freed pointer/size that can be attacker controlled Others: Missing permission check, race condition

Causes of Infoleaks (cont.) Infoleak Causes in the Linux Kernel (since 2013) Model checking, etc. OOB and UAF read (29.1%) Others (13.6%) Uninitialized data read (57.3%) Uninitialized data read Out-of-bound and useafter-free read Others (e.g., logic error) Memory safety Our focus Similarly, Chen et al. [APSys 11] showed 76% infoleaks (Jan. 2010 - Mar. 2011) are caused by uninitialized data reads

From Uninitialized Data Read to Leak 1. Deallocated memory is not cleared by default. 2. Allocated memory is not initialized by default. 3. Reading the uninitialized memory -> leak. Memory Memory Memory Object A Object B Object B sensitive sensitive sensitive sensitive 1 2 3 4 User A allocates object A and writes sensitive in to it User A deallocates object A; sensitive is not cleared User B allocates object B without Initialization; sensitive kept User B reads Object B; sensitive leaked!

Troublemaker: Developer Missing element initialization: Blame the developer. J Difficult to avoid, e.g., Data structure definition and object initialization may be implemented by different developers

Troublemaker: Compiler Data structure padding: A fundamental feature improving CPU efficiency struct usbdevfs_connectinfo { unsigned int devnum; unsigned char slow; /* 3-bytes padding */ }; /* both fields (5 bytes) are initialized */ struct usbdevfs_connectinfo ci = {.devnum = ps->dev->devnum,.slow = ps->dev->speed == USB_SPEED_LOW }; /* leaking 3-byte uninitialized padding sizeof(ci) = 8 */ copy_to_user(arg, &ci, sizeof(ci));

C Specifications (C11) Chapter 6.2.6.1/6 When a value is stored in an object of structure or union type, including in a member object, the bytes of the object representation that correspond to any padding bytes take unspecified values.

Responses from the Linux Community Doubted Confirmed Kees Cook: Willy Tarreau: Blamed GCC Agreed solution Linus Torvalds: Ben Hutchings:

Detecting/Preventing Uninitialized Data Leaks The -Wuninitialized option of compilers? Simply initialize all allocations? Our UniSan approach: 1) Conservatively identify unsafe allocations (i.e., with potential leaks) via static program analysis 2) Instrument the code to initialize only unsafe allocations

Detecting Unsafe Allocations Integrating byte-level and flow-, context-, and field-sensitive reachability and initialization analyses Reachability analysis Sources (i.e., allocations) Data flow Initialization analysis Sinks (e.g., copy_to_user)

Main Challenges in UniSan Sink definition General rules Global call-graph construction Type analysis for indirect calls Byte-level tracking Offset-based analysis, GetElementPtr Be conservative! Assume it is unsafe for special cases!

Instrumentation Zero-initializations for unsafe allocations: Stack: Assigning zero or using memset Heap: Adding the GFP_ZERO flag to kmalloc Instrumentations are semantic preserving Robust Tolerant of false positives

Implementation Using LLVM An analysis pass and an instrumentation pass Making kernels compilable with LLVM Patches from the LLVMLinux project and Kenali [NDSS 16] Optimizing analysis Modeling basic functions How to use UniSan: $ unisan @bitcode.list

Evaluation Evaluation goals Accuracy in identifying unsafe allocations Effectiveness in preventing uninitialized data leaks The efficiency of the secured kernels Platforms Latest mainline Linux kernel for x86_64 Latest Android kernel for AArch64

Evaluation of Accuracy Statistics of various numbers: Only 10% of allocations are detected as unsafe. Arch Module Alloca Malloc Unsafe Alloca Unsafe Malloc Percent X86_64 2,152 17,878 2,929 1,493 386 9.0% AArch64 2,030 15,628 3,023 1,485 451 10.3%

Evaluation of Effectiveness Preventing known leaks: Selected 43 recent leaks with CVE# UniSan prevented all of them Detecting unknown leaks With manual verification

Confirmed New Infoleaks (Selected) File Object Leak Bytes Cause CVE rtnetlink.c map 4 Pad CVE-2016-4486 devio.c ci 3 Pad CVE-2016-4482 af_llc.c info 1 Pad CVE-2016-4485 timer.c tread 8 Pad CVE-2016-4569 timer.c r1 8 Pad CVE-2016-4578 netlink...c link_info 60 Dev. CVE-2016-5243 mediadevice.c u_ent 192 P&D AndroidID- 28616963 more more more

Evaluation of Efficiency Runtime overhead (geo-mean %) Category Benchmarks Blind Mode (x86_64) System operations Server programs User programs Analyses took less 3 minutes. Binary size increased < 0.5%. UniSan (x86_64) LMBench 4.74% 1.36% ApacheBench 0.8% <0.1% SPEC Bench 1.92% 0.54%

Limitations and Future Work Custom heap allocators Require annotations Close-sourced modules Not supported Other uninitialized uses, e.g., uninitialized pointer dereference GCC support (in progress)

Conclusions Information leaks are common in OS kernels. Uninitialized read is the dominant cause. Developers are not always to blame compilers may also introduce security problems. UniSan eliminates all uninitialized data leaks.

Try UniSan: https://github.com/sslab-gatech/unisan