Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 1549: Return constant results for navigator.plugins and navigator.mimeTypes #697

Merged
merged 1 commit into from
Nov 21, 2018

Conversation

jumde
Copy link
Contributor

@jumde jumde commented Oct 18, 2018

fixes brave/brave-browser#1549

Description

From: brave/brave-browser#1549 (comment) - navigator.plugins and navigator.mimeTypes will return an empty array until Flash is installed and explicitly enabled. navigator.plugins and navigator.mimeTypes will return an empty array in tor mode.

Submitter Checklist:

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Verified that these changes build without errors on
    • Windows
    • macOS
    • Linux
  • Verified that these changes pass automated tests (npm test brave_unit_tests && npm test brave_browser_tests) on
    • Windows
    • macOS
    • Linux
  • Ran git rebase master (if needed).
  • Ran git rebase -i to squash commits (if needed).
  • Tagged reviewers and labelled the pull request as needed.
  • Request a security/privacy review as needed.
  • Add appropriate QA labels (QA/Yes or QA/No) to include the closed issue in milestone

Test Plan:

Without flash:

>navigator.mimeTypes
MimeTypeArray {length: 0}

>navigator.plugins
PluginArray {length: 0}

With Flash:

  1. Install flash player: https://get.adobe.com/flashplayer/
  2. Navigate to isflashinstalled.com and enable flash for the site.
  3. The site will be reloaded and the output of the site should say Yes.
navigator.plugins
PluginArray {0: Plugin, Shockwave Flash: Plugin, length: 1}

navigator.mimeTypes
MimeTypeArray {0: MimeType, 1: MimeType, application/x-shockwave-flash: MimeType, application/futuresplash: MimeType, length: 2}

Verify that navigator.plugins and navigator.mimeTypes return empty arrays in tor mode.

Reviewer Checklist:

  • New files have MPL-2.0 license header.
  • Request a security/privacy review as needed.
  • Adequate test coverage exists to prevent regressions
  • Verify test plan is specified in PR before merging to source

@jumde jumde self-assigned this Oct 18, 2018
@jumde jumde force-pushed the mimetypes_fingerprinting branch 2 times, most recently from b515e1b to 6be3441 Compare October 29, 2018 20:17
@@ -0,0 +1,5 @@
<script>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test works since flash is explicitly disabled by default

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we test to make sure it does show up when it is enabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jumde jumde force-pushed the mimetypes_fingerprinting branch 3 times, most recently from 1e390a8 to 2e9acc2 Compare November 1, 2018 08:51
Vector<mojom::blink::PluginInfoPtr> plugins;
registry->GetPlugins(false, main_frame_origin_, &plugins);
for (const auto& plugin : plugins) {
+ if (plugin->name != "Shockwave Flash") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if i understand correctly, this will never add any plugins to navigator.plugins/mimeTypes unless it is the Flash plugin. but the behavior we want is:

  1. if flash is not enabled for the site via click-to-play, navigator.plugins/mimeTypes is empty
  2. if flash is enabled, navigator.plugins/mimeTypes only shows Flash

i will update https://github.com/brave/brave-browser/wiki/Fingerprinting-Protection-Mode#privacy-protection-enabled-regardless-of-whether-fingerprinting-protection-mode-is-on to be more clear about this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@diracdeltas - GetPlugins does not return the flash plugin if its not enabled via click-to-play. If flash is not enabled via click-to-play, navigator.plugins/mimeTypes will return empty.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jumde right, i'm saying that GetPlugins should return flash when it's enabled via click to play, which i don't think happens with this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved after offline conversation.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to implement this by subclassing PluginRegistryImpl and doing a chromium_src override to replace it in RenderProcessHostImpl

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then we can filter it out in PluginRegistryImpl::GetPlugins without affecting the actual PluginList used by the browser process

@diracdeltas
Copy link
Member

PJ showed me the behavior of this PR in-person and it lgtm. defer on code approval.

@jumde jumde requested review from bridiver and removed request for yrliou November 13, 2018 23:56
@jumde
Copy link
Contributor Author

jumde commented Nov 13, 2018

Updating reviewer from @yrliou to @bridiver after discussion with @yrliou since @bridiver reviewed the recent navigator PRs.

@jumde jumde force-pushed the mimetypes_fingerprinting branch 9 times, most recently from 21d7eea to f813bb8 Compare November 19, 2018 18:35

for(std::vector<blink::mojom::PluginInfoPtr>::iterator it = plugins.begin();
it != plugins.end(); ++it) {
if ((*it) && (*it)->name == base::ASCIIToUTF16("Shockwave Flash")) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

content::kFlashPluginName for "Shockwave Flash"

GetPluginsCallback callback) {
PluginRegistryImpl::GetPlugins(refresh, main_frame_origin,
base::BindOnce(
&BravePluginRegistryImpl::GetPluginsComplete, base::Unretained(this),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you must use weak ptr here just like the superclass

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually this should be handled because the lifetime issue is already covered by the superclass WeakPtr in the original callback.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the embedded callback will be called synchronously so no lifetime issues at that point

Copy link
Collaborator

@bridiver bridiver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comments


#include "brave/content/browser/renderer_host/brave_plugin_registry_impl.h"

#define PluginRegistryImpl BravePluginRegistryImpl
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you are overriding a class like this, you should always include the header for the class you are overriding before redefining it. Otherwise it's possible that it won't already be defined at this point and you'll change the original header file (likely resulting in a build failure)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it gets added from brave_plugin_registry_impl.h, but better to be explicit and make sure there are no issues

@jumde jumde force-pushed the mimetypes_fingerprinting branch 2 times, most recently from 7ac9edd to 2845757 Compare November 20, 2018 21:39
@petemill
Copy link
Member

Note that this introduced a build error on master as described in brave/brave-browser#2222. It's fixed by #952 which I've merged since it solves the issue. Please check it out and see if it's the preferred fix. If not, perhaps create a follow-up...

@bbondy
Copy link
Member

bbondy commented Nov 26, 2018

was this tested with Widevine?

@jumde
Copy link
Contributor Author

jumde commented Nov 26, 2018

was this tested with Widevine?

Yes! For detecting widevine web-authors use navigator.requestMediaKeySystemAccess instead of navigator.plugins or navigator.mimeTypes

@jumde
Copy link
Contributor Author

jumde commented Nov 26, 2018

Note that this introduced a build error on master as described in brave/brave-browser#2222. It's fixed by #952 which I've merged since it solves the issue. Please check it out and see if it's the preferred fix. If not, perhaps create a follow-up...

I was trying a different patch that addresses this issue: https://github.com/brave/brave-core/compare/fixes_2222?expand=1. Was testing this on windows to see if linker errors were resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants