Security types to the rescue



Similar documents
CSE543 - Introduction to Computer and Network Security. Module: Operating System Security

Hunting Vulnerabilities with Graph Databases

Assignment 5: Adding and testing a new system call to Linux kernel

Why Do Software Assurance Tools Have Problems Finding Bugs Like Heartbleed?

Linux Kernel. Security Report

Mouse Drivers. Alan Cox.

Jorix kernel: real-time scheduling

Top 10 Bug-Killing Coding Standard Rules

Static Checking of C Programs for Vulnerabilities. Aaron Brown

Format. Three parts in today s presentation. Kernel auditing research. A sample of exploitable bugs. Kernel exploitation.

sys socketcall: Network systems calls on Linux

Kernel Intrusion Detection System

First Java Programs. V. Paúl Pauca. CSC 111D Fall, Department of Computer Science Wake Forest University. Introduction to Computer Science

Detecting Software Vulnerabilities Static Taint Analysis

Dynamic VM Monitoring using Hypervisor Probes

Exploiting Trustzone on Android

Review and Exploit Neglected Attack Surface in ios 8. Tielei Wang, Hao Xu, Xiaobo Chen of TEAM PANGU

W4118 Operating Systems. Junfeng Yang

Defense in Depth: Protecting Against Zero-Day Attacks

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

Iron Chef: John Henry Challenge

Practical taint analysis for protecting buggy binaries

Modeling and Discovering Vulnerabilities with Code Property Graphs

Java Interview Questions and Answers

ECS 165B: Database System Implementa6on Lecture 2

Defending Computer Networks Lecture 3: More On Vulnerabili3es. Stuart Staniford Adjunct Professor of Computer Science

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

Applications of formal verification for secure Cloud environments at CEA LIST

Semantic Analysis: Types and Type Checking

Data Types in the Kernel

QUIRE: : Lightweight Provenance for Smart Phone Operating Systems

Transparent Monitoring of a Process Self in a Virtual Environment

User-level processes (clients) request services from the kernel (server) via special protected procedure calls

Static Analysis In Software Security

Linux Kernel Rootkit : Virtual Terminal Key Logger

OpenCL Static C++ Kernel Language Extension

CHAPTER 5 INTELLIGENT TECHNIQUES TO PREVENT SQL INJECTION ATTACKS

X05. An Overview of Source Code Scanning Tools. Loulwa Salem. Las Vegas, NV. IBM Corporation IBM System p, AIX 5L & Linux Technical University

NDK: NOVELL NSS AUDIT

Porting Lustre to Operating Systems other than Linux. Ken Hornstein US Naval Research Laboratory April 16, 2010

Soft-Timer Driven Transient Kernel Control Flow Attacks and Defense

LLVMLinux: Embracing the Dragon

How To Write Portable Programs In C

C++ Programming Language

Chucky: Exposing Missing Checks in Source Code for Vulnerability Discovery

Unix::Statgrab - System Monitoring

HybriDroid: Analysis Framework for Android Hybrid Applications

Designing a Concurrent File Server

Open-source Versus Commercial Software: A Quantitative Comparison

Coding Rules. Encoding the type of a function into the name (so-called Hungarian notation) is forbidden - it only confuses the programmer.

Run-Time Type Checking for Binary Programs

Applying Clang Static Analyzer to Linux Kernel

Ulogd2, Advanced firewall logging

Visualizing Information Flow through C Programs

Linux Firewall Lab. 1 Overview. 2 Lab Tasks. 2.1 Task 1: Firewall Policies. Laboratory for Computer Security Education 1

Mining for Bugs with Graph Database Queries

IPC. Semaphores were chosen for synchronisation (out of several options).

Practice Questions. CS161 Computer Security, Fall 2008

MPI-Checker Static Analysis for MPI

Sistemi Operativi. Lezione 25: JOS processes (ENVS) Corso: Sistemi Operativi Danilo Bruschi A.A. 2015/2016

How To Port A Program To Dynamic C (C) (C-Based) (Program) (For A Non Portable Program) (Un Portable) (Permanent) (Non Portable) C-Based (Programs) (Powerpoint)

Betriebssysteme KU Security

Heartbleed. or: I read the news, too. Martin R. Albrecht. Information Security Group, Royal Holloway, University of London

C++ INTERVIEW QUESTIONS

Department of Electrical Engineering and Computer Science MASSACHUSETTS INSTITUTE OF TECHNOLOGY Operating System Engineering: Fall 2005

The C Programming Language course syllabus associate level

Using C to Access Data Stored in Program Space Memory on the TMS320C24x DSP

Crash Course in Java

CSC 405 Introduction to Computer Security

