Skip to content

Commit

Permalink
Disable the kNavigatorPluginsFixed feature to use Brave's farbling code
Browse files Browse the repository at this point in the history
The CL below made a change to make fingerprinting more difficult in
Chromium without breaking existing sites by returning a fixed list
of PDF plugins, regardless of the actual ones available, which broke
our farbling of the navigator.plugins array.

Since farbling in Brave works in a different way (i.e. differently
depending on the selected "farbling level"), we're just disabling this
runtime feature to get back to the original code we had before, which
would make sure the actual list of plugins is only returned if the
used has explicitly disabled fingerprinting protections, otherwise
a farbled, randomly generated and always different list of plugins
will be returned (which is better than a fixed list anyway).

Last, we add some new chromium_src overrides here to avoid the need
of a C++ patch to disable this runtime feature via WebRuntimeFeatures.

Chromium change:

https://chromium.googlesource.com/chromium/src/+/fb96360c18b517bcc487c0de7235eec27e3adf5e

commit fb96360c18b517bcc487c0de7235eec27e3adf5e
Author: Mason Freed <masonf@chromium.org>
Date:   Fri Aug 6 20:20:17 2021 +0000

    Hard-code the list of plugins and mimetypes in navigator

    See [1] for a previous attempt to completely empty the navigator.plugins
    and navigator.mimeTypes APIs. That caused site breakage due to sites
    scanning for a PDF reader. This new attempt is discussed in significant
    detail in [2], and involves the hard-coding of a list of PDF viewers and
    mime types.

    The plugins/mimetypes lists will be empty if the user setting to
    download PDFs instead of viewing them
    (chrome://settings/content/pdfDocuments) is enabled. This is to ensure
    compat with sites that scan the plugins list for specific PDF plugins
    to decide on behavior. Prior to this CL, when the PDF viewer is
    disabled, the PDF viewer plugins are unloaded.

    Tests were copied mostly verbatim from [3], thanks @domenic.

    I2S:
    https://groups.google.com/a/chromium.org/g/blink-dev/c/bbxAGu90LgM

    [1] https://chromium-review.googlesource.com/c/chromium/src/+/2783393
    [2] whatwg/html#6738
    [3] web-platform-tests/wpt#29559

    Bug: 1164635
  • Loading branch information
mariospr committed Sep 2, 2021
1 parent b543bf1 commit 3f2d6a8
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
16 changes: 14 additions & 2 deletions chromium_src/content/child/runtime_features.cc
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
#define SetRuntimeFeaturesDefaultsAndUpdateFromArgs SetRuntimeFeaturesDefaultsAndUpdateFromArgs_ChromiumImpl
/* Copyright (c) 2018 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#define SetRuntimeFeaturesDefaultsAndUpdateFromArgs \
SetRuntimeFeaturesDefaultsAndUpdateFromArgs_ChromiumImpl

#include "../../../../content/child/runtime_features.cc"

#undef SetRuntimeFeaturesDefaultsAndUpdateFromArgs

namespace content {

void SetRuntimeFeaturesDefaultsAndUpdateFromArgs(
const base::CommandLine& command_line) {
SetRuntimeFeaturesDefaultsAndUpdateFromArgs_ChromiumImpl(command_line);

// Brave will use its own mechanism for farbling the actual list of plugins
// returned by navigator.plugins depending on the selected BraveFarblingLevel.
WebRuntimeFeatures::EnableNavigatorPluginsFixed(false);
}

} // namespace content
} // namespace content
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* Copyright (c) 2021 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef BRAVE_CHROMIUM_SRC_THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_RUNTIME_FEATURES_H_
#define BRAVE_CHROMIUM_SRC_THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_RUNTIME_FEATURES_H_

#define EnableCLSScrollAnchoring \
EnableCLSScrollAnchoring(bool); \
BLINK_PLATFORM_EXPORT static void EnableNavigatorPluginsFixed

#include "../../../../../../third_party/blink/public/platform/web_runtime_features.h"

#undef EnableCLSScrollAnchoring

#endif // BRAVE_CHROMIUM_SRC_THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_RUNTIME_FEATURES_H_
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* Copyright (c) 2021 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "../../../../../../../third_party/blink/renderer/platform/exported/web_runtime_features.cc"

namespace blink {

void WebRuntimeFeatures::EnableNavigatorPluginsFixed(bool enable) {
RuntimeEnabledFeatures::SetNavigatorPluginsFixedEnabled(enable);
}

} // namespace blink

0 comments on commit 3f2d6a8

Please sign in to comment.