TL;DR
This paper introduces capweave, a tool that automatically rewrites C programs to use Capsicum capabilities, a security mechanism for fine-grained privilege control. capweave takes a declarative policy of desired capabilities and transforms the program, making it easier to write secure software with less manual effort and comparable performance to expert-written code.
What Problem Does This Paper Address?
Developing secure software is notoriously difficult. Traditional operating systems offer limited tools for applications to manage their own privileges, often requiring developers to prove complex properties like memory safety. Newer systems like Capsicum offer "capabilities" – essentially fine-grained access rights to resources – which allow for more robust security by limiting what code can do. However, manually instrumenting programs to correctly use these capability primitives is a complex and error-prone task, even for experienced developers. The core challenge is translating high-level security policies into the low-level, temporal sequences of system calls required by capability systems, while also preserving the program's original functionality.
Methods
The paper introduces capweave, a tool that tackles the "Capsicum policy-weaving problem." It operates in two main stages:
- Declarative Policy: A programmer defines a security policy using a declarative, temporal language. This policy specifies the capabilities a program should have at different points during its execution. This is a significant improvement over manually reasoning about the intricate temporal effects of capability primitives.
- Automatic Instrumentation:
capweavetakes the original, unwoven program (written in LLVM IR) and the declarative policy. It then uses an automata-theoretic approach, specifically a two-player safety game between an "Attacker" and a "Defender," to find a winning strategy for the Defender. This strategy is then translated into code that instruments the original program, inserting Capsicum system calls (primitives) at the appropriate locations to enforce the policy. The system is designed to be adaptable to new Capsicum primitives by simply updating a formal description of Capsicum's semantics.
Datasets
Not discussed in the paper. The paper focuses on applying capweave to existing UNIX utilities.
Key Insights and Ideas
- Declarative Policies Simplify Security: The core insight is that expressing security requirements as declarative, temporal policies (what capabilities should be held) is far more manageable for developers than manually orchestrating low-level capability primitives.
- Automata Games for Security Synthesis: The paper demonstrates the practical application of automata-theoretic safety games for automatically synthesizing security instrumentation. This is a powerful technique for bridging the gap between abstract policies and concrete code.
- Separation of Concerns:
capweaveeffectively separates the "what" (the policy) from the "how" (the instrumentation). This allows security architects to define policies and application developers to usecapweavewithout needing deep expertise in the intricacies of Capsicum primitives. - Practicality of Capabilities: The work shows that capability systems, when coupled with effective tooling like
capweave, can be used to secure real-world applications with minimal developer effort and acceptable performance overhead.
Key Results
- Reduced Effort: Developers needed only a few lines of code annotations and a policy of 35-114 lines to rewrite complex UNIX utilities like
bzip2,gzip,php-cgi,tar,tcpdump, andwget. - Efficiency:
capweaveitself is efficient, weaving programs in minutes (except forphp-cgiwhich took 46 minutes), making it suitable for integration into build systems. - Performance: Programs woven by
capweaveincurred a runtime overhead of at most 4% on realistic workloads, comparable to programs manually instrumented by experts. - Effectiveness: The woven programs successfully mitigated known vulnerabilities and enforced the defined security policies. For example, a woven
tcpdumpcould not open files containing secret keys, as dictated by its policy.
Limitations and Future Work
- Undecidability: The general policy-weaving problem is undecidable.
capweaveuses a sound but incomplete approach. - Failure Diagnostics: The current version of
capweavedoes not provide detailed diagnostic information when it fails to find a solution, which is a planned area for future work. - Programmer Study: The authors suggest a comprehensive programmer study is needed to fully evaluate the utility of
capweaveand related tools. - Policy Inference: Future work could involve tools that infer likely policies from system call usage, further reducing the burden on the programmer.
- Cost Metrics: Extending
capweaveto use cost metrics could help find more optimal strategies, especially when dealing with costly primitives likefork.
Summary updated