1 From 10873c626d038b520853539d45a170919d6d0361 Mon Sep 17 00:00:00 2001
2 From: Mike Perry <mikeperry-git@torproject.org>
3 Date: Wed, 1 Feb 2012 15:50:15 -0800
4 Subject: [PATCH 07/13] Block all plugins except flash.
6 We cannot use the @mozilla.org/extensions/blocklist;1 service, because we
7 actually want to stop plugins from ever entering the browser's process space
8 and/or executing code (for example, AV plugins that collect statistics/analyse
9 urls, magical toolbars that phone home or "help" the user, skype buttons that
10 ruin our day, and censorship filters). Hence we rolled our own.
12 See https://trac.torproject.org/projects/tor/ticket/3547#comment:6 for musings
13 on a better way. Until then, it is delta-darwinism for us.
15 dom/plugins/base/nsPluginHost.cpp | 33 +++++++++++++++++++++++++++++++++
16 dom/plugins/base/nsPluginHost.h | 2 ++
17 2 files changed, 35 insertions(+), 0 deletions(-)
19 diff --git a/dom/plugins/base/nsPluginHost.cpp b/dom/plugins/base/nsPluginHost.cpp
20 index 7fe18b2..d76c4ca 100644
21 --- a/dom/plugins/base/nsPluginHost.cpp
22 +++ b/dom/plugins/base/nsPluginHost.cpp
23 @@ -1982,6 +1982,35 @@ bool nsPluginHost::IsDuplicatePlugin(nsPluginTag * aPluginTag)
27 +PRBool nsPluginHost::GhettoBlacklist(nsIFile *pluginFile)
30 + const char *leafStr;
33 + rv = pluginFile->GetNativeLeafName(leaf);
34 + if (NS_FAILED(rv)) {
35 + return PR_TRUE; // fuck 'em. blacklist.
38 + leafStr = leaf.get();
41 + return PR_TRUE; // fuck 'em. blacklist.
44 + // libgnashplugin.so, libflashplayer.so, Flash Player-10.4-10.5.plugin,
45 + // NPSWF32.dll, NPSWF64.dll
46 + if (strstr(leafStr, "libgnashplugin") == leafStr ||
47 + strstr(leafStr, "libflashplayer") == leafStr ||
48 + strstr(leafStr, "Flash Player") == leafStr ||
49 + strstr(leafStr, "NPSWF") == leafStr) {
53 + return PR_TRUE; // fuck 'em. blacklist.
56 typedef NS_NPAPIPLUGIN_CALLBACK(char *, NP_GETMIMEDESCRIPTION)(void);
58 nsresult nsPluginHost::ScanPluginsDirectory(nsIFile *pluginsDir,
59 @@ -2103,6 +2132,10 @@ nsresult nsPluginHost::ScanPluginsDirectory(nsIFile *pluginsDir,
63 + if (GhettoBlacklist(localfile)) {
67 // if it is not found in cache info list or has been changed, create a new one
69 nsPluginFile pluginFile(localfile);
70 diff --git a/dom/plugins/base/nsPluginHost.h b/dom/plugins/base/nsPluginHost.h
71 index 5630b8d..f54bd32 100644
72 --- a/dom/plugins/base/nsPluginHost.h
73 +++ b/dom/plugins/base/nsPluginHost.h
74 @@ -285,6 +285,8 @@ private:
75 // Loads all cached plugins info into mCachedPlugins
76 nsresult ReadPluginInfo();
78 + PRBool GhettoBlacklist(nsIFile *pluginFile);
80 // Given a file path, returns the plugins info from our cache
81 // and removes it from the cache.
82 void RemoveCachedPluginsInfo(const char *filePath,