Introduction
As web development has matured, the delivery of JavaScript has shifted from individual, discrete scripts to massive, consolidated "bundles." While bundling improves performance by reducing HTTP requests, it has inadvertently created a significant blind spot for privacy tools. Traditional content blockers, which rely on URL-based filtering to stop trackers (e.g., blocking tracker.com/collect.js), are ineffective when tracking logic is embedded directly into a first-party bundle like app.js. This research introduces URR (Unbundle-Rewrite-Rebundle), a system designed to detect and neutralize privacy-harming code within these bundles at runtime without disrupting site functionality.
The Challenge of Bundled JavaScript
Modern build tools like Webpack and Rollup combine dozens of libraries—ranging from essential UI frameworks to invasive fingerprinters—into a single file. This creates an "all-or-nothing" dilemma for privacy-conscious users:
- Blocking the bundle prevents tracking but breaks the website's core features.
- Allowing the bundle protects functionality but permits unchecked data collection.
Because the tracking code is served from the same domain as the website, URL-based filters cannot distinguish between the "good" and "bad" code inside the file. URR addresses this by performing surgical intervention on the JavaScript source code after it is downloaded but before the browser executes it.
The URR Methodology
URR is implemented as a browser extension that intercepts script loading. It follows a four-stage pipeline to identify and replace malicious modules:
1. Module Extraction
The system parses incoming JavaScript into an Abstract Syntax Tree (AST). By analyzing the boilerplate code used by bundlers (like Webpack's module loader), URR identifies the boundaries of individual modules within the larger file.
2. Structural Hashing
To combat minification—where variable names are obfuscated into random characters—URR ignores identifiers and focuses on the code's underlying logic. It uses a Merkle-tree-based hashing algorithm to create a signature based on the types and arrangement of AST nodes. This ensures that even if a developer renames every variable in a tracking library, its structural signature remains recognizable.
3. Signature Matching
These structural signatures are compared against a database of known privacy-harming libraries, such as FingerprintJS, Sentry, and Prebid. The authors found that a similarity threshold as low as 8% is often sufficient to identify a library while maintaining high accuracy.
4. Shimming and Rebundling
Simply deleting a module would likely cause the rest of the bundle to crash due to missing dependencies. Instead, URR replaces the flagged module with a "shim"—a benign piece of code that mimics the original library's API. This allows the rest of the application to function normally, unaware that the tracking component has been neutralized. Finally, the modified modules are rebundled and executed.
Evaluation and Real-World Impact
The researchers evaluated URR using the Tranco 10k dataset and a custom crawl of over 30,000 scripts. Key findings include:
- High Precision: The system achieved a 1.00 precision (zero false positives) and 0.95 recall in identifying target libraries within real-world bundles.
- Enhanced Coverage: URR identified tracking libraries on 7% of the top 10,000 websites that were completely missed by traditional URL-based blockers.
- Performance Trade-offs: The process adds approximately 0.43 seconds of latency per script and increases the time to "DOM Interactive" by about 0.5 seconds. While this is a measurable delay, it represents a functional trade-off for users prioritizing privacy.
- Scalability: The "shim" approach proved highly robust; a single shim for the Sentry library was compatible with over 335 different minor versions of the software.
Conclusion and Future Directions
URR demonstrates that surgical, runtime code modification is a viable path forward for web privacy. By moving beyond URL filtering to structural analysis, privacy tools can keep pace with modern development practices.
Future work aims to automate the creation of shims, which currently require manual expert intervention, and to expand support for a wider variety of bundlers beyond Webpack. Additionally, as developers may attempt to use more aggressive obfuscation to alter AST structures, the arms race between tracking and privacy-preserving technology will likely move into the realm of structural logic manipulation.
Summary updated