Manual vs. Automated Vulnerability Assessment: A Case Study

1 Abstract Data Types Information Hiding

Dynamic Taint Analysis for Automatic Detection, Analysis, and Signature Generation of Exploits on Commodity Software

Linux Driver Devices. Why, When, Which, How?

Týr: a dependent type system for spatial memory safety in LLVM

CS193j, Stanford Handout #10 OOP 3

Improving Software Quality with Static Analysis and Annotations for Software Defect Detection

Format string exploitation on windows Using Immunity Debugger / Python. By Abysssec Inc

Frama-C s value analysis plug-in

UNIX Sockets. COS 461 Precept 1

Design of a secure system. Example: trusted OS. Bell-La Pdula Model. Evaluation: the orange book. Buffer Overflow Attacks

Qt Signals and Slots. Olivier Goffart. October 2013

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

Using Code Coverage Tools in the Linux Kernel

A Test Suite for Basic CWE Effectiveness. Paul E. Black.

Malicious Code on Java Card Smartcards: Attacks and Countermeasures

Lecture 10: Dynamic Memory Allocation 1: Into the jaws of malloc()

Logistics. Software Testing. Logistics. Logistics. Plan for this week. Before we begin. Project. Final exam. Questions?

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

CS 106 Introduction to Computer Science I

Announcements. Lab 2 now on web site

Fortify on Demand Security Review. Fortify Open Review

Specific Simple Network Management Tools

How to Sandbox IIS Automatically without 0 False Positive and Negative

Lecture 17: Mobile Computing Platforms: Android. Mythili Vutukuru CS 653 Spring 2014 March 24, Monday

Lecture 22: C Programming 4 Embedded Systems

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

Pattern Insight Clone Detection

SMTP-32 Library. Simple Mail Transfer Protocol Dynamic Link Library for Microsoft Windows. Version 5.2

J a v a Quiz (Unit 3, Test 0 Practice)

The GenomeTools Developer s Guide

Transcription:

Security types to the rescue p. 1 Security types to the rescue David Wagner and Rob Johnson {daw,rtjohnso}@cs.berkeley.edu University of California, Berkeley

Security types to the rescue p. 2 Problem statement Attackers may feed us untrustworthy inputs We must be careful to never trust those inputs, lest terrible things happen How do we ensure proper input validation?

Security types to the rescue p. 3 Input validation is tricky untrusted sources trusting sinks your program All untrusted data must get validated somewhere on the path from source to sink Sources of untrusted data can be far from the sinks

Security types to the rescue p. 4 Strategy #1: Validate at the sources validate! untrusted sources trusting sinks your program A good choice when: proper validation depends on where data came from, rather than how it will be used

Security types to the rescue p. 5 Strategy #2: Validate at the sinks validate! untrusted sources trusting sinks your program A good choice when: proper validation depends on how data will be used, rather than where it came from

Security types to the rescue p. 6 A hybrid strategy untrusted sources trusting sinks your program This is what results when: Developer Dave validates at the sources Coder Courtney validates at the sinks Dave & Courtney work together

Security types to the rescue p. 7 Challenges in input validation untrusted sources trusting sinks your program There are many data flow paths through the program that require checks How can we be sure we got them all?

Security types to the rescue p. 8 Overview In this talk: Q: How can we verify complete input validation?

Security types to the rescue p. 8 Overview In this talk: Q: How can we verify complete input validation? A: Type systems

Security types to the rescue p. 8 Overview In this talk: Q: How can we verify complete input validation? A: Type systems Defn: Security types are types that record security claims.

Security types to the rescue p. 9 Static taint analysis The idea: Extend the C type system with type qualifiers Qualified types express security annotations; e.g., $tainted char * is an untrusted string Type checking enforces safe usage Type inference reduces the annotation burden Benefits: verify complete input validation eliminate error-prone mental bookkeeping

Security types to the rescue p. 10 Spot the bug char *s; s = read_from_network(); syslog(s);

Security types to the rescue p. 10 Spot the bug char *s; s = read_from_network(); syslog(s); untrusted source

Security types to the rescue p. 10 Spot the bug char *s; s = read_from_network(); untrusted source syslog(s); trusting sink

Security types to the rescue p. 10 Spot the bug char *s; s = read_from_network(); untrusted source syslog(s); trusting sink Format string bug! syslog() trusts its first argument.

Security types to the rescue p. 11 Types, and the example void printf($untainted char *,...); $tainted char * read_from_network(void); char *s; s = read_from_network(); syslog(s); where $untainted T $tainted T

Security types to the rescue p. 11 Types, and the example void printf($untainted char *,...); $tainted char * read_from_network(void); a trust annotation char *s; s = read_from_network(); syslog(s); where $untainted T $tainted T

