CookieGraph: Understanding and Detecting First-Party Tracking Cookies

Shaoor Munir, Sandra Deepthy Siby, Umar Iqbal, Steven Englehardt, Zubair Shafiq, Carmela Troncoso

TL;DR

As third-party cookies are blocked, trackers are increasingly using first-party cookies for cross-site tracking. This paper introduces CookieGraph, a novel machine learning approach that accurately detects and blocks these first-party tracking cookies without causing significant website breakage, outperforming existing methods.

What Problem Does This Paper Address?

The widespread blocking of third-party cookies by major browsers has led to a shift in tracking strategies. Advertisers and trackers are now leveraging first-party cookies, which are set by the website a user is directly visiting, to continue tracking user activity. While blocking first-party cookies entirely is not feasible due to their essential role in website functionality (e.g., maintaining login sessions), existing methods for detecting and blocking first-party tracking cookies are either prone to false positives (causing breakage) or easily evaded. This paper addresses the critical need for a robust and accurate solution to identify and mitigate first-party tracking without disrupting user experience.

Methods

The authors developed CookieGraph, a graph-based machine learning approach. The core idea is to represent a webpage's execution as a graph, where nodes represent elements like HTML, network requests, scripts, and storage (cookies and localStorage). Edges capture interactions between these elements.

Key aspects of the CookieGraph method include:

  • Graph Construction: It models interactions such as scripts setting cookies, reading from storage, and exfiltrating/infiltrating data via network requests. It specifically focuses on how first-party cookies are used for tracking.
  • Feature Extraction: CookieGraph extracts two types of features:
  • Structural Features: Relationships between nodes, like how many scripts interact with a cookie.
  • Flow Features: These capture actual tracking behaviors, such as the number of times a cookie is exfiltrated or set, and whether the cookie setter is involved in redirect chains.
  • Machine Learning Classifier: A random forest classifier is trained on these features to distinguish between first-party tracking (ATS) cookies and non-tracking cookies.
  • Robustness: Crucially, CookieGraph avoids using content-based features like cookie names, which are easily manipulated by trackers. Instead, it relies on behavioral patterns captured in the graph.

Datasets

  • Measurement Study: A dataset of 20,000 websites from the Tranco top-million list was used for differential measurement studies (comparing third-party cookies enabled vs. blocked).
  • Training and Evaluation: A carefully labeled dataset of first-party cookie-domain pairs was constructed. This dataset was derived from a 20% sample of the top-million websites (approximately 20,000 sites). The ground truth labeling involved using filter lists (EasyList, EasyPrivacy) and Cookiepedia, with a conservative approach to minimize false positives.
  • Deployment Data: The final CookieGraph model was deployed on a 20% sample of the top-million websites (approximately 20,000 sites) to measure the prevalence of first-party tracking cookies.

Key Insights and Ideas

  • Third-party cookie blocking is insufficient: The study demonstrates that blocking third-party cookies has a minimal impact on the exfiltration of identifiers to trackers, as they have already shifted to using first-party cookies.
  • First-party cookies are the new frontier for tracking: A significant majority (89.86%) of top websites use first-party tracking cookies, often set by third-party scripts embedded in the first-party context.
  • Ghostwriting is prevalent: A staggering 96.61% of these first-party tracking cookies are "ghostwritten" by third-party scripts, meaning trackers are actively setting and controlling them.
  • Fingerprinting is a key enabler: The research found evidence that fingerprinting scripts are also setting first-party tracking cookies, further complicating tracking detection.
  • Major players are involved: Top advertising entities like Google, Facebook, and TikTok are among the most prevalent setters of first-party tracking cookies.
  • Breakage is a major concern with existing solutions: Blanket blocking of first-party cookies causes significant breakage on a large percentage of websites, and even specialized tools like CookieBlock have limitations in this regard.

Key Results

  • Detection Accuracy: CookieGraph achieves 90.18% accuracy, outperforming the state-of-the-art CookieBlock by 17.31%.
  • Website Breakage: CookieGraph causes no major breakage on tested sites, a significant improvement over CookieBlock (10% breakage on sites with SSO logins) and WebGraph.
  • Robustness: CookieGraph is robust against cookie name manipulation, with its accuracy degrading by only 2% when flow features are removed, whereas CookieBlock's accuracy drops by 15.87%.
  • Prevalence: CookieGraph detected first-party tracking cookies on 89.86% of the top-million websites analyzed.
  • Ghostwriting: 96.61% of first-party tracking cookies were found to be ghostwritten by third-party scripts.

Limitations and Future Work

  • Completeness of Graph Representation: The detection of ATS cookies depends on the intensity and variety of user activity during webpage execution. Insufficient activity might lead to missed cookies. The authors suggest that more comprehensive crawling or user interaction could improve detection.
  • Deployment Overhead: CookieGraph's current implementation has performance overheads that make it unsuitable for real-time runtime deployment. The authors propose using it offline to generate blocklists for privacy-enhancing browser extensions.
  • Future Work: The authors suggest further research into efficient and effective online implementations of CookieGraph and improving the ground truth labeling process. They also note that while their approach is robust to name manipulation, it could be further enhanced against evasion techniques targeting encoding schemes or domain changes.

Summary updated

BibTeX
@inproceedings{munir2023cookiegraph,
  author = {Shaoor Munir and Sandra Deepthy Siby and Umar Iqbal and Steven Englehardt and Zubair Shafiq and Carmela Troncoso},
  title = {{CookieGraph: Understanding and Detecting First-Party Tracking Cookies}},
  booktitle = {CCS},
  year = {2023},
  doi = {10.1145/3576915.3616586},
}
Figure