February Syscall Filtering and You Paul Moore

Similar documents
Sandboxing Linux code to mitigate exploitation. (Or: How to ship a secure operating system that includes third-party code)

Outline. Basic features of BPF virtual machine

Sandboxing. CS-576 Systems Security Instructor: Georgios Portokalidis Spring 2018

Using seccomp to limit the kernel attack surface

Seccomp. Linux Security and Isolation APIs. Outline. Michael Kerrisk, man7.org c 2017 November 2017

Using seccomp to limit the kernel attack surface

Using seccomp to limit the kernel attack surface

File access-control per container with Landlock

Container Isolation at Scale (... and introducing gvisor) Dawn Chen and Zhengyu He

Promises and pitfalls of sandboxes

ISOLATION DEFENSES GRAD SEC OCT

Landlock LSM: toward unprivileged sandboxing

Scripting Linux system calls with Lua. Lua Workshop 2018 Pedro Tammela CUJO AI

seccomp-nurse Nicolas Bareil ekoparty 2010 EADS CSC Innovation Works France seccomp-nurse: sandboxing environment

LibSysCTr(3) System Call Tracing Library LibSysCTr(3)

Chrome/OS Security 2014

TDDB68. Lesson 1. Simon Ståhlberg

ECE 471 Embedded Systems Lecture 8

BUFFER OVERFLOW DEFENSES & COUNTERMEASURES

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

PROCESS MANAGEMENT. Operating Systems 2015 Spring by Euiseong Seo

How Double-Fetch Situations turn into Double-Fetch Vulnerabilities:

Operating Systems 2010/2011

Buffer overflow background

lpengfei Ding & Chenfu Bao lsecurity Researcher & Baidu X-Lab lfocused on Mobile, IoT and Linux kernel security

Introduction to OS Processes in Unix, Linux, and Windows MOS 2.1 Mahmoud El-Gayyar

Common Problems on Homework

Linux Kernel Security Update LinuxCon Europe Berlin, 2016

On Supporting Per-Process based System Call Vectors in Linux Kernel

CSC369 Lecture 2. Larry Zhang, September 21, 2015

Productizing Linux Applications. What We ll Cover

MWR InfoSecurity Security Advisory. IBM WebSphere MQ - rrilookupget Remote Denial of Service Vulnerability. 4th March 2010

I run a Linux server, so we re secure

Malware

ViryaOS RFC: Secure Containers for Embedded and IoT. A proposal for a new Xen Project sub-project

Arm cross development tools

Linux Kernel Security Overview

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

EECS 482 Introduction to Operating Systems

Reading Assignment 4. n Chapter 4 Threads, due 2/7. 1/31/13 CSE325 - Processes 1

PROCESS MANAGEMENT Operating Systems Design Euiseong Seo

PROCESSES. At least they re not ISO-9001 processes

CAN STRACE MAKE YOU FAIL?

THREADS: (abstract CPUs)

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

Operating Systems (234123) Spring 2017 (Homework Wet 1) Homework 1 Wet

PROCESSES. Jo, Heeseung

Processes. Jo, Heeseung

Sandwiches for everyone

Sandboxing. (1) Motivation. (2) Sandboxing Approaches. (3) Chroot

CSC369 Lecture 2. Larry Zhang

A practical introduction to XDP

Android Kernel Security

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

Secure Containers with EPT Isolation

Windows architecture. user. mode. Env. subsystems. Executive. Device drivers Kernel. kernel. mode HAL. Hardware. Process B. Process C.

SPEAKER: Split-Phase Execution of Application Containers

I Control Your Code Attack Vectors through the Eyes of Software-based Fault Isolation. Mathias Payer

CSE 120 Principles of Operating Systems

CSCE Operating Systems Interrupts, Exceptions, and Signals. Qiang Zeng, Ph.D. Fall 2018

OS lpr. www. nfsd gcc emacs ls 1/27/09. Process Management. CS 537 Lecture 3: Processes. Example OS in operation. Why Processes? Simplicity + Speed

METU Department of Computer Engineering

Processes and Threads

First order of Business

Programming Abstractions

ECE 574 Cluster Computing Lecture 8

DPDK+eBPF KONSTANTIN ANANYEV INTEL

