TL;DR
This paper introduces Chestnut, an automated system for generating seccomp filters for Linux applications, significantly reducing the attack surface by blocking unused system calls. Chestnut offers a faster compiler-based approach and a more flexible binary analysis method that doesn't require position-independent binaries, making syscall filtering accessible to a wider range of applications.
What Problem Does This Paper Address?
Modern software, especially applications written in memory-unsafe languages like C, is increasingly complex and prone to vulnerabilities. While seccomp is a powerful Linux mechanism for restricting an application's system call (syscall) interface, its manual configuration for each application is a significant hurdle. This manual effort limits its widespread adoption. Existing automated approaches to generate seccomp filters have limitations: some are computationally expensive, requiring extensive analysis during compilation, while others impose strict requirements on the binary format (e.g., position-independent code), excluding many applications. This paper aims to overcome these limitations by providing a more efficient, flexible, and broadly applicable automated seccomp filter generation system.
Methods
Chestnut employs a two-phase approach:
- Phase 1: Static Analysis (P1)
- Sourcalyzer (Compiler-based): This component integrates with the LLVM compiler framework. It analyzes the application's source code during compilation to identify used syscalls. It uses a "has address taken" approach for call graph construction, which is significantly faster than previous points-to analysis methods.
- Binalyzer (Binary Analysis): For applications where source code is unavailable or incompatible with LLVM, Binalyzer analyzes the compiled binary. It uses symbolic backward execution to identify syscall numbers and control-flow graph analysis to map them to functions. Crucially, Binalyzer does not require position-independent binaries (PIE), a significant advantage over prior work.
- Phase 2: Dynamic Refinement (P2) - Finalyzer (Optional)
- This phase addresses limitations of static analysis, such as handling dynamically loaded libraries or child processes with inherited filters. Finalyzer acts as a tracer, observing syscalls at runtime and refining the seccomp filters to include any missed syscalls or remove unnecessary ones. This phase is optional and intended for cases where static analysis might be insufficient.
Chestnut can then apply these generated filters by either patching the binary to include a seccomp library or by generating a sandboxed wrapper.
Datasets
The paper evaluates Chestnut on a selection of 18 real-world applications, including:
- Client utilities:
ls,chown,cat,pwd,diff,dmesg,env,grep,true,head,git,ffmpeg,mutool. - Database applications:
redis-server,sqlite3. - Server applications:
memcached,nginx,httpd.
The evaluation also references the CVE database [75] for security analysis.
Key Insights and Ideas
- Performance Boost for Compiler-Based Analysis: By using a faster "has address taken" approach for call graph construction instead of complex points-to analysis, Sourcalyzer achieves up to a 73x speedup in compilation time compared to prior work without sacrificing accuracy.
- Breaking the PIE Requirement: Binalyzer's ability to analyze non-PIE binaries significantly broadens the applicability of automated seccomp filter generation, as many statically compiled binaries are not PIE.
- Dynamic Refinement for Edge Cases: The optional Finalyzer phase is crucial for handling dynamic library loading and complex execution scenarios where static analysis might miss syscalls.
- Tightness of Filters: The paper is the first to evaluate the "tightness" of automatically generated seccomp filters, demonstrating how well they match the actual syscalls used by an application.
- Practical Security Improvement: Chestnut effectively blocks dangerous syscalls like
execand mitigates a significant percentage of kernel-targeting CVEs, enhancing system security without requiring manual intervention.
Key Results
- Syscall Reduction: On average, Chestnut blocks 302 syscalls (86.5%) using the compiler-based approach and 288 (82.5%) using the binary-based approach across tested applications.
- Dangerous Syscall Blocking: The
execsyscall is blocked in 50% of applications with Sourcalyzer and 77.7% with Binalyzer.mprotectis blocked in 61.1% with Sourcalyzer. - CVE Mitigation: Chestnut prevents exploitation of over 62% of 175 kernel-targeting CVEs.
- Performance: Sourcalyzer offers up to a 73x speedup for Nginx compilation compared to related work. Binalyzer's analysis time is generally in the range of 2-10 seconds for typical applications.
- Functional Correctness: A 6-month long-term study of a sandboxed Nginx server showed no crashes. Functional correctness was also validated by running test suites and observing code coverage.
- Binary Size: The overhead for annotated binaries is generally small, with static binaries seeing a maximum overhead limited by the number of available syscalls. Dynamic binaries and shared libraries show a larger overhead due to embedding call graphs.
Limitations and Future Work
- Seccomp Performance: The inherent slowness of seccomp itself is a system-level limitation, not specific to Chestnut.
- Overapproximation: Both static approaches can still overapproximate the set of used syscalls, although Finalyzer helps mitigate this. The paper acknowledges that achieving perfect precision with static analysis is an open problem.
- Argument-Level Filtering: The current work focuses on syscall numbers. Future work could extend filtering to specific syscall arguments (e.g., blocking
execwith hardcoded paths) for even finer-grained security. - Coverage-Guided Fuzzing: The authors suggest using coverage-guided fuzzing to better estimate the overapproximation of automated seccomp filter generation tools.
- Performance Improvements: Investigating performance improvements for seccomp or exploring alternatives is also mentioned.
Summary updated