PageRenderTime 54ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/sandbox/win/src/security_level.h

https://gitlab.com/0072016/Facebook-SDK-
C Header | 221 lines | 51 code | 25 blank | 145 comment | 0 complexity | 6ae23bceb813e4f479d2e20b0dc5009e MD5 | raw file
  1. // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef SANDBOX_SRC_SECURITY_LEVEL_H_
  5. #define SANDBOX_SRC_SECURITY_LEVEL_H_
  6. #include <stdint.h>
  7. namespace sandbox {
  8. // List of all the integrity levels supported in the sandbox. This is used
  9. // only on Windows Vista. You can't set the integrity level of the process
  10. // in the sandbox to a level higher than yours.
  11. enum IntegrityLevel {
  12. INTEGRITY_LEVEL_SYSTEM,
  13. INTEGRITY_LEVEL_HIGH,
  14. INTEGRITY_LEVEL_MEDIUM,
  15. INTEGRITY_LEVEL_MEDIUM_LOW,
  16. INTEGRITY_LEVEL_LOW,
  17. INTEGRITY_LEVEL_BELOW_LOW,
  18. INTEGRITY_LEVEL_UNTRUSTED,
  19. INTEGRITY_LEVEL_LAST
  20. };
  21. // The Token level specifies a set of security profiles designed to
  22. // provide the bulk of the security of sandbox.
  23. //
  24. // TokenLevel |Restricting |Deny Only |Privileges|
  25. // |Sids |Sids | |
  26. // ----------------------------|--------------|----------------|----------|
  27. // USER_LOCKDOWN | Null Sid | All | None |
  28. // ----------------------------|--------------|----------------|----------|
  29. // USER_RESTRICTED | RESTRICTED | All | Traverse |
  30. // ----------------------------|--------------|----------------|----------|
  31. // USER_LIMITED | Users | All except: | Traverse |
  32. // | Everyone | Users | |
  33. // | RESTRICTED | Everyone | |
  34. // | | Interactive | |
  35. // ----------------------------|--------------|----------------|----------|
  36. // USER_INTERACTIVE | Users | All except: | Traverse |
  37. // | Everyone | Users | |
  38. // | RESTRICTED | Everyone | |
  39. // | Owner | Interactive | |
  40. // | | Local | |
  41. // | | Authent-users | |
  42. // | | User | |
  43. // ----------------------------|--------------|----------------|----------|
  44. // USER_NON_ADMIN | None | All except: | Traverse |
  45. // | | Users | |
  46. // | | Everyone | |
  47. // | | Interactive | |
  48. // | | Local | |
  49. // | | Authent-users | |
  50. // | | User | |
  51. // ----------------------------|--------------|----------------|----------|
  52. // USER_RESTRICTED_SAME_ACCESS | All | None | All |
  53. // ----------------------------|--------------|----------------|----------|
  54. // USER_UNPROTECTED | None | None | All |
  55. // ----------------------------|--------------|----------------|----------|
  56. //
  57. // The above restrictions are actually a transformation that is applied to
  58. // the existing broker process token. The resulting token that will be
  59. // applied to the target process depends both on the token level selected
  60. // and on the broker token itself.
  61. //
  62. // The LOCKDOWN and RESTRICTED are designed to allow access to almost
  63. // nothing that has security associated with and they are the recommended
  64. // levels to run sandboxed code specially if there is a chance that the
  65. // broker is process might be started by a user that belongs to the Admins
  66. // or power users groups.
  67. enum TokenLevel {
  68. USER_LOCKDOWN = 0,
  69. USER_RESTRICTED,
  70. USER_LIMITED,
  71. USER_INTERACTIVE,
  72. USER_NON_ADMIN,
  73. USER_RESTRICTED_SAME_ACCESS,
  74. USER_UNPROTECTED,
  75. USER_LAST
  76. };
  77. // The Job level specifies a set of decreasing security profiles for the
  78. // Job object that the target process will be placed into.
  79. // This table summarizes the security associated with each level:
  80. //
  81. // JobLevel |General |Quota |
  82. // |restrictions |restrictions |
  83. // -----------------|---------------------------------- |--------------------|
  84. // JOB_NONE | No job is assigned to the | None |
  85. // | sandboxed process. | |
  86. // -----------------|---------------------------------- |--------------------|
  87. // JOB_UNPROTECTED | None | *Kill on Job close.|
  88. // -----------------|---------------------------------- |--------------------|
  89. // JOB_INTERACTIVE | *Forbid system-wide changes using | |
  90. // | SystemParametersInfo(). | *Kill on Job close.|
  91. // | *Forbid the creation/switch of | |
  92. // | Desktops. | |
  93. // | *Forbids calls to ExitWindows(). | |
  94. // -----------------|---------------------------------- |--------------------|
  95. // JOB_LIMITED_USER | Same as INTERACTIVE_USER plus: | *One active process|
  96. // | *Forbid changes to the display | limit. |
  97. // | settings. | *Kill on Job close.|
  98. // -----------------|---------------------------------- |--------------------|
  99. // JOB_RESTRICTED | Same as LIMITED_USER plus: | *One active process|
  100. // | * No read/write to the clipboard. | limit. |
  101. // | * No access to User Handles that | *Kill on Job close.|
  102. // | belong to other processes. | |
  103. // | * Forbid message broadcasts. | |
  104. // | * Forbid setting global hooks. | |
  105. // | * No access to the global atoms | |
  106. // | table. | |
  107. // -----------------|-----------------------------------|--------------------|
  108. // JOB_LOCKDOWN | Same as RESTRICTED | *One active process|
  109. // | | limit. |
  110. // | | *Kill on Job close.|
  111. // | | *Kill on unhandled |
  112. // | | exception. |
  113. // | | |
  114. // In the context of the above table, 'user handles' refers to the handles of
  115. // windows, bitmaps, menus, etc. Files, treads and registry handles are kernel
  116. // handles and are not affected by the job level settings.
  117. enum JobLevel {
  118. JOB_LOCKDOWN = 0,
  119. JOB_RESTRICTED,
  120. JOB_LIMITED_USER,
  121. JOB_INTERACTIVE,
  122. JOB_UNPROTECTED,
  123. JOB_NONE
  124. };
  125. // These flags correspond to various process-level mitigations (eg. ASLR and
  126. // DEP). Most are implemented via UpdateProcThreadAttribute() plus flags for
  127. // the PROC_THREAD_ATTRIBUTE_MITIGATION_POLICY attribute argument; documented
  128. // here: http://msdn.microsoft.com/en-us/library/windows/desktop/ms686880
  129. // Some mitigations are implemented directly by the sandbox or emulated to
  130. // the greatest extent possible when not directly supported by the OS.
  131. // Flags that are unsupported for the target OS will be silently ignored.
  132. // Flags that are invalid for their application (pre or post startup) will
  133. // return SBOX_ERROR_BAD_PARAMS.
  134. typedef uint64_t MitigationFlags;
  135. // Permanently enables DEP for the target process. Corresponds to
  136. // PROCESS_CREATION_MITIGATION_POLICY_DEP_ENABLE.
  137. const MitigationFlags MITIGATION_DEP = 0x00000001;
  138. // Permanently Disables ATL thunk emulation when DEP is enabled. Valid
  139. // only when MITIGATION_DEP is passed. Corresponds to not passing
  140. // PROCESS_CREATION_MITIGATION_POLICY_DEP_ATL_THUNK_ENABLE.
  141. const MitigationFlags MITIGATION_DEP_NO_ATL_THUNK = 0x00000002;
  142. // Enables Structured exception handling override prevention. Must be
  143. // enabled prior to process start. Corresponds to
  144. // PROCESS_CREATION_MITIGATION_POLICY_SEHOP_ENABLE.
  145. const MitigationFlags MITIGATION_SEHOP = 0x00000004;
  146. // Forces ASLR on all images in the child process. Corresponds to
  147. // PROCESS_CREATION_MITIGATION_POLICY_FORCE_RELOCATE_IMAGES_ALWAYS_ON .
  148. const MitigationFlags MITIGATION_RELOCATE_IMAGE = 0x00000008;
  149. // Refuses to load DLLs that cannot support ASLR. Corresponds to
  150. // PROCESS_CREATION_MITIGATION_POLICY_FORCE_RELOCATE_IMAGES_ALWAYS_ON_REQ_RELOCS.
  151. const MitigationFlags MITIGATION_RELOCATE_IMAGE_REQUIRED = 0x00000010;
  152. // Terminates the process on Windows heap corruption. Coresponds to
  153. // PROCESS_CREATION_MITIGATION_POLICY_HEAP_TERMINATE_ALWAYS_ON.
  154. const MitigationFlags MITIGATION_HEAP_TERMINATE = 0x00000020;
  155. // Sets a random lower bound as the minimum user address. Must be
  156. // enabled prior to process start. On 32-bit processes this is
  157. // emulated to a much smaller degree. Corresponds to
  158. // PROCESS_CREATION_MITIGATION_POLICY_BOTTOM_UP_ASLR_ALWAYS_ON.
  159. const MitigationFlags MITIGATION_BOTTOM_UP_ASLR = 0x00000040;
  160. // Increases the randomness range of bottom-up ASLR to up to 1TB. Must be
  161. // enabled prior to process start and with MITIGATION_BOTTOM_UP_ASLR.
  162. // Corresponds to
  163. // PROCESS_CREATION_MITIGATION_POLICY_HIGH_ENTROPY_ASLR_ALWAYS_ON
  164. const MitigationFlags MITIGATION_HIGH_ENTROPY_ASLR = 0x00000080;
  165. // Immediately raises an exception on a bad handle reference. Must be
  166. // enabled after startup. Corresponds to
  167. // PROCESS_CREATION_MITIGATION_POLICY_STRICT_HANDLE_CHECKS_ALWAYS_ON.
  168. const MitigationFlags MITIGATION_STRICT_HANDLE_CHECKS = 0x00000100;
  169. // Prevents the process from making Win32k calls. Corresponds to
  170. // PROCESS_CREATION_MITIGATION_POLICY_WIN32K_SYSTEM_CALL_DISABLE_ALWAYS_ON.
  171. const MitigationFlags MITIGATION_WIN32K_DISABLE = 0x00000200;
  172. // Disables common DLL injection methods (e.g. window hooks and
  173. // App_InitDLLs). Corresponds to
  174. // PROCESS_CREATION_MITIGATION_POLICY_EXTENSION_POINT_DISABLE_ALWAYS_ON.
  175. const MitigationFlags MITIGATION_EXTENSION_DLL_DISABLE = 0x00000400;
  176. // Prevents the process from loading non-system fonts into GDI.
  177. // Corresponds to
  178. // PROCESS_CREATION_MITIGATION_POLICY_FONT_DISABLE_ALWAYS_ON
  179. const MitigationFlags MITIGATION_NONSYSTEM_FONT_DISABLE = 0x00000800;
  180. // Sets the DLL search order to LOAD_LIBRARY_SEARCH_DEFAULT_DIRS. Additional
  181. // directories can be added via the Windows AddDllDirectory() function.
  182. // http://msdn.microsoft.com/en-us/library/windows/desktop/hh310515
  183. // Must be enabled after startup.
  184. const MitigationFlags MITIGATION_DLL_SEARCH_ORDER = 0x00000001ULL << 32;
  185. // Changes the mandatory integrity level policy on the current process' token
  186. // to enable no-read and no-execute up. This prevents a lower IL process from
  187. // opening the process token for impersonate/duplicate/assignment.
  188. const MitigationFlags MITIGATION_HARDEN_TOKEN_IL_POLICY = 0x00000001ULL << 33;
  189. // Blocks mapping of images from remote devices. Corresponds to
  190. // PROCESS_CREATION_MITIGATION_POLICY_IMAGE_LOAD_NO_REMOTE_ALWAYS_ON.
  191. const MitigationFlags MITIGATION_IMAGE_LOAD_NO_REMOTE = 0x00000001ULL << 52;
  192. // Blocks mapping of images that have the low manditory label. Corresponds to
  193. // PROCESS_CREATION_MITIGATION_POLICY_IMAGE_LOAD_NO_LOW_LABEL_ALWAYS_ON.
  194. const MitigationFlags MITIGATION_IMAGE_LOAD_NO_LOW_LABEL = 0x00000001ULL << 56;
  195. } // namespace sandbox
  196. #endif // SANDBOX_SRC_SECURITY_LEVEL_H_