Abstract
This paper presents a method for securing Ajax applications by employing static analysis to construct a "request graph" of legitimate client-to-server call sequences. By deploying this graph within a server-side proxy, the system automatically blocks malicious requests, such as XSS or CSRF, that deviate from expected behavior. To defend against mimicry attacks, the system injects randomized dummy requests into the client code, ensuring that only requests following the specific mutated logic are accepted. Evaluation on real-world applications demonstrates the system's effectiveness in vulnerability discovery and attack prevention with minimal runtime overhead.
Introduction
Modern Ajax (Asynchronous JavaScript and XML) applications present a significant security challenge. Unlike traditional web applications where the server dictates the workflow through sequential page transitions, Ajax applications expose a complex API of URLs that client-side JavaScript can invoke at any time. This flexibility allows malicious users to bypass the intended user interface and call endpoints in arbitrary orders or with malicious arguments. Traditional intrusion detection systems (IDS) often struggle with the event-driven, non-deterministic nature of these applications, where network latency can cause requests to arrive at the server out of order.
Methodology
The proposed solution bridges the gap between client-side code behavior and server-side security enforcement through a multi-step pipeline. The core of this approach is the construction of a Request Graph using static control-flow analysis (CFA).
Request Graph Construction
The system uses a $k$-CFA algorithm to analyze JavaScript and HTML, tracking higher-order functions and callbacks. This analysis is then transformed into a Request Graph that models all valid sequences of HTTP requests.
To accurately model the asynchronous nature of Ajax, the graph utilizes specialized node types:
- And nodes: Represent asynchronous requests that can arrive at the server in any order.
- Or nodes: Represent conditional branches in the application logic.
- Repeatable nodes: Model event handlers, such as button clicks, that a user can trigger multiple times.
The formal grammar for these nodes is defined to ensure the proxy can precisely track the application state:
Enforcement and Security
- Capability Tracking: The system automatically identifies "capabilities"—values like session IDs that the server sends in a response and the client must include in subsequent requests—to ensure state integrity.
- Intrusion-Prevention Proxy: A reverse proxy sits in front of the web server and tracks the state of each client session on the request graph. Requests that do not constitute a valid next step in the graph are blocked.
- Randomized Guard Requests: To prevent "mimicry attacks" (where an attacker follows a valid path for a malicious purpose), the tool mutates client code to inject random, asynchronous "guard" requests. The proxy expects these specific dummy requests; an attacker who has not analyzed the mutated code will fail to provide them, thus pruning the valid state space for attackers.
Evaluation and Results
The tool was evaluated on a mix of academic and real-world targets, including student blogs, multi-page Ajax applications (Continue & Resume), AjaxIM, and Google Web Toolkit (GWT) samples.
- Vulnerability Discovery: While testing AjaxIM, the tool discovered a previously unknown XSS vulnerability that allowed administrative privilege escalation. The request graph successfully blocked the attack.
- Effectiveness: The system successfully detected and blocked injected XSS and CSRF attacks across all test applications.
- Performance: Analysis time ranged from 28 seconds to 45 minutes, depending on application complexity. Crucially, the runtime overhead added by the proxy was less than 0.5 seconds of latency, which is negligible for most web interactions.
- Scalability: The tool successfully handled applications up to 10,000 lines of code, including complex machine-generated JavaScript from GWT.
Conclusion
By modeling the server's perspective of legitimate client-side interactions, this static analysis approach provides a robust defense against common web vulnerabilities in Ajax environments. While the tool faces challenges with highly dynamic code generation (e.g., eval()) and precise DOM modeling, it offers a significant improvement over traditional IDS. Future work will focus on "call-signing" to improve session state scalability and expanding support for diverse data formats like XML.
Summary updated