summaryrefslogtreecommitdiff
blob: 2cfa7ba2bb0446724e487d6797b817ded241c888 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
From 47235106c9e1257c66bab774aab330be4dabcfb0 Mon Sep 17 00:00:00 2001
From: Mike Perry <mikeperry-git@torproject.org>
Date: Wed, 1 Feb 2012 15:50:15 -0800
Subject: [PATCH 05/20] Block all plugins except flash.

We cannot use the @mozilla.org/extensions/blocklist;1 service, because we
actually want to stop plugins from ever entering the browser's process space
and/or executing code (for example, AV plugins that collect statistics/analyse
urls, magical toolbars that phone home or "help" the user, skype buttons that
ruin our day, and censorship filters). Hence we rolled our own.

See https://trac.torproject.org/projects/tor/ticket/3547#comment:6 for musings
on a better way. Until then, it is delta-darwinism for us.
---
 dom/plugins/base/nsPluginHost.cpp |   33 +++++++++++++++++++++++++++++++++
 dom/plugins/base/nsPluginHost.h   |    2 ++
 2 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/dom/plugins/base/nsPluginHost.cpp b/dom/plugins/base/nsPluginHost.cpp
index 0c3efa0..e607e68 100644
--- a/dom/plugins/base/nsPluginHost.cpp
+++ b/dom/plugins/base/nsPluginHost.cpp
@@ -2002,6 +2002,35 @@ bool nsPluginHost::IsDuplicatePlugin(nsPluginTag * aPluginTag)
   return false;
 }
 
+PRBool nsPluginHost::GhettoBlacklist(nsIFile *pluginFile)
+{
+    nsCString leaf;
+    const char *leafStr;
+    nsresult rv;
+    
+    rv = pluginFile->GetNativeLeafName(leaf);
+    if (NS_FAILED(rv)) {
+        return PR_TRUE; // fuck 'em. blacklist.
+    }
+
+    leafStr = leaf.get();
+
+    if (!leafStr) {
+        return PR_TRUE; // fuck 'em. blacklist.
+    }
+
+    // libgnashplugin.so, libflashplayer.so, Flash Player-10.4-10.5.plugin,
+    // NPSWF32.dll, NPSWF64.dll
+    if (strstr(leafStr, "libgnashplugin") == leafStr ||
+        strstr(leafStr, "libflashplayer") == leafStr ||
+        strstr(leafStr, "Flash Player") == leafStr ||
+        strstr(leafStr, "NPSWF") == leafStr) {
+        return PR_FALSE;
+    }
+
+    return PR_TRUE; // fuck 'em. blacklist.
+}
+
 typedef NS_NPAPIPLUGIN_CALLBACK(char *, NP_GETMIMEDESCRIPTION)(void);
 
 nsresult nsPluginHost::ScanPluginsDirectory(nsIFile *pluginsDir,
@@ -2135,6 +2164,10 @@ nsresult nsPluginHost::ScanPluginsDirectory(nsIFile *pluginsDir,
       continue;
     }
 
+    if (GhettoBlacklist(localfile)) {
+        continue;
+    }
+
     // if it is not found in cache info list or has been changed, create a new one
     if (!pluginTag) {
       nsPluginFile pluginFile(localfile);
diff --git a/dom/plugins/base/nsPluginHost.h b/dom/plugins/base/nsPluginHost.h
index 1b46957..4f1e890 100644
--- a/dom/plugins/base/nsPluginHost.h
+++ b/dom/plugins/base/nsPluginHost.h
@@ -285,6 +285,8 @@ private:
   // Loads all cached plugins info into mCachedPlugins
   nsresult ReadPluginInfo();
 
+  PRBool GhettoBlacklist(nsIFile *pluginFile);
+
   // Given a file path, returns the plugins info from our cache
   // and removes it from the cache.
   void RemoveCachedPluginsInfo(const char *filePath,
-- 
1.7.5.4