IMPLEMENTATION OF SIGNAL HANDLING. CS124 Operating Systems Fall , Lecture 15

ARM Compiler and assembly on QEMU

Scheduling Policies. Threads Library. Lightweight Processes

SA30228 / CVE

13th ANNUAL WORKSHOP 2017 VERBS KERNEL ABI. Liran Liss, Matan Barak. Mellanox Technologies LTD. [March 27th, 2017 ]

Linux seccomp(2) vs OpenBSD pledge(2)

SE350: Operating Systems

CSC 591 Systems Attacks and Defenses Stack Canaries & ASLR

The Kernel Abstraction. Chapter 2 OSPP Part I

Chapter 3: Process Concept

Chapter 3: Process Concept

Exceptions and Processes

TDDB68 Lesson 2 Pintos Assignments 3 & 4. Mattias Eriksson 2010 (or

Linux Kernel Futex Fun: Exploiting CVE Dougall Johnson

CS 326: Operating Systems. Process Execution. Lecture 5

The Kernel Abstraction

Operating system organizaton

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

Chapter 3: Process Concept

OS lpr. www. nfsd gcc emacs ls 9/18/11. Process Management. CS 537 Lecture 4: Processes. The Process. Why Processes? Simplicity + Speed

Exercise Session 6 Computer Architecture and Systems Programming

Process Control. Philipp Koehn. 23 April 2018

Process. Heechul Yun. Disclaimer: some slides are adopted from the book authors slides with permission 1

seven Virtual Memory Introduction

Tolerating Malicious Drivers in Linux. Silas Boyd-Wickizer and Nickolai Zeldovich

Hint #1. Define a syscall

CS 355 Operating Systems. Keeping Track of Processes. When are processes created? Process States 1/26/18. Processes, Unix Processes and System Calls

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

CSC C69: OPERATING SYSTEMS

Inf2C - Computer Systems Lecture 16 Exceptions and Processor Management

ECE 473 Computer Architecture and Organization Lab 4: MIPS Assembly Programming Due: Wednesday, Oct. 19, 2011 (30 points)

CS61 Scribe Notes Lecture 18 11/6/14 Fork, Advanced Virtual Memory

Operating Systems and Networks Assignment 9

Transcription:

Syscall Filtering and You Paul Moore February 2014 1

What is Linux Syscall Filtering Triggers the kernel to take action on syscalls Kill the calling process Signal the calling process Signal the parent tracing process Cause the syscall to return a specific errno value Configured on a per-process basis Configured at application run-time Inherited by the process' children Enforced by the kernel 2

Why You Should Care Bugs are both inevitable and a security risk 1.Application bugs can lead to malicious code execution 2.Malicious code can exercise kernel vulnerabilities 3.Kernel vulnerabilities can lead to @!$&%#! Focus on containing bugs and limiting the risks System hardening Access controls and now, syscall filtering 3

The Start of Linux Syscall Filtering Initial syscall filtering functionality, seccomp mode 1 First appeared in Linux 2.6.23 Filtering is enabled on a per-application basis Fixed list of allowed syscalls: read(2), write(2), exit(2), sigreturn(2) Not very flexible, not a general purpose solution Unable to filter on architecture/abi Unable to change the syscall whitelist Unable to filter on syscall arguments 4

Linux Syscall Filtering Today Enhanced syscall filtering, seccomp mode 2 First appeared in Linux 3.5 for x86, x86_64, and x32 Added 32-bit ARM support in Linux 3.8 Additional architectures are works in progress 32-bit and 64-bit MIPS (3.15?) 64-bit ARM (patches are available) Syscall filters are now defined by a filtering language Applications create their own syscall filter Filter on arch/abi and any syscall, including arguments Filtering is still done by the kernel 5

Seccomp Mode 2 and the Filter Language Filters are written in BPF (Berkley Packet Filter) Simple low level language, e.g. assembly Originally used in the Linux network socket filter Multiple filters can be loaded for each process Syscalls are filtered through the entire filter stack Most restrictive result wins Not possible to unload or overwrite a loaded filter Syscall filters are inherited across fork(2)/exec(2) Not possible to escape from a syscall filter once set 6

Language Based Filtering and Complexity Drawbacks of language based syscall filtering Syscall tables are different for each architecture Filters are arch/abi dependent BPF language is 32-bit 64-bit support is possible, but BPF code is more complex Good, non-trivial filters can be cumbersome Similar to coding in assembly language Learning curve may be too steep for developers Developers want to focus on their application, not syscall filtering 7

Making Life Easier with libseccomp Provide a programmatic API for seccomp filters Architecture/ABI independent Transparent support for 64-bit architectures No BPF knowledge required Provide documentation and examples Currently 22 manpages, 25 tests/examples Generate optimized filters without any extra effort Library optimizes filters for size/speed automatically API allows developers to provide syscall priority hints 8

libseccomp Filter Example int myapp_libseccomp_start(void) { int rc; scmp_filter_ctx ctx; ctx = seccomp_init(scmp_act_kill); if (ctx == NULL) return -ENOMEM; rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(open), 0); if (rc < 0) goto out; rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(close), 0); if (rc < 0) goto out; rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(read), 3, SCMP_A0(SCMP_CMP_EQ, STDIN_FILENO), SCMP_A1(SCMP_CMP_NE, 0x0), SCMP_A2(SCMP_CMP_LT, SSIZE_MAX)); if (rc < 0) goto out; rc = seccomp_load(ctx); out: } seccomp_release(ctx); return rc; 9

