OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/win/chrome_elf_init.h" | 5 #include "chrome/browser/win/chrome_elf_init.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
12 #include "base/metrics/sparse_histogram.h" | 12 #include "base/metrics/sparse_histogram.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "base/win/registry.h" | 14 #include "base/win/registry.h" |
15 #include "chrome/common/chrome_version.h" | 15 #include "chrome/common/chrome_version.h" |
16 #include "chrome_elf/blacklist/blacklist.h" | 16 #include "chrome_elf/blacklist/blacklist.h" |
17 #include "chrome_elf/chrome_elf_constants.h" | 17 #include "chrome_elf/chrome_elf_constants.h" |
18 #include "chrome_elf/dll_hash/dll_hash.h" | 18 #include "chrome_elf/dll_hash/dll_hash.h" |
19 #include "components/variations/variations_associated_data.h" | 19 #include "components/variations/variations_associated_data.h" |
20 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
21 #include "content/public/common/content_features.h" | |
22 | 21 |
23 const char kBrowserBlacklistTrialName[] = "BrowserBlacklist"; | 22 const char kBrowserBlacklistTrialName[] = "BrowserBlacklist"; |
24 const char kBrowserBlacklistTrialDisabledGroupName[] = "NoBlacklist"; | 23 const char kBrowserBlacklistTrialDisabledGroupName[] = "NoBlacklist"; |
25 | 24 |
26 namespace { | 25 namespace { |
27 | 26 |
28 // How long to wait, in seconds, before reporting for the second (and last | 27 // How long to wait, in seconds, before reporting for the second (and last |
29 // time), what dlls were blocked from the browser process. | 28 // time), what dlls were blocked from the browser process. |
30 const int kBlacklistReportingDelaySec = 600; | 29 const int kBlacklistReportingDelaySec = 600; |
31 | 30 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 ReportSuccessfulBlocks(); | 102 ReportSuccessfulBlocks(); |
104 | 103 |
105 // Schedule another task to report all successful interceptions later. | 104 // Schedule another task to report all successful interceptions later. |
106 // This time delay should be long enough to catch any dlls that attempt to | 105 // This time delay should be long enough to catch any dlls that attempt to |
107 // inject after Chrome has started up. | 106 // inject after Chrome has started up. |
108 content::BrowserThread::PostDelayedTask( | 107 content::BrowserThread::PostDelayedTask( |
109 content::BrowserThread::UI, | 108 content::BrowserThread::UI, |
110 FROM_HERE, | 109 FROM_HERE, |
111 base::Bind(&ReportSuccessfulBlocks), | 110 base::Bind(&ReportSuccessfulBlocks), |
112 base::TimeDelta::FromSeconds(kBlacklistReportingDelaySec)); | 111 base::TimeDelta::FromSeconds(kBlacklistReportingDelaySec)); |
113 | |
114 // Make sure the early finch emergency "off switch" for | |
115 // sandbox::MITIGATION_EXTENSION_POINT_DISABLE is set properly in reg. | |
116 // Note: the very existence of this key signals elf to not enable | |
117 // this mitigation on browser next start. | |
118 base::win::RegKey finch_security_registry_key( | |
119 HKEY_CURRENT_USER, elf_sec::kRegSecurityFinchPath, KEY_READ); | |
120 | |
121 if (base::FeatureList::IsEnabled(features::kWinSboxDisableExtensionPoints)) { | |
122 if (finch_security_registry_key.Valid()) | |
123 finch_security_registry_key.DeleteKey(L""); | |
124 } else { | |
125 if (!finch_security_registry_key.Valid()) | |
126 finch_security_registry_key.Create( | |
127 HKEY_CURRENT_USER, elf_sec::kRegSecurityFinchPath, KEY_WRITE); | |
128 } | |
129 } | 112 } |
130 | 113 |
131 void BrowserBlacklistBeaconSetup() { | 114 void BrowserBlacklistBeaconSetup() { |
132 base::win::RegKey blacklist_registry_key(HKEY_CURRENT_USER, | 115 base::win::RegKey blacklist_registry_key(HKEY_CURRENT_USER, |
133 blacklist::kRegistryBeaconPath, | 116 blacklist::kRegistryBeaconPath, |
134 KEY_QUERY_VALUE | KEY_SET_VALUE); | 117 KEY_QUERY_VALUE | KEY_SET_VALUE); |
135 | 118 |
136 // No point in trying to continue if the registry key isn't valid. | 119 // No point in trying to continue if the registry key isn't valid. |
137 if (!blacklist_registry_key.Valid()) | 120 if (!blacklist_registry_key.Valid()) |
138 return; | 121 return; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 | 169 |
187 blacklist_registry_key.WriteValue(blacklist::kBeaconAttemptCount, | 170 blacklist_registry_key.WriteValue(blacklist::kBeaconAttemptCount, |
188 static_cast<DWORD>(0)); | 171 static_cast<DWORD>(0)); |
189 | 172 |
190 // Only report the blacklist as getting setup when both registry writes | 173 // Only report the blacklist as getting setup when both registry writes |
191 // succeed, since otherwise the blacklist wasn't properly setup. | 174 // succeed, since otherwise the blacklist wasn't properly setup. |
192 if (set_version == ERROR_SUCCESS && set_state == ERROR_SUCCESS) | 175 if (set_version == ERROR_SUCCESS && set_state == ERROR_SUCCESS) |
193 RecordBlacklistSetupEvent(BLACKLIST_SETUP_ENABLED); | 176 RecordBlacklistSetupEvent(BLACKLIST_SETUP_ENABLED); |
194 } | 177 } |
195 } | 178 } |
OLD | NEW |