Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(423)

Side by Side Diff: sandbox/win/src/process_mitigations_test.cc

Issue 1835003003: [Windows Sandbox] MITIGATION_EXTENSION_POINT_DISABLE support for children. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review fixes, part 3 (robertshield). Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 "sandbox/win/src/process_mitigations.h"
6
7 #include <psapi.h>
8
9 #include "base/command_line.h"
5 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
6 #include "base/files/scoped_temp_dir.h" 11 #include "base/files/scoped_temp_dir.h"
7 #include "base/path_service.h" 12 #include "base/path_service.h"
8 #include "base/process/launch.h" 13 #include "base/process/launch.h"
14 #include "base/scoped_native_library.h"
9 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
16 #include "base/win/registry.h"
10 #include "base/win/scoped_handle.h" 17 #include "base/win/scoped_handle.h"
18 #include "base/win/startup_information.h"
19 #include "base/win/win_util.h"
11 #include "base/win/windows_version.h" 20 #include "base/win/windows_version.h"
12 #include "sandbox/win/src/nt_internals.h" 21 #include "sandbox/win/src/nt_internals.h"
13 #include "sandbox/win/src/process_mitigations.h"
14 #include "sandbox/win/src/sandbox.h" 22 #include "sandbox/win/src/sandbox.h"
15 #include "sandbox/win/src/sandbox_factory.h" 23 #include "sandbox/win/src/sandbox_factory.h"
16 #include "sandbox/win/src/target_services.h" 24 #include "sandbox/win/src/target_services.h"
17 #include "sandbox/win/src/win_utils.h"
18 #include "sandbox/win/tests/common/controller.h" 25 #include "sandbox/win/tests/common/controller.h"
26 #include "sandbox/win/tests/integration_tests/integration_tests_common.h"
19 #include "testing/gtest/include/gtest/gtest.h" 27 #include "testing/gtest/include/gtest/gtest.h"
20 28
21 namespace { 29 namespace {
22 30
23 // API defined in winbase.h. 31 // API defined in winbase.h.
24 typedef decltype(GetProcessDEPPolicy)* GetProcessDEPPolicyFunction; 32 typedef decltype(GetProcessDEPPolicy)* GetProcessDEPPolicyFunction;
25 33
26 // API defined in processthreadsapi.h. 34 // API defined in processthreadsapi.h.
27 typedef decltype( 35 typedef decltype(
28 GetProcessMitigationPolicy)* GetProcessMitigationPolicyFunction; 36 GetProcessMitigationPolicy)* GetProcessMitigationPolicyFunction;
29 GetProcessMitigationPolicyFunction get_process_mitigation_policy; 37 GetProcessMitigationPolicyFunction get_process_mitigation_policy;
30 38
31 // APIs defined in wingdi.h. 39 // APIs defined in wingdi.h.
32 typedef decltype(AddFontMemResourceEx)* AddFontMemResourceExFunction; 40 typedef decltype(AddFontMemResourceEx)* AddFontMemResourceExFunction;
33 typedef decltype(RemoveFontMemResourceEx)* RemoveFontMemResourceExFunction; 41 typedef decltype(RemoveFontMemResourceEx)* RemoveFontMemResourceExFunction;
34 42
43 // APIs defined in integration_tests_common.h
44 typedef decltype(WasHookCalled)* WasHookCalledFunction;
45 typedef decltype(SetHook)* SetHookFunction;
46
35 #if !defined(_WIN64) 47 #if !defined(_WIN64)
36 bool CheckWin8DepPolicy() { 48 bool CheckWin8DepPolicy() {
37 PROCESS_MITIGATION_DEP_POLICY policy = {}; 49 PROCESS_MITIGATION_DEP_POLICY policy = {};
38 if (!get_process_mitigation_policy(::GetCurrentProcess(), ProcessDEPPolicy, 50 if (!get_process_mitigation_policy(::GetCurrentProcess(), ProcessDEPPolicy,
39 &policy, sizeof(policy))) { 51 &policy, sizeof(policy))) {
40 return false; 52 return false;
41 } 53 }
42 return policy.Enable && policy.Permanent; 54 return policy.Enable && policy.Permanent;
43 } 55 }
44 #endif // !defined(_WIN64) 56 #endif // !defined(_WIN64)
45 57
46 #if defined(NDEBUG) 58 #if defined(NDEBUG)
47 bool CheckWin8AslrPolicy() { 59 bool CheckWin8AslrPolicy() {
48 PROCESS_MITIGATION_ASLR_POLICY policy = {}; 60 PROCESS_MITIGATION_ASLR_POLICY policy = {};
49 if (!get_process_mitigation_policy(::GetCurrentProcess(), ProcessASLRPolicy, 61 if (!get_process_mitigation_policy(::GetCurrentProcess(), ProcessASLRPolicy,
50 &policy, sizeof(policy))) { 62 &policy, sizeof(policy))) {
51 return false; 63 return false;
52 } 64 }
53 return policy.EnableForceRelocateImages && policy.DisallowStrippedImages; 65 return policy.EnableForceRelocateImages && policy.DisallowStrippedImages;
54 } 66 }
55 #endif // defined(NDEBUG) 67 #endif // defined(NDEBUG)
56 68
57 bool CheckWin8StrictHandlePolicy() { 69 bool CheckWin8StrictHandlePolicy() {
58 PROCESS_MITIGATION_STRICT_HANDLE_CHECK_POLICY policy = {}; 70 PROCESS_MITIGATION_STRICT_HANDLE_CHECK_POLICY policy = {};
59 if (!get_process_mitigation_policy(::GetCurrentProcess(), 71 if (!get_process_mitigation_policy(::GetCurrentProcess(),
60 ProcessStrictHandleCheckPolicy, 72 ProcessStrictHandleCheckPolicy, &policy,
61 &policy, sizeof(policy))) { 73 sizeof(policy))) {
62 return false; 74 return false;
63 } 75 }
64 return policy.RaiseExceptionOnInvalidHandleReference && 76 return policy.RaiseExceptionOnInvalidHandleReference &&
65 policy.HandleExceptionsPermanentlyEnabled; 77 policy.HandleExceptionsPermanentlyEnabled;
66 } 78 }
67 79
68 bool CheckWin8Win32CallPolicy() { 80 bool CheckWin8Win32CallPolicy() {
69 PROCESS_MITIGATION_SYSTEM_CALL_DISABLE_POLICY policy = {}; 81 PROCESS_MITIGATION_SYSTEM_CALL_DISABLE_POLICY policy = {};
70 if (!get_process_mitigation_policy(::GetCurrentProcess(), 82 if (!get_process_mitigation_policy(::GetCurrentProcess(),
71 ProcessSystemCallDisablePolicy, 83 ProcessSystemCallDisablePolicy, &policy,
72 &policy, sizeof(policy))) { 84 sizeof(policy))) {
73 return false; 85 return false;
74 } 86 }
75 return policy.DisallowWin32kSystemCalls; 87 return policy.DisallowWin32kSystemCalls;
76 } 88 }
77 89
78 bool CheckWin8DllExtensionPolicy() { 90 bool CheckWin8ExtensionPointPolicy() {
79 PROCESS_MITIGATION_EXTENSION_POINT_DISABLE_POLICY policy = {}; 91 PROCESS_MITIGATION_EXTENSION_POINT_DISABLE_POLICY policy = {};
80 if (!get_process_mitigation_policy(::GetCurrentProcess(), 92 if (!get_process_mitigation_policy(::GetCurrentProcess(),
81 ProcessExtensionPointDisablePolicy, 93 ProcessExtensionPointDisablePolicy,
82 &policy, sizeof(policy))) { 94 &policy, sizeof(policy))) {
83 return false; 95 return false;
84 } 96 }
85 return policy.DisableExtensionPoints; 97 return policy.DisableExtensionPoints;
86 } 98 }
87 99
88 bool CheckWin10FontPolicy() { 100 bool CheckWin10FontPolicy() {
89 PROCESS_MITIGATION_FONT_DISABLE_POLICY policy = {}; 101 PROCESS_MITIGATION_FONT_DISABLE_POLICY policy = {};
90 if (!get_process_mitigation_policy(::GetCurrentProcess(), 102 if (!get_process_mitigation_policy(::GetCurrentProcess(),
91 ProcessFontDisablePolicy, &policy, 103 ProcessFontDisablePolicy, &policy,
92 sizeof(policy))) { 104 sizeof(policy))) {
93 return false; 105 return false;
94 } 106 }
95 return policy.DisableNonSystemFonts; 107 return policy.DisableNonSystemFonts;
96 } 108 }
97 109
98 bool CheckWin10ImageLoadNoRemotePolicy() { 110 bool CheckWin10ImageLoadNoRemotePolicy() {
99 PROCESS_MITIGATION_IMAGE_LOAD_POLICY policy = {}; 111 PROCESS_MITIGATION_IMAGE_LOAD_POLICY policy = {};
100 if (!get_process_mitigation_policy(::GetCurrentProcess(), 112 if (!get_process_mitigation_policy(::GetCurrentProcess(),
101 ProcessImageLoadPolicy, &policy, 113 ProcessImageLoadPolicy, &policy,
102 sizeof(policy))) { 114 sizeof(policy))) {
103 return false; 115 return false;
104 } 116 }
105 return policy.NoRemoteImages; 117 return policy.NoRemoteImages;
106 } 118 }
107 119
120 // Spawn Windows process (with or without mitigation enabled).
121 bool SpawnWinProc(PROCESS_INFORMATION* pi, bool success_test, HANDLE* event) {
122 base::win::StartupInformation startup_info;
123 DWORD creation_flags = 0;
124
125 if (!success_test) {
126 DWORD64 flags =
127 PROCESS_CREATION_MITIGATION_POLICY_EXTENSION_POINT_DISABLE_ALWAYS_ON;
128 // This test only runs on >= Win8, so don't have to handle
129 // illegal 64-bit flags on 32-bit <= Win7.
130 size_t flags_size = sizeof(flags);
131
132 if (!startup_info.InitializeProcThreadAttributeList(1) ||
133 !startup_info.UpdateProcThreadAttribute(
134 PROC_THREAD_ATTRIBUTE_MITIGATION_POLICY, &flags, flags_size)) {
135 ADD_FAILURE();
136 return false;
137 }
138 creation_flags = EXTENDED_STARTUPINFO_PRESENT;
139 }
140
141 // Command line must be writable.
142 base::string16 cmd_writeable(g_winproc_file);
143
144 if (!::CreateProcessW(NULL, &cmd_writeable[0], NULL, NULL, FALSE,
145 creation_flags, NULL, NULL, startup_info.startup_info(),
146 pi)) {
147 ADD_FAILURE();
148 return false;
149 }
150 EXPECT_EQ(WAIT_OBJECT_0,
151 ::WaitForSingleObject(*event, g_winproc_event_max_wait_ms));
152
153 return true;
154 }
155
156 //------------------------------------------------------------------------------
157 // 1. Spawn a Windows process (with or without mitigation enabled).
158 // 2. Load the hook Dll locally.
159 // 3. Create a global named event for the hook to trigger.
160 // 4. Start the hook (for the specific WinProc or globally).
161 // 5. Send a keystroke event.
162 // 6. Ask the hook Dll if it received a hook callback.
163 // 7. Cleanup the hooking.
164 // 8. Signal the Windows process to shutdown.
165 //
166 // Do NOT use any ASSERTs in this function. Cleanup required.
167 //------------------------------------------------------------------------------
168 void TestWin8ExtensionPointHookWrapper(bool is_success_test, bool global_hook) {
169 // Set up a couple global events that this test will use.
170 HANDLE winproc_event = ::CreateEventW(NULL, FALSE, FALSE, g_winproc_event);
171 if (winproc_event == NULL || winproc_event == INVALID_HANDLE_VALUE) {
172 ADD_FAILURE();
173 return;
174 }
175 base::win::ScopedHandle scoped_winproc_event(winproc_event);
176
177 HANDLE hook_event = ::CreateEventW(NULL, FALSE, FALSE, g_hook_event);
178 if (hook_event == NULL || hook_event == INVALID_HANDLE_VALUE) {
179 ADD_FAILURE();
180 return;
181 }
182 base::win::ScopedHandle scoped_hook_event(hook_event);
183
184 // 1. Spawn WinProc.
185 PROCESS_INFORMATION proc_info = {};
186 if (!SpawnWinProc(&proc_info, is_success_test, &winproc_event))
187 return;
188
189 // From this point on, no return on failure. Cleanup required.
190 bool all_good = true;
191
192 // 2. Load the hook DLL.
193 base::FilePath hook_dll_path(g_hook_dll_file);
194 base::ScopedNativeLibrary dll(hook_dll_path);
195 EXPECT_TRUE(dll.is_valid());
196
197 HOOKPROC hook_proc =
198 reinterpret_cast<HOOKPROC>(dll.GetFunctionPointer(g_hook_handler_func));
199 WasHookCalledFunction was_hook_called =
200 reinterpret_cast<WasHookCalledFunction>(
201 dll.GetFunctionPointer(g_was_hook_called_func));
202 SetHookFunction set_hook = reinterpret_cast<SetHookFunction>(
203 dll.GetFunctionPointer(g_set_hook_func));
204 if (!hook_proc || !was_hook_called || !set_hook) {
205 ADD_FAILURE();
206 all_good = false;
207 }
208
209 // 3. Try installing the hook (either on a remote target thread,
210 // or globally).
211 HHOOK hook = nullptr;
212 if (all_good) {
213 DWORD target = 0;
214 if (!global_hook)
215 target = proc_info.dwThreadId;
216 hook = ::SetWindowsHookExW(WH_KEYBOARD, hook_proc, dll.get(), target);
217 if (!hook) {
218 ADD_FAILURE();
219 all_good = false;
220 } else
221 // Pass the hook DLL the hook handle.
222 set_hook(hook);
223 }
224
225 // 4. Inject a keyboard event.
226 if (all_good) {
227 // Note: that PostThreadMessage and SendMessage APIs will not deliver
228 // a keystroke in such a way that triggers a "legitimate" hook.
229 // Have to use targetless SendInput or keybd_event. The latter is
230 // less code and easier to work with.
231 keybd_event(VkKeyScan(L'A'), 0, 0, 0);
232 keybd_event(VkKeyScan(L'A'), 0, KEYEVENTF_KEYUP, 0);
233 // Give it a chance to hit the hook handler...
234 ::WaitForSingleObject(hook_event, g_hook_event_max_wait_ms);
235
236 // 5. Did the hook get hit? Was it expected to?
237 if (global_hook)
238 EXPECT_EQ((is_success_test ? true : false), was_hook_called());
239 else
240 // ***IMPORTANT: when targeting a specific thread id, the
241 // PROCESS_CREATION_MITIGATION_POLICY_EXTENSION_POINT_DISABLE
242 // mitigation does NOT disable the hook API. It ONLY
243 // stops global hooks from running in a process. Hence,
244 // the hook will hit (TRUE) even in the "failure"
245 // case for a non-global/targeted hook.
246 EXPECT_EQ((is_success_test ? true : true), was_hook_called());
247 }
248
249 // 6. Disable hook.
250 if (hook)
251 EXPECT_TRUE(::UnhookWindowsHookEx(hook));
252
253 // 7. Trigger shutdown of WinProc.
254 if (proc_info.hProcess) {
255 if (::PostThreadMessageW(proc_info.dwThreadId, WM_QUIT, 0, 0)) {
256 // Note: The combination/perfect-storm of a Global Hook, in a
257 // WinProc that has the EXTENSION_POINT_DISABLE mitigation ON, and the
258 // use of the SendInput or keybd_event API to inject a keystroke,
259 // results in the target becoming unresponsive. If any one of these
260 // states are changed, the problem does not occur. This means the WM_QUIT
261 // message is not handled and the call to WaitForSingleObject times out.
262 // Therefore not checking the return val.
263 ::WaitForSingleObject(winproc_event, g_winproc_event_max_wait_ms);
264 } else {
265 // Ensure no strays.
266 ::TerminateProcess(proc_info.hProcess, 0);
267 ADD_FAILURE();
268 }
269 EXPECT_TRUE(::CloseHandle(proc_info.hThread));
270 EXPECT_TRUE(::CloseHandle(proc_info.hProcess));
271 }
272 }
273
274 //------------------------------------------------------------------------------
275 // 1. Set up the AppInit Dll in registry settings. (Enable)
276 // 2. Spawn a Windows process (with or without mitigation enabled).
277 // 3. Check if the AppInit Dll got loaded in the Windows process or not.
278 // 4. Signal the Windows process to shutdown.
279 // 5. Restore original reg settings.
280 //
281 // Do NOT use any ASSERTs in this function. Cleanup required.
282 //------------------------------------------------------------------------------
283 void TestWin8ExtensionPointAppInitWrapper(bool is_success_test) {
284 // 0.5 Get path of current module. The appropriate build of the
285 // AppInit DLL will be in the same directory (and the
286 // full path is needed for reg).
287 wchar_t path[MAX_PATH];
288 if (!::GetModuleFileNameW(NULL, path, MAX_PATH)) {
289 ADD_FAILURE();
290 return;
291 }
292 // Only want the directory. Switch file name for the AppInit DLL.
293 base::FilePath full_dll_path(path);
294 full_dll_path = full_dll_path.DirName();
295 full_dll_path = full_dll_path.Append(g_hook_dll_file);
296 wchar_t* non_const = const_cast<wchar_t*>(full_dll_path.value().c_str());
297 // Now make sure the path is in "short-name" form for registry.
298 DWORD length = ::GetShortPathNameW(non_const, NULL, 0);
299 std::vector<wchar_t> short_name(length);
300 if (!::GetShortPathNameW(non_const, &short_name[0], length)) {
301 ADD_FAILURE();
302 return;
303 }
304
305 // 1. Reg setup.
306 wchar_t* app_init_reg_path =
307 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Windows";
308 wchar_t* dlls_value_name = L"AppInit_DLLs";
309 wchar_t* enabled_value_name = L"LoadAppInit_DLLs";
310 wchar_t* signing_value_name = L"RequireSignedAppInit_DLLs";
311 std::wstring orig_dlls;
312 std::wstring new_dlls;
313 DWORD orig_enabled_value = 0;
314 DWORD orig_signing_value = 0;
315 base::win::RegKey app_init_key(HKEY_LOCAL_MACHINE, app_init_reg_path,
316 KEY_QUERY_VALUE | KEY_SET_VALUE);
317 // Backup the existing settings.
318 if (!app_init_key.Valid() || !app_init_key.HasValue(dlls_value_name) ||
319 !app_init_key.HasValue(enabled_value_name) ||
320 ERROR_SUCCESS != app_init_key.ReadValue(dlls_value_name, &orig_dlls) ||
321 ERROR_SUCCESS !=
322 app_init_key.ReadValueDW(enabled_value_name, &orig_enabled_value)) {
323 ADD_FAILURE();
324 return;
325 }
326 if (app_init_key.HasValue(signing_value_name)) {
327 if (ERROR_SUCCESS !=
328 app_init_key.ReadValueDW(signing_value_name, &orig_signing_value)) {
329 ADD_FAILURE();
330 return;
331 }
332 }
333
334 // Set the new settings (obviously requires local admin privileges).
335 new_dlls = orig_dlls;
336 if (!orig_dlls.empty())
337 new_dlls.append(L",");
338 new_dlls.append(short_name.data());
339
340 // From this point on, no return on failure. Cleanup required.
341 bool all_good = true;
342
343 if (app_init_key.HasValue(signing_value_name)) {
344 if (ERROR_SUCCESS !=
345 app_init_key.WriteValue(signing_value_name, static_cast<DWORD>(0))) {
346 ADD_FAILURE();
347 all_good = false;
348 }
349 }
350 if (ERROR_SUCCESS !=
351 app_init_key.WriteValue(dlls_value_name, new_dlls.c_str()) ||
352 ERROR_SUCCESS !=
353 app_init_key.WriteValue(enabled_value_name, static_cast<DWORD>(1))) {
354 ADD_FAILURE();
355 all_good = false;
356 }
357
358 // 2. Spawn WinProc.
359 HANDLE winproc_event = INVALID_HANDLE_VALUE;
360 base::win::ScopedHandle scoped_event;
361 PROCESS_INFORMATION proc_info = {};
362 if (all_good) {
363 winproc_event = ::CreateEventW(NULL, FALSE, FALSE, g_winproc_event);
364 if (winproc_event == NULL || winproc_event == INVALID_HANDLE_VALUE) {
365 ADD_FAILURE();
366 all_good = false;
367 } else {
368 scoped_event.Set(winproc_event);
369 if (!SpawnWinProc(&proc_info, is_success_test, &winproc_event))
370 all_good = false;
371 }
372 }
373
374 // 3. Check loaded modules in WinProc to see if the AppInit dll is loaded.
375 bool dll_loaded = false;
376 if (all_good) {
377 std::vector<HMODULE>(modules);
378 if (!base::win::GetLoadedModulesSnapshot(proc_info.hProcess, &modules)) {
379 ADD_FAILURE();
380 all_good = false;
381 } else {
382 for (auto module : modules) {
383 wchar_t name[MAX_PATH] = {};
384 if (::GetModuleFileNameExW(proc_info.hProcess, module, name,
385 MAX_PATH) &&
386 ::wcsstr(name, g_hook_dll_file)) {
387 // Found it.
388 dll_loaded = true;
389 break;
390 }
391 }
392 }
393 }
394
395 // Was the test result as expected?
396 if (all_good)
397 EXPECT_EQ((is_success_test ? true : false), dll_loaded);
398
399 // 4. Trigger shutdown of WinProc.
400 if (proc_info.hProcess) {
401 if (::PostThreadMessageW(proc_info.dwThreadId, WM_QUIT, 0, 0)) {
402 ::WaitForSingleObject(winproc_event, g_winproc_event_max_wait_ms);
403 } else {
404 // Ensure no strays.
405 ::TerminateProcess(proc_info.hProcess, 0);
406 ADD_FAILURE();
407 }
408 EXPECT_TRUE(::CloseHandle(proc_info.hThread));
409 EXPECT_TRUE(::CloseHandle(proc_info.hProcess));
410 }
411
412 // 5. Reg Restore
413 EXPECT_EQ(ERROR_SUCCESS,
414 app_init_key.WriteValue(enabled_value_name, orig_enabled_value));
415 if (app_init_key.HasValue(signing_value_name))
416 EXPECT_EQ(ERROR_SUCCESS,
417 app_init_key.WriteValue(signing_value_name, orig_signing_value));
418 EXPECT_EQ(ERROR_SUCCESS,
419 app_init_key.WriteValue(dlls_value_name, orig_dlls.c_str()));
420 }
421
108 void TestWin10ImageLoadRemote(bool is_success_test) { 422 void TestWin10ImageLoadRemote(bool is_success_test) {
109 // ***Insert your manual testing share UNC path here! 423 // ***Insert a manual testing share UNC path here!
110 // E.g.: \\\\hostname\\sharename\\calc.exe 424 // E.g.: \\\\hostname\\sharename\\calc.exe
111 std::wstring unc = L"\"\\\\hostname\\sharename\\calc.exe\""; 425 std::wstring unc = L"\"\\\\hostname\\sharename\\calc.exe\"";
112 426
113 sandbox::TestRunner runner; 427 sandbox::TestRunner runner;
114 sandbox::TargetPolicy* policy = runner.GetPolicy(); 428 sandbox::TargetPolicy* policy = runner.GetPolicy();
115 429
116 // Set a policy that would normally allow for process creation. 430 // Set a policy that would normally allow for process creation.
117 policy->SetJobLevel(sandbox::JOB_NONE, 0); 431 policy->SetJobLevel(sandbox::JOB_NONE, 0);
118 policy->SetTokenLevel(sandbox::USER_UNPROTECTED, sandbox::USER_UNPROTECTED); 432 policy->SetTokenLevel(sandbox::USER_UNPROTECTED, sandbox::USER_UNPROTECTED);
119 runner.SetDisableCsrss(false); 433 runner.SetDisableCsrss(false);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 setup_proc.Terminate(desired_exit_code, false); 544 setup_proc.Terminate(desired_exit_code, false);
231 return SBOX_TEST_SUCCEEDED; 545 return SBOX_TEST_SUCCEEDED;
232 } 546 }
233 // Note: GetLastError from CreateProcess returns 5, "ERROR_ACCESS_DENIED". 547 // Note: GetLastError from CreateProcess returns 5, "ERROR_ACCESS_DENIED".
234 return SBOX_TEST_FAILED; 548 return SBOX_TEST_FAILED;
235 } 549 }
236 550
237 //------------------------------------------------------------------------------ 551 //------------------------------------------------------------------------------
238 // Win8 Checks: 552 // Win8 Checks:
239 // MITIGATION_DEP(_NO_ATL_THUNK) 553 // MITIGATION_DEP(_NO_ATL_THUNK)
240 // MITIGATION_EXTENSION_DLL_DISABLE
241 // MITIGATION_RELOCATE_IMAGE(_REQUIRED) - ASLR, release only 554 // MITIGATION_RELOCATE_IMAGE(_REQUIRED) - ASLR, release only
242 // MITIGATION_STRICT_HANDLE_CHECKS 555 // MITIGATION_STRICT_HANDLE_CHECKS
243 // >= Win8 556 // >= Win8
244 //------------------------------------------------------------------------------ 557 //------------------------------------------------------------------------------
245 558
246 SBOX_TESTS_COMMAND int CheckWin8(int argc, wchar_t **argv) { 559 SBOX_TESTS_COMMAND int CheckWin8(int argc, wchar_t** argv) {
247 get_process_mitigation_policy = 560 get_process_mitigation_policy =
248 reinterpret_cast<GetProcessMitigationPolicyFunction>( 561 reinterpret_cast<GetProcessMitigationPolicyFunction>(::GetProcAddress(
249 ::GetProcAddress(::GetModuleHandleW(L"kernel32.dll"), 562 ::GetModuleHandleW(L"kernel32.dll"), "GetProcessMitigationPolicy"));
250 "GetProcessMitigationPolicy"));
251 if (!get_process_mitigation_policy) 563 if (!get_process_mitigation_policy)
252 return SBOX_TEST_NOT_FOUND; 564 return SBOX_TEST_NOT_FOUND;
253 565
254 #if !defined(_WIN64) // DEP is always enabled on 64-bit. 566 #if !defined(_WIN64) // DEP is always enabled on 64-bit.
255 if (!CheckWin8DepPolicy()) 567 if (!CheckWin8DepPolicy())
256 return SBOX_TEST_FIRST_ERROR; 568 return SBOX_TEST_FIRST_ERROR;
257 #endif 569 #endif
258 570
259 #if defined(NDEBUG) // ASLR cannot be forced in debug builds. 571 #if defined(NDEBUG) // ASLR cannot be forced in debug builds.
260 if (!CheckWin8AslrPolicy()) 572 if (!CheckWin8AslrPolicy())
261 return SBOX_TEST_SECOND_ERROR; 573 return SBOX_TEST_SECOND_ERROR;
262 #endif 574 #endif
263 575
264 if (!CheckWin8StrictHandlePolicy()) 576 if (!CheckWin8StrictHandlePolicy())
265 return SBOX_TEST_THIRD_ERROR; 577 return SBOX_TEST_THIRD_ERROR;
266 578
267 if (!CheckWin8DllExtensionPolicy())
268 return SBOX_TEST_FIFTH_ERROR;
269
270 return SBOX_TEST_SUCCEEDED; 579 return SBOX_TEST_SUCCEEDED;
271 } 580 }
272 581
273 TEST(ProcessMitigationsTest, CheckWin8) { 582 TEST(ProcessMitigationsTest, CheckWin8) {
274 if (base::win::GetVersion() < base::win::VERSION_WIN8) 583 if (base::win::GetVersion() < base::win::VERSION_WIN8)
275 return; 584 return;
276 585
277 TestRunner runner; 586 TestRunner runner;
278 sandbox::TargetPolicy* policy = runner.GetPolicy(); 587 sandbox::TargetPolicy* policy = runner.GetPolicy();
279 588
280 sandbox::MitigationFlags mitigations = MITIGATION_DEP | 589 sandbox::MitigationFlags mitigations =
281 MITIGATION_DEP_NO_ATL_THUNK | 590 MITIGATION_DEP | MITIGATION_DEP_NO_ATL_THUNK;
282 MITIGATION_EXTENSION_DLL_DISABLE;
283 #if defined(NDEBUG) // ASLR cannot be forced in debug builds. 591 #if defined(NDEBUG) // ASLR cannot be forced in debug builds.
284 mitigations |= MITIGATION_RELOCATE_IMAGE | 592 mitigations |= MITIGATION_RELOCATE_IMAGE | MITIGATION_RELOCATE_IMAGE_REQUIRED;
285 MITIGATION_RELOCATE_IMAGE_REQUIRED;
286 #endif 593 #endif
287 594
288 EXPECT_EQ(policy->SetProcessMitigations(mitigations), SBOX_ALL_OK); 595 EXPECT_EQ(policy->SetProcessMitigations(mitigations), SBOX_ALL_OK);
289 596
290 mitigations |= MITIGATION_STRICT_HANDLE_CHECKS; 597 mitigations |= MITIGATION_STRICT_HANDLE_CHECKS;
291 598
292 EXPECT_EQ(policy->SetDelayedProcessMitigations(mitigations), SBOX_ALL_OK); 599 EXPECT_EQ(policy->SetDelayedProcessMitigations(mitigations), SBOX_ALL_OK);
293 600
294 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"CheckWin8")); 601 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"CheckWin8"));
295 } 602 }
296 603
297 //------------------------------------------------------------------------------ 604 //------------------------------------------------------------------------------
298 // DEP (MITIGATION_DEP) 605 // DEP (MITIGATION_DEP)
299 // < Win8 x86 606 // < Win8 x86
300 //------------------------------------------------------------------------------ 607 //------------------------------------------------------------------------------
301 608
302 SBOX_TESTS_COMMAND int CheckDep(int argc, wchar_t **argv) { 609 SBOX_TESTS_COMMAND int CheckDep(int argc, wchar_t** argv) {
303 GetProcessDEPPolicyFunction get_process_dep_policy = 610 GetProcessDEPPolicyFunction get_process_dep_policy =
304 reinterpret_cast<GetProcessDEPPolicyFunction>( 611 reinterpret_cast<GetProcessDEPPolicyFunction>(::GetProcAddress(
305 ::GetProcAddress(::GetModuleHandleW(L"kernel32.dll"), 612 ::GetModuleHandleW(L"kernel32.dll"), "GetProcessDEPPolicy"));
306 "GetProcessDEPPolicy"));
307 if (get_process_dep_policy) { 613 if (get_process_dep_policy) {
308 BOOL is_permanent = FALSE; 614 BOOL is_permanent = FALSE;
309 DWORD dep_flags = 0; 615 DWORD dep_flags = 0;
310 616
311 if (!get_process_dep_policy(::GetCurrentProcess(), &dep_flags, 617 if (!get_process_dep_policy(::GetCurrentProcess(), &dep_flags,
312 &is_permanent)) { 618 &is_permanent)) {
313 return SBOX_TEST_FIRST_ERROR; 619 return SBOX_TEST_FIRST_ERROR;
314 } 620 }
315 621
316 if (!(dep_flags & PROCESS_DEP_ENABLE) || !is_permanent) 622 if (!(dep_flags & PROCESS_DEP_ENABLE) || !is_permanent)
317 return SBOX_TEST_SECOND_ERROR; 623 return SBOX_TEST_SECOND_ERROR;
318 624
319 } else { 625 } else {
320 NtQueryInformationProcessFunction query_information_process = NULL; 626 NtQueryInformationProcessFunction query_information_process = NULL;
321 ResolveNTFunctionPtr("NtQueryInformationProcess", 627 ResolveNTFunctionPtr("NtQueryInformationProcess",
322 &query_information_process); 628 &query_information_process);
323 if (!query_information_process) 629 if (!query_information_process)
324 return SBOX_TEST_NOT_FOUND; 630 return SBOX_TEST_NOT_FOUND;
325 631
326 ULONG size = 0; 632 ULONG size = 0;
327 ULONG dep_flags = 0; 633 ULONG dep_flags = 0;
328 if (!SUCCEEDED(query_information_process(::GetCurrentProcess(), 634 if (!SUCCEEDED(query_information_process(::GetCurrentProcess(),
329 ProcessExecuteFlags, &dep_flags, 635 ProcessExecuteFlags, &dep_flags,
330 sizeof(dep_flags), &size))) { 636 sizeof(dep_flags), &size))) {
331 return SBOX_TEST_THIRD_ERROR; 637 return SBOX_TEST_THIRD_ERROR;
332 } 638 }
333 639
334 static const int MEM_EXECUTE_OPTION_DISABLE = 2; 640 static const int MEM_EXECUTE_OPTION_DISABLE = 2;
335 static const int MEM_EXECUTE_OPTION_PERMANENT = 8; 641 static const int MEM_EXECUTE_OPTION_PERMANENT = 8;
336 dep_flags &= 0xff; 642 dep_flags &= 0xff;
337 643
338 if (dep_flags != (MEM_EXECUTE_OPTION_DISABLE | 644 if (dep_flags !=
339 MEM_EXECUTE_OPTION_PERMANENT)) { 645 (MEM_EXECUTE_OPTION_DISABLE | MEM_EXECUTE_OPTION_PERMANENT)) {
340 return SBOX_TEST_FOURTH_ERROR; 646 return SBOX_TEST_FOURTH_ERROR;
341 } 647 }
342 } 648 }
343 649
344 return SBOX_TEST_SUCCEEDED; 650 return SBOX_TEST_SUCCEEDED;
345 } 651 }
346 652
347 #if !defined(_WIN64) // DEP is always enabled on 64-bit. 653 #if !defined(_WIN64) // DEP is always enabled on 64-bit.
348 TEST(ProcessMitigationsTest, CheckDep) { 654 TEST(ProcessMitigationsTest, CheckDep) {
349 if (base::win::GetVersion() > base::win::VERSION_WIN7) 655 if (base::win::GetVersion() > base::win::VERSION_WIN7)
350 return; 656 return;
351 657
352 TestRunner runner; 658 TestRunner runner;
353 sandbox::TargetPolicy* policy = runner.GetPolicy(); 659 sandbox::TargetPolicy* policy = runner.GetPolicy();
354 660
355 EXPECT_EQ(policy->SetProcessMitigations( 661 EXPECT_EQ(policy->SetProcessMitigations(MITIGATION_DEP |
356 MITIGATION_DEP | 662 MITIGATION_DEP_NO_ATL_THUNK |
357 MITIGATION_DEP_NO_ATL_THUNK | 663 MITIGATION_SEHOP),
358 MITIGATION_SEHOP),
359 SBOX_ALL_OK); 664 SBOX_ALL_OK);
360 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"CheckDep")); 665 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"CheckDep"));
361 } 666 }
362 #endif 667 #endif
363 668
364 //------------------------------------------------------------------------------ 669 //------------------------------------------------------------------------------
365 // Win32k Lockdown (MITIGATION_WIN32K_DISABLE) 670 // Win32k Lockdown (MITIGATION_WIN32K_DISABLE)
366 // >= Win8 671 // >= Win8
367 //------------------------------------------------------------------------------ 672 //------------------------------------------------------------------------------
368 673
369 SBOX_TESTS_COMMAND int CheckWin8Lockdown(int argc, wchar_t **argv) { 674 SBOX_TESTS_COMMAND int CheckWin8Lockdown(int argc, wchar_t** argv) {
370 get_process_mitigation_policy = 675 get_process_mitigation_policy =
371 reinterpret_cast<GetProcessMitigationPolicyFunction>( 676 reinterpret_cast<GetProcessMitigationPolicyFunction>(::GetProcAddress(
372 ::GetProcAddress(::GetModuleHandleW(L"kernel32.dll"), 677 ::GetModuleHandleW(L"kernel32.dll"), "GetProcessMitigationPolicy"));
373 "GetProcessMitigationPolicy"));
374 if (!get_process_mitigation_policy) 678 if (!get_process_mitigation_policy)
375 return SBOX_TEST_NOT_FOUND; 679 return SBOX_TEST_NOT_FOUND;
376 680
377 if (!CheckWin8Win32CallPolicy()) 681 if (!CheckWin8Win32CallPolicy())
378 return SBOX_TEST_FIRST_ERROR; 682 return SBOX_TEST_FIRST_ERROR;
379 return SBOX_TEST_SUCCEEDED; 683 return SBOX_TEST_SUCCEEDED;
380 } 684 }
381 685
382 // This test validates that setting the MITIGATION_WIN32K_DISABLE mitigation on 686 // This test validates that setting the MITIGATION_WIN32K_DISABLE mitigation on
383 // the target process causes the launch to fail in process initialization. 687 // the target process causes the launch to fail in process initialization.
(...skipping 23 matching lines...) Expand all
407 711
408 EXPECT_EQ(policy->SetProcessMitigations(MITIGATION_WIN32K_DISABLE), 712 EXPECT_EQ(policy->SetProcessMitigations(MITIGATION_WIN32K_DISABLE),
409 SBOX_ALL_OK); 713 SBOX_ALL_OK);
410 EXPECT_EQ(policy->AddRule(sandbox::TargetPolicy::SUBSYS_WIN32K_LOCKDOWN, 714 EXPECT_EQ(policy->AddRule(sandbox::TargetPolicy::SUBSYS_WIN32K_LOCKDOWN,
411 sandbox::TargetPolicy::FAKE_USER_GDI_INIT, NULL), 715 sandbox::TargetPolicy::FAKE_USER_GDI_INIT, NULL),
412 sandbox::SBOX_ALL_OK); 716 sandbox::SBOX_ALL_OK);
413 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"CheckWin8Lockdown")); 717 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"CheckWin8Lockdown"));
414 } 718 }
415 719
416 //------------------------------------------------------------------------------ 720 //------------------------------------------------------------------------------
721 // Disable extension points (MITIGATION_EXTENSION_POINT_DISABLE).
722 // >= Win8
723 //------------------------------------------------------------------------------
724 SBOX_TESTS_COMMAND int CheckWin8ExtensionPointSetting(int argc,
725 wchar_t** argv) {
726 get_process_mitigation_policy =
727 reinterpret_cast<GetProcessMitigationPolicyFunction>(::GetProcAddress(
728 ::GetModuleHandleW(L"kernel32.dll"), "GetProcessMitigationPolicy"));
729 if (!get_process_mitigation_policy)
730 return SBOX_TEST_NOT_FOUND;
731
732 if (!CheckWin8ExtensionPointPolicy())
733 return SBOX_TEST_FIRST_ERROR;
734 return SBOX_TEST_SUCCEEDED;
735 }
736
737 // This test validates that setting the MITIGATION_EXTENSION_POINT_DISABLE
738 // mitigation enables the setting on a process.
739 TEST(ProcessMitigationsTest, CheckWin8ExtensionPointPolicySuccess) {
740 if (base::win::GetVersion() < base::win::VERSION_WIN8)
741 return;
742
743 TestRunner runner;
744 sandbox::TargetPolicy* policy = runner.GetPolicy();
745
746 EXPECT_EQ(policy->SetProcessMitigations(MITIGATION_EXTENSION_POINT_DISABLE),
747 SBOX_ALL_OK);
748 EXPECT_EQ(SBOX_TEST_SUCCEEDED,
749 runner.RunTest(L"CheckWin8ExtensionPointSetting"));
750 }
751
752 // This test validates that a "legitimate" global hook CAN be set on the
753 // sandboxed proc/thread if the MITIGATION_EXTENSION_POINT_DISABLE
754 // mitigation is not set.
755 //
756 // MANUAL testing only.
757 TEST(ProcessMitigationsTest,
758 DISABLED_CheckWin8ExtensionPoint_GlobalHook_Success) {
759 if (base::win::GetVersion() < base::win::VERSION_WIN8)
760 return;
761
762 HANDLE mutex = ::CreateMutexW(NULL, FALSE, g_extension_point_test_mutex);
763 EXPECT_TRUE(mutex != NULL && mutex != INVALID_HANDLE_VALUE);
764 EXPECT_EQ(WAIT_OBJECT_0,
765 ::WaitForSingleObject(mutex, g_test_mutex_max_wait_ms));
766
767 // (is_success_test, global_hook)
768 TestWin8ExtensionPointHookWrapper(true, true);
769
770 EXPECT_TRUE(::ReleaseMutex(mutex));
771 EXPECT_TRUE(::CloseHandle(mutex));
772 }
773
774 // This test validates that setting the MITIGATION_EXTENSION_POINT_DISABLE
775 // mitigation prevents a global hook on WinProc.
776 //
777 // MANUAL testing only.
778 TEST(ProcessMitigationsTest,
779 DISABLED_CheckWin8ExtensionPoint_GlobalHook_Failure) {
780 if (base::win::GetVersion() < base::win::VERSION_WIN8)
781 return;
782
783 HANDLE mutex = ::CreateMutexW(NULL, FALSE, g_extension_point_test_mutex);
784 EXPECT_TRUE(mutex != NULL && mutex != INVALID_HANDLE_VALUE);
785 EXPECT_EQ(WAIT_OBJECT_0,
786 ::WaitForSingleObject(mutex, g_test_mutex_max_wait_ms));
787
788 // (is_success_test, global_hook)
789 TestWin8ExtensionPointHookWrapper(false, true);
790
791 EXPECT_TRUE(::ReleaseMutex(mutex));
792 EXPECT_TRUE(::CloseHandle(mutex));
793 }
794
795 // This test validates that a "legitimate" hook CAN be set on the sandboxed
796 // proc/thread if the MITIGATION_EXTENSION_POINT_DISABLE mitigation is not set.
797 //
798 // MANUAL testing only.
799 TEST(ProcessMitigationsTest, DISABLED_CheckWin8ExtensionPoint_Hook_Success) {
800 if (base::win::GetVersion() < base::win::VERSION_WIN8)
801 return;
802
803 HANDLE mutex = ::CreateMutexW(NULL, FALSE, g_extension_point_test_mutex);
804 EXPECT_TRUE(mutex != NULL && mutex != INVALID_HANDLE_VALUE);
805 EXPECT_EQ(WAIT_OBJECT_0,
806 ::WaitForSingleObject(mutex, g_test_mutex_max_wait_ms));
807
808 // (is_success_test, global_hook)
809 TestWin8ExtensionPointHookWrapper(true, false);
810
811 EXPECT_TRUE(::ReleaseMutex(mutex));
812 EXPECT_TRUE(::CloseHandle(mutex));
813 }
814
815 // *** Important: MITIGATION_EXTENSION_POINT_DISABLE does NOT prevent
816 // hooks targetted at a specific thread id. It only prevents
817 // global hooks. So this test does NOT actually expect the hook
818 // to fail (see TestWin8ExtensionPointHookWrapper function) even
819 // with the mitigation on.
820 //
821 // MANUAL testing only.
822 TEST(ProcessMitigationsTest, DISABLED_CheckWin8ExtensionPoint_Hook_Failure) {
823 if (base::win::GetVersion() < base::win::VERSION_WIN8)
824 return;
825
826 HANDLE mutex = ::CreateMutexW(NULL, FALSE, g_extension_point_test_mutex);
827 EXPECT_TRUE(mutex != NULL && mutex != INVALID_HANDLE_VALUE);
828 EXPECT_EQ(WAIT_OBJECT_0,
829 ::WaitForSingleObject(mutex, g_test_mutex_max_wait_ms));
830
831 // (is_success_test, global_hook)
832 TestWin8ExtensionPointHookWrapper(false, false);
833
834 EXPECT_TRUE(::ReleaseMutex(mutex));
835 EXPECT_TRUE(::CloseHandle(mutex));
836 }
837
838 // This test validates that an AppInit Dll CAN be added to a target
839 // WinProc if the MITIGATION_EXTENSION_POINT_DISABLE mitigation is not set.
840 //
841 // MANUAL testing only.
842 // Must run this test as admin/elevated.
843 TEST(ProcessMitigationsTest, DISABLED_CheckWin8ExtensionPoint_AppInit_Success) {
844 if (base::win::GetVersion() < base::win::VERSION_WIN8)
845 return;
846
847 HANDLE mutex = ::CreateMutexW(NULL, FALSE, g_extension_point_test_mutex);
848 EXPECT_TRUE(mutex != NULL && mutex != INVALID_HANDLE_VALUE);
849 EXPECT_EQ(WAIT_OBJECT_0,
850 ::WaitForSingleObject(mutex, g_test_mutex_max_wait_ms));
851
852 TestWin8ExtensionPointAppInitWrapper(true);
853
854 EXPECT_TRUE(::ReleaseMutex(mutex));
855 EXPECT_TRUE(::CloseHandle(mutex));
856 }
857
858 // This test validates that setting the MITIGATION_EXTENSION_POINT_DISABLE
859 // mitigation prevents the loading of any AppInit Dll into WinProc.
860 //
861 // MANUAL testing only.
862 // Must run this test as admin/elevated.
863 TEST(ProcessMitigationsTest, DISABLED_CheckWin8ExtensionPoint_AppInit_Failure) {
864 if (base::win::GetVersion() < base::win::VERSION_WIN8)
865 return;
866
867 HANDLE mutex = ::CreateMutexW(NULL, FALSE, g_extension_point_test_mutex);
868 EXPECT_TRUE(mutex != NULL && mutex != INVALID_HANDLE_VALUE);
869 EXPECT_EQ(WAIT_OBJECT_0,
870 ::WaitForSingleObject(mutex, g_test_mutex_max_wait_ms));
871
872 TestWin8ExtensionPointAppInitWrapper(false);
873
874 EXPECT_TRUE(::ReleaseMutex(mutex));
875 EXPECT_TRUE(::CloseHandle(mutex));
876 }
877
878 //------------------------------------------------------------------------------
417 // Disable non-system font loads (MITIGATION_NONSYSTEM_FONT_DISABLE) 879 // Disable non-system font loads (MITIGATION_NONSYSTEM_FONT_DISABLE)
418 // >= Win10 880 // >= Win10
419 //------------------------------------------------------------------------------ 881 //------------------------------------------------------------------------------
420 882
421 SBOX_TESTS_COMMAND int CheckWin10FontLockDown(int argc, wchar_t** argv) { 883 SBOX_TESTS_COMMAND int CheckWin10FontLockDown(int argc, wchar_t** argv) {
422 get_process_mitigation_policy = 884 get_process_mitigation_policy =
423 reinterpret_cast<GetProcessMitigationPolicyFunction>(::GetProcAddress( 885 reinterpret_cast<GetProcessMitigationPolicyFunction>(::GetProcAddress(
424 ::GetModuleHandleW(L"kernel32.dll"), "GetProcessMitigationPolicy")); 886 ::GetModuleHandleW(L"kernel32.dll"), "GetProcessMitigationPolicy"));
425 if (!get_process_mitigation_policy) 887 if (!get_process_mitigation_policy)
426 return SBOX_TEST_NOT_FOUND; 888 return SBOX_TEST_NOT_FOUND;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 policy->SetDelayedProcessMitigations(MITIGATION_IMAGE_LOAD_NO_REMOTE), 1033 policy->SetDelayedProcessMitigations(MITIGATION_IMAGE_LOAD_NO_REMOTE),
572 SBOX_ALL_OK); 1034 SBOX_ALL_OK);
573 EXPECT_EQ(SBOX_TEST_SUCCEEDED, 1035 EXPECT_EQ(SBOX_TEST_SUCCEEDED,
574 runner.RunTest(L"CheckWin10ImageLoadNoRemote")); 1036 runner.RunTest(L"CheckWin10ImageLoadNoRemote"));
575 } 1037 }
576 1038
577 // This test validates that we CAN create a new process from 1039 // This test validates that we CAN create a new process from
578 // a remote UNC device, if the MITIGATION_IMAGE_LOAD_NO_REMOTE 1040 // a remote UNC device, if the MITIGATION_IMAGE_LOAD_NO_REMOTE
579 // mitigation is NOT set. 1041 // mitigation is NOT set.
580 // 1042 //
581 // DISABLED for automated testing bots. Enable for manual testing. 1043 // MANUAL testing only.
582 TEST(ProcessMitigationsTest, DISABLED_CheckWin10ImageLoadNoRemoteSuccess) { 1044 TEST(ProcessMitigationsTest, DISABLED_CheckWin10ImageLoadNoRemoteSuccess) {
583 if (base::win::GetVersion() < base::win::VERSION_WIN10_TH2) 1045 if (base::win::GetVersion() < base::win::VERSION_WIN10_TH2)
584 return; 1046 return;
585 1047
586 TestWin10ImageLoadRemote(true); 1048 TestWin10ImageLoadRemote(true);
587 } 1049 }
588 1050
589 // This test validates that setting the MITIGATION_IMAGE_LOAD_NO_REMOTE 1051 // This test validates that setting the MITIGATION_IMAGE_LOAD_NO_REMOTE
590 // mitigation prevents creating a new process from a remote 1052 // mitigation prevents creating a new process from a remote
591 // UNC device. 1053 // UNC device.
592 // 1054 //
593 // DISABLED for automated testing bots. Enable for manual testing. 1055 // MANUAL testing only.
594 TEST(ProcessMitigationsTest, DISABLED_CheckWin10ImageLoadNoRemoteFailure) { 1056 TEST(ProcessMitigationsTest, DISABLED_CheckWin10ImageLoadNoRemoteFailure) {
595 if (base::win::GetVersion() < base::win::VERSION_WIN10_TH2) 1057 if (base::win::GetVersion() < base::win::VERSION_WIN10_TH2)
596 return; 1058 return;
597 1059
598 TestWin10ImageLoadRemote(false); 1060 TestWin10ImageLoadRemote(false);
599 } 1061 }
600 1062
601 //------------------------------------------------------------------------------ 1063 //------------------------------------------------------------------------------
602 // Disable image load when "mandatory low label" (integrity level). 1064 // Disable image load when "mandatory low label" (integrity level).
603 // (MITIGATION_IMAGE_LOAD_NO_LOW_LABEL) 1065 // (MITIGATION_IMAGE_LOAD_NO_LOW_LABEL)
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 cmd = cmd.Append(L"calc.exe"); 1187 cmd = cmd.Append(L"calc.exe");
726 1188
727 std::wstring test_command(base::StringPrintf(L"TestChildProcess %ls 0x%08X", 1189 std::wstring test_command(base::StringPrintf(L"TestChildProcess %ls 0x%08X",
728 cmd.value().c_str(), 1190 cmd.value().c_str(),
729 STATUS_ACCESS_VIOLATION)); 1191 STATUS_ACCESS_VIOLATION));
730 1192
731 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(test_command.c_str())); 1193 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(test_command.c_str()));
732 } 1194 }
733 1195
734 } // namespace sandbox 1196 } // namespace sandbox
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698