Abstract: Third-party scripts are ubiquitous in modern web development but pose significant security risks due to the "all-or-nothing" privilege model of the browser. Current defenses, such as Content Security Policy (CSP) or JavaScript-layer monitors, often fail to balance functionality with security or introduce significant performance overhead. This paper presents ScriptChecker, a framework implemented in Chromium that shifts security enforcement to the browser’s task scheduler and internal security monitors. By assigning specific "capabilities" to execution tasks and isolating risky scripts in a sandbox context, ScriptChecker provides robust protection against environment poisoning and confused deputy attacks with minimal performance impact.
1. Introduction
Third-party scripts, such as analytics, ad trackers, and utility libraries, are present on over 88% of websites. However, because these scripts are co-located in the same frame as the host script, they inherit the host’s full privileges. This lack of isolation allows a malicious or compromised script to steal cookies, scrape sensitive form data, or perform unauthorized actions.
Existing solutions generally fall into two categories: coarse-grained policies (like CSP or iframes) which often break functionality, and JavaScript-layer monitors (using filters or proxies). The latter are notoriously slow, difficult to maintain, and vulnerable to Environment Poisoning (modifying built-in JS objects) or Confused Deputy Attacks (tricking a trusted script into performing a malicious action).
2. The ScriptChecker Framework
Presented at NDSS 2022, ScriptChecker shifts the security boundary from the JavaScript engine to the browser's task scheduler and security monitors. The approach relies on three primary pillars:
- Sandbox Context: ScriptChecker introduces a "sandbox context" for risky scripts. While it has access to full JS APIs, it is separated from the host’s environment, preventing malicious scripts from tampering with host variables or functions.
- Task Capabilities: Instead of identifying which script is running, ScriptChecker assigns a "capability" (a set of permissions) to the task—the primitive unit of execution scheduling in the browser.
- Asynchronous Execution: Host scripts invoke third-party functions using new asynchronous APIs (e.g.,
asynCallCap), which spin off new tasks with tailored capabilities enforced by the browser’s internal C++ security monitors.
3. Key Insights and Isolation Model
ScriptChecker's most significant innovation is treating the task as the subject of access control. Since tasks are the unit of scheduling, the browser always knows exactly which task is executing, making it impossible for a script to "hide" its identity. This provides immunity to confused deputy attacks; even if a task executes trusted host code, it remains bound by the restricted capability assigned to that specific task.
Furthermore, the framework implements One-Way Isolation. The host can see and interact with the third-party script's objects, but the third-party script cannot see the host's objects unless they are explicitly whitelisted, effectively neutralizing environment poisoning attempts.
4. Evaluation and Results
The researchers evaluated ScriptChecker using a dataset of 1,373 malicious scripts and an empirical study of the top 1,000 Alexa sites. Key findings include:
- Security: ScriptChecker successfully blocked 100% of illegal accesses in the malicious script dataset, including complex confused deputy attacks.
- Performance: The overhead is remarkably low, with DOM access mediation taking only 0.2 microseconds. Loading popular JS libraries (e.g., Three.js, Lodash) saw a negligible delay of approximately 5%.
- Host Impact: The impact on host script performance (code not involving third-party scripts) was minimal, with a drop of only 0.1% to 0.4%.
5. Conclusion and Future Work
ScriptChecker provides a high-performance, "watertight" protection mechanism for third-party script execution. While it requires developer effort to tag risky scripts and use new APIs, it offers a significant security upgrade over existing JS-layer monitors. Future work includes addressing Discretionary Access Control (DAC) limitations—where a host might voluntarily share data with a risky script—by potentially integrating Information Flow Checking (IFC).
Summary updated