Programmable System Call Security with eBPF

Jinghao Jia, YiFei Zhu, Dan Williams, Andrea Arcangeli, Claudio Canella, Hubertus Franke, Tobin Feldman-Fitzthum, Dimitrios Skarlatos, Daniel Gruss, Tianyin XuarXiv 2023 · DOI

Abstract

System call filtering is a cornerstone of modern application sandboxing, yet the standard Linux mechanism, Seccomp-cBPF, is limited by its stateless nature. This paper presents Seccomp-eBPF, a programmable filtering framework that integrates extended BPF (eBPF) into the Seccomp subsystem. By enabling stateful policies and deep argument inspection, Seccomp-eBPF provides a robust defense against complex attacks, including Time-of-Check-to-Time-of-Use (TOCTTOU) races, while avoiding the significant performance overhead associated with userspace security agents.

Introduction

Sandboxing technologies, such as Docker and Android, rely heavily on system call filtering to restrict the attack surface of applications. The traditional tool for this, Seccomp-cBPF, uses classic BPF to make allow/deny decisions based on individual syscall arguments. However, cBPF is stateless; it cannot track process history or context (e.g., allowing execve() only once). While userspace agents like Seccomp Notifier offer more flexibility, they suffer from high context-switching overhead and are vulnerable to TOCTTOU attacks, where an attacker modifies syscall arguments in memory after the security check but before execution. Seccomp-eBPF addresses these challenges by bringing the programmability and safety of eBPF directly into the kernel's syscall filtering path.

System Design

The core of the proposed system is a new eBPF program type, BPF_PROG_TYPE_SECCOMP. This integration allows developers to write sophisticated security logic that executes within the kernel context. The workflow involves three primary phases: Load, Install, and Run. During the Load phase, the eBPF program is passed through a specialized Seccomp verifier to ensure safety before being JIT-compiled into native code.

Workflow of Seccomp-eBPF showing the load, install, and run phases across user and kernel space.

To support stateful and secure filtering, the authors introduced several key technical components:

  • Stateful Helpers: By exposing eBPF maps (arrays, hashes, etc.), filters can maintain state across syscall invocations.
  • Safe Deep Argument Inspection (DPI): New helpers like bpf_safe_read_user allow the filter to copy data from userspace into kernel memory safely, neutralizing TOCTTOU vulnerabilities.
  • Syscall Serialization: The bpf_wait_syscall helper enables the filter to pause execution if a potential race condition is detected, providing a generic defense against certain classes of kernel vulnerabilities.
Categorization of Seccomp-eBPF helpers and their implementation strategies.

Evaluation and Results

The system was evaluated using a variety of server applications (e.g., NGINX, Redis, Memcached) and real-world vulnerabilities (CVE-2016-0728, CVE-2018-18281).

Key results include:

  • Attack Surface Reduction: By utilizing stateful "temporal specialization"—where the filter tightens permissions after an application's initialization phase—the authors reduced the syscall attack surface by 33.6% to 55.4%.
  • Performance: Seccomp-eBPF maintains performance parity with the highly optimized cBPF and is orders of magnitude faster than userspace-based filtering, avoiding the "userspace tax" (up to 45x overhead).
  • Security Efficacy: The framework successfully mitigated multiple vulnerability classes, including those requiring counter-based limits and race condition serialization.

Discussion and Future Work

Seccomp-eBPF demonstrates that in-kernel stateful filtering is both feasible and highly effective. A key insight is the use of serialization as a defense mechanism, allowing administrators to block race-condition exploits without waiting for specific kernel patches. However, challenges remain. The complexity of the eBPF verifier itself is a potential point of failure, and the difficulty of writing complex eBPF policies suggests a need for automated policy generation tools. Future research will likely focus on using static and dynamic analysis to simplify the creation of these powerful security filters.

Summary updated

BibTeX
@misc{jia2023programmable,
  author = {Jinghao Jia and YiFei Zhu and Dan Williams and Andrea Arcangeli and Claudio Canella and Hubertus Franke and Tobin Feldman-Fitzthum and Dimitrios Skarlatos and Daniel Gruss and Tianyin Xu},
  title = {{Programmable System Call Security with eBPF}},
  year = {2023},
  eprint = {2302.10366},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2302.10366},
}
Figure