Security types to the rescue p. 11 Types, and the example void printf($untainted char *,...); $tainted char * read_from_network(void); char *s; s = read_from_network(); syslog(s); where $untainted T $tainted T

Security types to the rescue p. 11 Types, and the example void printf($untainted char *,...); $tainted char * read_from_network(void); char /* $tainted */ *s; s = read_from_network(); syslog(s); where $untainted T $tainted T

Security types to the rescue p. 11 Types, and the example void printf($untainted char *,...); $tainted char * read_from_network(void); char /* $tainted */ *s; s = read_from_network(); syslog(s); an inferred type where $untainted T $tainted T

Security types to the rescue p. 11 Types, and the example void printf($untainted char *,...); $tainted char * read_from_network(void); char /* $tainted */ *s; s = read_from_network(); syslog(s); Doesn t type-check! A security hole. where $untainted T $tainted T

Case study #1: Format string bugs Successful at finding bugs in real programs Cost: 10 15 minutes per application Security types to the rescue p. 12

Security types to the rescue p. 13 Case study #2: the Linux kernel Risk: TOCTTOU bugs Some syscalls pass values by reference, rather than by value Current approach: manual emulation of pass-by-copy Problematic; it s easy to forget to make a copy Types can help...

Security types to the rescue p. 14 GOOD! int main () { struct foo *p;... ioctl (fd, SIOCGFOO, p);... } int dev_ioctl (int cmd, long arg) { struct foo *q = mkfoo();... copy_to_user (arg, q, n); return 0; } User code Kernel code

Security types to the rescue p. 15 BAD! int main () { struct foo *p;... ioctl (fd, SIOCGFOO, p);... } int dev_ioctl (int cmd, long arg) { struct foo *q = mkfoo();... memcpy (arg, q, n); return 0; } User code Kernel code

Security types to the rescue p. 16 Type qualifiers to the rescue The idea: Annotate all pointers from user-space as $user Annotate all kernel pointers as $kernel Only allow dereferencing of $kernel pointers Use type qualifier inference (CQUAL)

Security types to the rescue p. 17 Example: Type checking struct foo * $kernel mkfoo(void); int memcpy(void * $kernel dst, void * $kernel src, size_t n); int dev_ioctl (int cmd, long $user arg) { struct foo * $kernel q = mkfoo();... memcpy (arg, q, n); Doesn t type-check! return 0; }

Security types to the rescue p. 17 Example: Type inference struct foo * $kernel mkfoo(void); int memcpy(void * $kernel dst, void * $kernel src, size_t n); int dev_ioctl (int cmd, long $user arg) { struct foo * /* $kernel */ q = mkfoo();... q s type is inferred automatically memcpy (arg, q, n); Doesn t type-check! return 0; }

Security types to the rescue p. 17 Example: Type inference struct foo * $kernel mkfoo(void); int memcpy(void * dst, void * src, size_t n) { while (n-- > 0) *dst++ = *src++; } memcpy() s signature is inferred automatically int dev_ioctl (int cmd, long $user arg) { struct foo * /* $kernel */ q = mkfoo();... q s type is inferred automatically memcpy (arg, q, n); Doesn t type-check! return 0; }

Security types to the rescue p. 18 Experience with user-kernel bugs Analyzed 1259 files in Linux 2.4.18 CQUAL reported errors in 23 files One error was genuine, exploitable bug Fixed in Linux 2.4.19 Recent changes to CQUAL Improve bug-finding power (pointeral and structureal constraints) Reduce false positive rate (polymorphic type inference, separating structure instances) Results forthcoming

Security types to the rescue p. 19 Spot the bug static int joydev_ioctl(struct inode *inode, struct file *f unsigned int cmd, unsigned long arg) { switch (cmd) { case JSIOCSAXMAP: if (copy_from_user(( u8 *) arg, joydev->abspam, sizeof( u8) * ABS_MAX)) return -EFAULT; for (i = 0; i < ABS_MAX; i++) { if (joydev->abspam[i] > ABS_MAX) return -EINVAL; joydev->absmap[joydev->abspam[i]] = i; } } }

Security types to the rescue p. 20 The general picture Principle: Objects with different security properties should receive different types. Values under attacker control receive a $tainted type: Untrusted sources are marked $tainted Anything that depends on a $tainted value is also marked $tainted Input validation breaks the propagation of $tainted A $tainted value at a trusting sink is an error

Security types to the rescue p. 21 Concluding thoughts Security types: a disciplined style of programming An enforceable discipline Detects errors of omission, but not of comission; type system won t let you forget to validate inputs (but did you do the right validation checks?) Type systems are useful for security engineering You can try this at home