Fine-grained privilege separation for web applications

Akshay Krishnamurthy, Adrian Mettler, David A. WagnerWWW 2010

Abstract

We present a programming model for building web applications with security properties that can be confidently verified during a security review. In our model, applications are divided into isolated, privilege-separated components, enabling rich security policies to be enforced in a way that can be checked by reviewers. In our model, the web framework enforces privilege separation and isolation of web applications by requiring the use of an object-capability language and providing interfaces that expose limited, explicitly-specified privileges to application components. This approach restricts what each component of the application can do and quarantines buggy or compromised code. It also provides a way to more safely integrate third-party, less-trusted code into a web application. We have implemented a prototype of this model based upon the Java Servlet framework and used it to build a webmail application. Our experience with this example suggests that the approach is viable and helpful at establishing reviewable application-specific security properties.

Introduction

Modern web applications often suffer from a fundamental architectural flaw: "ambient authority." When code executes within a user's session, it typically inherits broad permissions to access any session data, cookies, or backend resources. This lack of isolation makes security auditing exceptionally difficult. To guarantee a simple property—such as "User A cannot access User B's data"—a reviewer must theoretically audit the entire codebase, as a single vulnerability anywhere could be leveraged to bypass security checks.

Furthermore, traditional frameworks lack strict language-level isolation between users, leaving applications vulnerable to common threats like cross-site scripting (XSS), cross-site request forgery (CSRF), and unintended data leaks. This paper proposes Capsules, a web framework designed to enforce fine-grained privilege separation through architectural constraints.

The Capsules Framework

The Capsules framework, built atop the Java Servlet API, introduces a security model based on object-capability (o-cap) principles. It relies on Joe-E, a security-oriented subset of Java that eliminates "unsafe" features like mutable static fields and reflection. In this model, an object can only interact with another if it holds an explicit reference (a "capability") to it.

The Capsules architecture stack, showing isolated servlets managed by a dispatcher above Tomcat and the JVM.

As shown in Figure 1, the architecture places a Dispatcher between the servlets and the underlying container. This dispatcher is responsible for providing Restricted Views to each component. Instead of granting every servlet full access to the HTTPSession, developers specify exactly which session variables or cookies a servlet requires. The framework then generates wrapper classes that expose only those specific fields, adhering to the principle of least privilege.

Isolation and Reviewability

A core goal of Capsules is to make security properties humanly reviewable. By partitioning the application into isolated domains, the framework limits the scope of any potential audit. If only a specific DeleteServlet has the capability to modify the filesystem, a reviewer only needs to look at that one component to verify the integrity of the system.

Isolation domains in a webmail application, showing how users and bridge objects are separated.

Figure 5 illustrates how isolation is maintained in a multi-user environment. Each user's data (e.g., Alice, Bob, Carol) resides in a separate domain. Interaction between these domains occurs only through well-defined bridge objects, such as the Authentication capability or the Mail Transfer Agent (MTA). By focusing audit efforts on these critical bridges, developers can reason about the security of the entire system without needing to verify every line of application code.

The framework also provides automated defenses. It mandates a restricted DOM API for HTML generation to prevent XSS caused by raw string concatenation and automatically manages CSRF tokens for all forms.

Evaluation and Results

The authors evaluated Capsules by implementing a functional webmail application featuring account management and email operations. Performance microbenchmarks were conducted on a 2.26 GHz Pentium 4 system to measure the overhead of these security guarantees.

The results highlighted a trade-off between security and performance:

  • Throughput: The webmail application experienced a roughly 20% throughput penalty compared to standard Java servlets when listing 1000 emails.
  • Latency: The use of the DOM API for "correct-by-construction" XSS prevention nearly doubled latency and halved throughput for page generation.
  • Memory: Each session introduced approximately 2.0 KB of overhead, which is considered a manageable cost for modern hardware.

Conclusion and Future Work

Capsules demonstrates that fine-grained privilege separation is a viable path toward more secure and reviewable web applications. However, several challenges remain. Integrating SQL databases while maintaining least-privilege row-level access is an open problem. Additionally, the "taming" of standard Java libraries—wrapping them to prevent capability leaks—requires significant manual effort. Future work will also focus on improving the developer experience, perhaps by adapting safe templating languages to replace the more verbose DOM API.

Summary updated

BibTeX
@inproceedings{krishnamurthy2010fine,
  author = {Akshay Krishnamurthy and Adrian Mettler and David A. Wagner},
  title = {{Fine-grained privilege separation for web applications}},
  booktitle = {The Web Conference},
  year = {2010},
  url = {https://openreview.net/forum?id=BJbc5eW_br},
}
Figure