dibollinger / CookieBlock

Repository for the CookieBlock browser extension, which automatically enforces user privacy policy on browser cookies.
MIT License
200 stars 18 forks source link
addon addons browser-cookies cookies extension gdpr privacy

CookieBlock Browser Extension

CookieBlock is a browser extension that automatically enforces your GDPR consent preferences for browser cookies. It classifies cookies on-the-fly into four distinct categories, and deletes those that the user did not consent to.

This helps enforce user privacy without having to rely on the website hosting the cookies.

Table of Contents

Description

CookieBlock is an extension that allows the user to apply their cookie consent preferences to any website, no matter if the website has a cookie banner. The user specifies their consent options once when the extension is first installed, and then CookieBlock will try to remove any cookies that do not align with the user's policy as they are being created.

This is intended to ensure that the privacy of the user is preserved. One can reject any of the following categories:

Note that CookieBlock does not handle the cookie banner itself. In order to remove these annoying banners, we recommend using the Consent-O-Matic extension:

Download Links

CookieBlock is compatible with both Firefox and Chromium-based browsers, and it is available on the following addon stores:

Feedback

If you would like to submit feedback, or report websites that break because of the addon, you can open an issue on this Github page, or alternatively use this Google Forms document.

Build Instructions

No requirements outside of what is contained in this repository is needed to build CookieBlock. Simply pack the contents of the subfolder src into a zip file, and you can install it into your browser. More information here.

Alternatively, you can also install npm and use the web-ext command-line tool, with the command web-ext build.

Reproducing the Model Files

The model files are constructed in the following process:

  1. Run a webcrawler to collect browser cookies and categories from Consent Management Providers. The relevant code is found here.
  2. Extract from the resulting database the training cookies, in JSON format. The script for this is found here.
  3. Use the feature extractor in this repository to transform the cookies JSON into a sparse LibSVM matrix representation.
  4. Provide this LibSVM with the associated class weights as input to the XGBoost classifier implementation (xgb_train.py) found in this repository.
  5. Execute a secondary Python script (xgboost_small_dump.py) to transform the XGBoost model into a minified JSON tree structure. This script produces the four model files forest_class0.json to forest_class3.json.
  6. Copy these files into the folder:
    ./src/ext_data/model/

    And replace the existing forest class files. Make sure to preserve their names as is.

How It Works

The policy enforcement process is a background script that executes every time a cookie event is raised in the browser. If this event indicates that a cookie was added or updated, the extension will store the cookie in a local history of cookie updates, and then perform a classification for that cookie.

The category for each cookie is predicted using a forest of decision trees model trained via the XGBoost classifier, and a set of feature extraction steps. First, the cookie is turned into a numerical vector, which is then provided as an input to the forest of trees. This produces a score for each class, and the best score is the class that gets assigned to the cookie.

Available cookie categories are:

Granularity is intentionally kept low to make the decision as simple as possible for the user. Note that "strictly necessary" cookies cannot be rejected, as this is the class of cookies that is required to make the website work. Without them, essential services such as logins would stop working.

The feature extractor can be found in the subfolder nodejs-feature-extractor/. This is used to extract the features for the training data set.

For the classifier training, see:

https://github.com/dibollinger/CookieBlock-Consent-Classifier

Known Issues

The classifier is not completely accurate. It may occur that certain functions on some sites are broken because essential cookies get misclassified. This is hard to resolve without gathering more cookie data to train on. As such, the approach has its limits.

To resolve these problems, we maintain a list of known cookie categories. This is a JSON file storing cookie labels for known cookie identifiers. If a cookie is contained in this file. the prediction is skipped, and the known class is applied.

By reporting broken websites, you can help us keep an updated list of cookie exceptions. This makes the extension more useable for everyone while also keeping a high level of privacy.

Repository Contents

Credits

Libraries

CookieBlock includes code from the following libraries and projects:

Thesis

This repository was created as part of the master thesis "Analyzing Cookies Compliance with the GDPR", which can be found at:

https://www.research-collection.ethz.ch/handle/20.500.11850/477333

as well as the paper "Automating Cookie Consent and GDPR Violation Detection", which can be found at:

https://karelkubicek.github.io/post/cookieblock.html

Thesis Supervision and co-authors:

See also the following repositories for other components that were developed as part of the thesis:

License

Copyright © 2021-2022 Dino Bollinger, Department of Computer Science at ETH Zürich, Information Security Group

MIT License, see included LICENSE file