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" |
21 | 22 |
22 const char kBrowserBlacklistTrialName[] = "BrowserBlacklist"; | 23 const char kBrowserBlacklistTrialName[] = "BrowserBlacklist"; |
23 const char kBrowserBlacklistTrialDisabledGroupName[] = "NoBlacklist"; | 24 const char kBrowserBlacklistTrialDisabledGroupName[] = "NoBlacklist"; |
24 | 25 |
25 namespace { | 26 namespace { |
26 | 27 |
27 // How long to wait, in seconds, before reporting for the second (and last | 28 // How long to wait, in seconds, before reporting for the second (and last |
28 // time), what dlls were blocked from the browser process. | 29 // time), what dlls were blocked from the browser process. |
29 const int kBlacklistReportingDelaySec = 600; | 30 const int kBlacklistReportingDelaySec = 600; |
30 | 31 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 ReportSuccessfulBlocks(); | 103 ReportSuccessfulBlocks(); |
103 | 104 |
104 // Schedule another task to report all successful interceptions later. | 105 // Schedule another task to report all successful interceptions later. |
105 // This time delay should be long enough to catch any dlls that attempt to | 106 // This time delay should be long enough to catch any dlls that attempt to |
106 // inject after Chrome has started up. | 107 // inject after Chrome has started up. |
107 content::BrowserThread::PostDelayedTask( | 108 content::BrowserThread::PostDelayedTask( |
108 content::BrowserThread::UI, | 109 content::BrowserThread::UI, |
109 FROM_HERE, | 110 FROM_HERE, |
110 base::Bind(&ReportSuccessfulBlocks), | 111 base::Bind(&ReportSuccessfulBlocks), |
111 base::TimeDelta::FromSeconds(kBlacklistReportingDelaySec)); | 112 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 } |
112 } | 129 } |
113 | 130 |
114 void BrowserBlacklistBeaconSetup() { | 131 void BrowserBlacklistBeaconSetup() { |
115 base::win::RegKey blacklist_registry_key(HKEY_CURRENT_USER, | 132 base::win::RegKey blacklist_registry_key(HKEY_CURRENT_USER, |
116 blacklist::kRegistryBeaconPath, | 133 blacklist::kRegistryBeaconPath, |
117 KEY_QUERY_VALUE | KEY_SET_VALUE); | 134 KEY_QUERY_VALUE | KEY_SET_VALUE); |
118 | 135 |
119 // No point in trying to continue if the registry key isn't valid. | 136 // No point in trying to continue if the registry key isn't valid. |
120 if (!blacklist_registry_key.Valid()) | 137 if (!blacklist_registry_key.Valid()) |
121 return; | 138 return; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 | 186 |
170 blacklist_registry_key.WriteValue(blacklist::kBeaconAttemptCount, | 187 blacklist_registry_key.WriteValue(blacklist::kBeaconAttemptCount, |
171 static_cast<DWORD>(0)); | 188 static_cast<DWORD>(0)); |
172 | 189 |
173 // Only report the blacklist as getting setup when both registry writes | 190 // Only report the blacklist as getting setup when both registry writes |
174 // succeed, since otherwise the blacklist wasn't properly setup. | 191 // succeed, since otherwise the blacklist wasn't properly setup. |
175 if (set_version == ERROR_SUCCESS && set_state == ERROR_SUCCESS) | 192 if (set_version == ERROR_SUCCESS && set_state == ERROR_SUCCESS) |
176 RecordBlacklistSetupEvent(BLACKLIST_SETUP_ENABLED); | 193 RecordBlacklistSetupEvent(BLACKLIST_SETUP_ENABLED); |
177 } | 194 } |
178 } | 195 } |
OLD | NEW |