Raw BPF Syscall Filter Example 10 int myapp_seccomp_raw_start(void) { struct sock_filter filter[] = { BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 4), BPF_STMT(BPF_JMP+BPF_JEQ+BPF_K, AUDIT_ARCH_X86_64, 0x00, 0x12), BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 0), BPF_STMT(BPF_JMP+BPF_JGE+BPF_K, 0x40000000, 0x10, 0x00), BPF_STMT(BPF_JMP+BPF_JEQ+BPF_K, NR_open, 0x0e, 0x00), BPF_STMT(BPF_JMP+BPF_JEQ+BPF_K, NR_close, 0x0d, 0x00), BPF_STMT(BPF_JMP+BPF_JEQ+BPF_K, NR_read, 0x00, 0x0d), BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 20), BPF_STMT(BPF_JMP+BPF_JEQ+BPF_K, 0, 0x00, 0x0b), BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 16), BPF_STMT(BPF_JMP+BPF_JEQ+BPF_K, 0, 0x00, 0x09), BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 28), BPF_STMT(BPF_JMP+BPF_JEQ+BPF_K, 0, 0x00, 0x02), BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 24), BPF_STMT(BPF_JMP+BPF_JEQ+BPF_K, 0, 0x05, 0x00), BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 36), BPF_STMT(BPF_JMP+BPF_JEQ+BPF_K, (SSIZE_MAX >> 32), 0x00, 0x02), BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 32), BPF_STMT(BPF_JMP+BPF_JEQ+BPF_K, (SSIZE_MAX & 0xffffffff), 0x01, 0x00), BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_ALLOW), BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_KILL), }; struct sock_fprog prog = {.len = (unsigned short)(sizeof(filter)/sizeof(filter[0])),.filter = filter, }; if (prctl(pr_set_no_new_privs, 1, 0, 0, 0) < 0) return -errno; if (prctl(pr_set_seccomp, SECCOMP_MODE_FILTER, &prog) < 0) return -errno; return 0; }

How You Can Help (part 1) Add syscall filtering to your applications Does your application work with dangerous data? Network applications, virtualization hypervisors, etc. Does your application offer sandboxing / containment? Syscall filtering can provide a new layer of hardening Others? Help with libseccomp development Additional automated tests Support for new architecture/abis Better tools for developers adding libseccomp support 11

How You Can Help (part 2) Testing Test libseccomp in your environment and applications Test libseccomp on new architectures Try to break libseccomp (please email me the pieces) Documentation Improve our existing manpages Develop tutorials and developer guides Help spread the word about libseccomp 12

More Information The libseccomp project Website http://libseccomp.sf.net Mailing list libseccomp-discuss@lists.sourceforge.net Source repository git://git.code.sf.net/p/libseccomp/libseccomp Presentation feedback http://devconf.cz/f/108 13