OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef SANDBOX_WIN_SRC_SANDBOX_POLICY_H_ | 5 #ifndef SANDBOX_WIN_SRC_SANDBOX_POLICY_H_ |
6 #define SANDBOX_WIN_SRC_SANDBOX_POLICY_H_ | 6 #define SANDBOX_WIN_SRC_SANDBOX_POLICY_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 // launching the sandboxed process will fail. See BrokerServices for details | 157 // launching the sandboxed process will fail. See BrokerServices for details |
158 // about installing an AppContainer. | 158 // about installing an AppContainer. |
159 // Note that currently Windows restricts the use of impersonation within | 159 // Note that currently Windows restricts the use of impersonation within |
160 // AppContainers, so this function is incompatible with the use of an initial | 160 // AppContainers, so this function is incompatible with the use of an initial |
161 // token. | 161 // token. |
162 virtual ResultCode SetAppContainer(const wchar_t* sid) = 0; | 162 virtual ResultCode SetAppContainer(const wchar_t* sid) = 0; |
163 | 163 |
164 // Sets a capability to be enabled for the sandboxed process' AppContainer. | 164 // Sets a capability to be enabled for the sandboxed process' AppContainer. |
165 virtual ResultCode SetCapability(const wchar_t* sid) = 0; | 165 virtual ResultCode SetCapability(const wchar_t* sid) = 0; |
166 | 166 |
| 167 // These flags correspond to various process-level mitigations (eg. ASLR and |
| 168 // DEP). Most are implemented via UpdateProcThreadAttribute() plus flags for |
| 169 // the PROC_THREAD_ATTRIBUTE_MITIGATION_POLICY attribute argument; documented |
| 170 // here: http://msdn.microsoft.com/en-us/library/windows/desktop/ms686880 |
| 171 // Some mitigations are implemented directly by the sandbox or emulated to |
| 172 // the greatest extent possible when not directly supported by the OS. |
| 173 // Flags that are unsupported for the target OS will be silently ignored. |
| 174 // Flags that are invalid for their application (pre or post startup) will |
| 175 // return SBOX_ERROR_BAD_PARAMS. |
| 176 // |
| 177 // Permanently enables DEP for the target process. Corresponds to |
| 178 // PROCESS_CREATION_MITIGATION_POLICY_DEP_ENABLE. |
| 179 static const uint64 MITIGATION_DEP = 0x00000001; |
| 180 // Permanently Disables ATL thunk emulation when DEP is enabled. Valid |
| 181 // only when MITIGATION_DEP is passed. Corresponds to not passing |
| 182 // PROCESS_CREATION_MITIGATION_POLICY_DEP_ATL_THUNK_ENABLE. |
| 183 static const uint64 MITIGATION_DEP_NO_ATL_THUNK = 0x00000002; |
| 184 // Enables Structured exception handling override prevention. Must be |
| 185 // enabled prior to process start. Corresponds to |
| 186 // PROCESS_CREATION_MITIGATION_POLICY_SEHOP_ENABLE. |
| 187 static const uint64 MITIGATION_SEHOP = 0x00000004; |
| 188 // Forces ASLR on all images in the child process. Corresponds to |
| 189 // PROCESS_CREATION_MITIGATION_POLICY_FORCE_RELOCATE_IMAGES_ALWAYS_ON . |
| 190 static const uint64 MITIGATION_RELOCATE_IMAGE = 0x00000008; |
| 191 // Refuses to load DLLs that cannot support ASLR. Corresponds to |
| 192 // PROCESS_CREATION_MITIGATION_POLICY_FORCE_RELOCATE_IMAGES_ALWAYS_ON_REQ_RELO
CS. |
| 193 static const uint64 MITIGATION_RELOCATE_IMAGE_REQUIRED = 0x00000010; |
| 194 // Terminates the process on Windows heap corruption. Coresponds to |
| 195 // PROCESS_CREATION_MITIGATION_POLICY_HEAP_TERMINATE_ALWAYS_ON. |
| 196 static const uint64 MITIGATION_HEAP_TERMINATE = 0x00000020; |
| 197 // Sets a random lower bound as the minimum user address. Must be |
| 198 // enabled prior to process start. On 32-bit processes this is |
| 199 // emulated to a much smaller degree. Corresponds to |
| 200 // PROCESS_CREATION_MITIGATION_POLICY_BOTTOM_UP_ASLR_ALWAYS_ON. |
| 201 static const uint64 MITIGATION_BOTTOM_UP_ASLR = 0x00000040; |
| 202 // Increases the randomness range of bottom-up ASLR to up to 1TB. Must be |
| 203 // enabled prior to process start and with MITIGATION_BOTTOM_UP_ASLR. |
| 204 // Corresponds to |
| 205 // PROCESS_CREATION_MITIGATION_POLICY_HIGH_ENTROPY_ASLR_ALWAYS_ON |
| 206 static const uint64 MITIGATION_HIGH_ENTROPY_ASLR = 0x00000080; |
| 207 // Immediately raises an exception on a bad handle reference. Must be |
| 208 // enabled after startup. Corresponds to |
| 209 // PROCESS_CREATION_MITIGATION_POLICY_STRICT_HANDLE_CHECKS_ALWAYS_ON. |
| 210 static const uint64 MITIGATION_STRICT_HANDLE_CHECKS = 0x00000100; |
| 211 // Prevents the process from making Win32k calls. Must be enabled after |
| 212 // startup. Corresponds to |
| 213 // PROCESS_CREATION_MITIGATION_POLICY_WIN32K_SYSTEM_CALL_DISABLE_ALWAYS_ON. |
| 214 static const uint64 MITIGATION_WIN32K_DISABLE = 0x00000200; |
| 215 // Disables common DLL injection methods (e.g. window hooks and |
| 216 // App_InitDLLs). Corresponds to |
| 217 // PROCESS_CREATION_MITIGATION_POLICY_EXTENSION_POINT_DISABLE_ALWAYS_ON. |
| 218 static const uint64 MITIGATION_EXTENSION_DLL_DISABLE = 0x00000400; |
| 219 // Sets the DLL search order to LOAD_LIBRARY_SEARCH_DEFAULT_DIRS. Additional |
| 220 // directories can be added via the Windows AddDllDirectory() function. |
| 221 // http://msdn.microsoft.com/en-us/library/windows/desktop/hh310515 |
| 222 // Must be enabled after startup. |
| 223 static const uint64 MITIGATION_DLL_SEARCH_ORDER = 0x00000001ULL << 32; |
| 224 |
| 225 // Sets the mitigation flags (described above) for starting the process. |
| 226 virtual ResultCode SetProcessMitigations(uint64 flags) = 0; |
| 227 |
| 228 // Returns the currently set mitigation flags (described above). |
| 229 virtual uint64 GetProcessMitigations() = 0; |
| 230 |
| 231 // Sets the process mitigation flags. These flags will not take effect |
| 232 // in the call to LowerToken (described above). |
| 233 virtual ResultCode SetDelayedProcessMitigations(uint64 flags) = 0; |
| 234 |
| 235 // Returns the currently set delayed mitigation flags (described above). |
| 236 virtual uint64 GetDelayedProcessMitigations() = 0; |
| 237 |
167 // Sets the interceptions to operate in strict mode. By default, interceptions | 238 // Sets the interceptions to operate in strict mode. By default, interceptions |
168 // are performed in "relaxed" mode, where if something inside NTDLL.DLL is | 239 // are performed in "relaxed" mode, where if something inside NTDLL.DLL is |
169 // already patched we attempt to intercept it anyway. Setting interceptions | 240 // already patched we attempt to intercept it anyway. Setting interceptions |
170 // to strict mode means that when we detect that the function is patched we'll | 241 // to strict mode means that when we detect that the function is patched we'll |
171 // refuse to perform the interception. | 242 // refuse to perform the interception. |
172 virtual void SetStrictInterceptions() = 0; | 243 virtual void SetStrictInterceptions() = 0; |
173 | 244 |
174 // Adds a policy rule effective for processes spawned using this policy. | 245 // Adds a policy rule effective for processes spawned using this policy. |
175 // subsystem: One of the above enumerated windows subsystems. | 246 // subsystem: One of the above enumerated windows subsystems. |
176 // semantics: One of the above enumerated FileSemantics. | 247 // semantics: One of the above enumerated FileSemantics. |
(...skipping 17 matching lines...) Expand all Loading... |
194 // A NULL value for handle_name indicates all handles of the specified type. | 265 // A NULL value for handle_name indicates all handles of the specified type. |
195 // An empty string for handle_name indicates the handle is unnamed. | 266 // An empty string for handle_name indicates the handle is unnamed. |
196 virtual ResultCode AddKernelObjectToClose(const wchar_t* handle_type, | 267 virtual ResultCode AddKernelObjectToClose(const wchar_t* handle_type, |
197 const wchar_t* handle_name) = 0; | 268 const wchar_t* handle_name) = 0; |
198 }; | 269 }; |
199 | 270 |
200 } // namespace sandbox | 271 } // namespace sandbox |
201 | 272 |
202 | 273 |
203 #endif // SANDBOX_WIN_SRC_SANDBOX_POLICY_H_ | 274 #endif // SANDBOX_WIN_SRC_SANDBOX_POLICY_H_ |
OLD | NEW |