snp-tdx-threat-model.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. ======================================================
  2. Confidential Computing in Linux for x86 virtualization
  3. ======================================================
  4. .. contents:: :local:
  5. By: Elena Reshetova <elena.reshetova@intel.com> and Carlos Bilbao <carlos.bilbao.osdev@gmail.com>
  6. Motivation
  7. ==========
  8. Kernel developers working on confidential computing for virtualized
  9. environments in x86 operate under a set of assumptions regarding the Linux
  10. kernel threat model that differ from the traditional view. Historically,
  11. the Linux threat model acknowledges attackers residing in userspace, as
  12. well as a limited set of external attackers that are able to interact with
  13. the kernel through various networking or limited HW-specific exposed
  14. interfaces (USB, thunderbolt). The goal of this document is to explain
  15. additional attack vectors that arise in the confidential computing space
  16. and discuss the proposed protection mechanisms for the Linux kernel.
  17. Overview and terminology
  18. ========================
  19. Confidential Computing (CoCo) is a broad term covering a wide range of
  20. security technologies that aim to protect the confidentiality and integrity
  21. of data in use (vs. data at rest or data in transit). At its core, CoCo
  22. solutions provide a Trusted Execution Environment (TEE), where secure data
  23. processing can be performed and, as a result, they are typically further
  24. classified into different subtypes depending on the SW that is intended
  25. to be run in TEE. This document focuses on a subclass of CoCo technologies
  26. that are targeting virtualized environments and allow running Virtual
  27. Machines (VM) inside TEE. From now on in this document will be referring
  28. to this subclass of CoCo as 'Confidential Computing (CoCo) for the
  29. virtualized environments (VE)'.
  30. CoCo, in the virtualization context, refers to a set of HW and/or SW
  31. technologies that allow for stronger security guarantees for the SW running
  32. inside a CoCo VM. Namely, confidential computing allows its users to
  33. confirm the trustworthiness of all SW pieces to include in its reduced
  34. Trusted Computing Base (TCB) given its ability to attest the state of these
  35. trusted components.
  36. While the concrete implementation details differ between technologies, all
  37. available mechanisms aim to provide increased confidentiality and
  38. integrity for the VM's guest memory and execution state (vCPU registers),
  39. more tightly controlled guest interrupt injection, as well as some
  40. additional mechanisms to control guest-host page mapping. More details on
  41. the x86-specific solutions can be found in
  42. :doc:`Intel Trust Domain Extensions (TDX) </arch/x86/tdx>` and
  43. `AMD Memory Encryption <https://www.amd.com/system/files/techdocs/sev-snp-strengthening-vm-isolation-with-integrity-protection-and-more.pdf>`_.
  44. The basic CoCo guest layout includes the host, guest, the interfaces that
  45. communicate guest and host, a platform capable of supporting CoCo VMs, and
  46. a trusted intermediary between the guest VM and the underlying platform
  47. that acts as a security manager. The host-side virtual machine monitor
  48. (VMM) typically consists of a subset of traditional VMM features and
  49. is still in charge of the guest lifecycle, i.e. create or destroy a CoCo
  50. VM, manage its access to system resources, etc. However, since it
  51. typically stays out of CoCo VM TCB, its access is limited to preserve the
  52. security objectives.
  53. In the following diagram, the "<--->" lines represent bi-directional
  54. communication channels or interfaces between the CoCo security manager and
  55. the rest of the components (data flow for guest, host, hardware) ::
  56. +-------------------+ +-----------------------+
  57. | CoCo guest VM |<---->| |
  58. +-------------------+ | |
  59. | Interfaces | | CoCo security manager |
  60. +-------------------+ | |
  61. | Host VMM |<---->| |
  62. +-------------------+ | |
  63. | |
  64. +--------------------+ | |
  65. | CoCo platform |<--->| |
  66. +--------------------+ +-----------------------+
  67. The specific details of the CoCo security manager vastly diverge between
  68. technologies. For example, in some cases, it will be implemented in HW
  69. while in others it may be pure SW.
  70. Existing Linux kernel threat model
  71. ==================================
  72. The overall components of the current Linux kernel threat model are::
  73. +-----------------------+ +-------------------+
  74. | |<---->| Userspace |
  75. | | +-------------------+
  76. | External attack | | Interfaces |
  77. | vectors | +-------------------+
  78. | |<---->| Linux Kernel |
  79. | | +-------------------+
  80. +-----------------------+ +-------------------+
  81. | Bootloader/BIOS |
  82. +-------------------+
  83. +-------------------+
  84. | HW platform |
  85. +-------------------+
  86. There is also communication between the bootloader and the kernel during
  87. the boot process, but this diagram does not represent it explicitly. The
  88. "Interfaces" box represents the various interfaces that allow
  89. communication between kernel and userspace. This includes system calls,
  90. kernel APIs, device drivers, etc.
  91. The existing Linux kernel threat model typically assumes execution on a
  92. trusted HW platform with all of the firmware and bootloaders included on
  93. its TCB. The primary attacker resides in the userspace, and all of the data
  94. coming from there is generally considered untrusted, unless userspace is
  95. privileged enough to perform trusted actions. In addition, external
  96. attackers are typically considered, including those with access to enabled
  97. external networks (e.g. Ethernet, Wireless, Bluetooth), exposed hardware
  98. interfaces (e.g. USB, Thunderbolt), and the ability to modify the contents
  99. of disks offline.
  100. Regarding external attack vectors, it is interesting to note that in most
  101. cases external attackers will try to exploit vulnerabilities in userspace
  102. first, but that it is possible for an attacker to directly target the
  103. kernel; particularly if the host has physical access. Examples of direct
  104. kernel attacks include the vulnerabilities CVE-2019-19524, CVE-2022-0435
  105. and CVE-2020-24490.
  106. Confidential Computing threat model and its security objectives
  107. ===============================================================
  108. Confidential Computing adds a new type of attacker to the above list: a
  109. potentially misbehaving host (which can also include some part of a
  110. traditional VMM or all of it), which is typically placed outside of the
  111. CoCo VM TCB due to its large SW attack surface. It is important to note
  112. that this doesn’t imply that the host or VMM are intentionally
  113. malicious, but that there exists a security value in having a small CoCo
  114. VM TCB. This new type of adversary may be viewed as a more powerful type
  115. of external attacker, as it resides locally on the same physical machine
  116. (in contrast to a remote network attacker) and has control over the guest
  117. kernel communication with most of the HW::
  118. +------------------------+
  119. | CoCo guest VM |
  120. +-----------------------+ | +-------------------+ |
  121. | |<--->| | Userspace | |
  122. | | | +-------------------+ |
  123. | External attack | | | Interfaces | |
  124. | vectors | | +-------------------+ |
  125. | |<--->| | Linux Kernel | |
  126. | | | +-------------------+ |
  127. +-----------------------+ | +-------------------+ |
  128. | | Bootloader/BIOS | |
  129. +-----------------------+ | +-------------------+ |
  130. | |<--->+------------------------+
  131. | | | Interfaces |
  132. | | +------------------------+
  133. | CoCo security |<--->| Host/Host-side VMM |
  134. | manager | +------------------------+
  135. | | +------------------------+
  136. | |<--->| CoCo platform |
  137. +-----------------------+ +------------------------+
  138. While traditionally the host has unlimited access to guest data and can
  139. leverage this access to attack the guest, the CoCo systems mitigate such
  140. attacks by adding security features like guest data confidentiality and
  141. integrity protection. This threat model assumes that those features are
  142. available and intact.
  143. The **Linux kernel CoCo VM security objectives** can be summarized as follows:
  144. 1. Preserve the confidentiality and integrity of CoCo guest's private
  145. memory and registers.
  146. 2. Prevent privileged escalation from a host into a CoCo guest Linux kernel.
  147. While it is true that the host (and host-side VMM) requires some level of
  148. privilege to create, destroy, or pause the guest, part of the goal of
  149. preventing privileged escalation is to ensure that these operations do not
  150. provide a pathway for attackers to gain access to the guest's kernel.
  151. The above security objectives result in two primary **Linux kernel CoCo
  152. VM assets**:
  153. 1. Guest kernel execution context.
  154. 2. Guest kernel private memory.
  155. The host retains full control over the CoCo guest resources, and can deny
  156. access to them at any time. Examples of resources include CPU time, memory
  157. that the guest can consume, network bandwidth, etc. Because of this, the
  158. host Denial of Service (DoS) attacks against CoCo guests are beyond the
  159. scope of this threat model.
  160. The **Linux CoCo VM attack surface** is any interface exposed from a CoCo
  161. guest Linux kernel towards an untrusted host that is not covered by the
  162. CoCo technology SW/HW protection. This includes any possible
  163. side-channels, as well as transient execution side channels. Examples of
  164. explicit (not side-channel) interfaces include accesses to port I/O, MMIO
  165. and DMA interfaces, access to PCI configuration space, VMM-specific
  166. hypercalls (towards Host-side VMM), access to shared memory pages,
  167. interrupts allowed to be injected into the guest kernel by the host, as
  168. well as CoCo technology-specific hypercalls, if present. Additionally, the
  169. host in a CoCo system typically controls the process of creating a CoCo
  170. guest: it has a method to load into a guest the firmware and bootloader
  171. images, the kernel image together with the kernel command line. All of this
  172. data should also be considered untrusted until its integrity and
  173. authenticity is established via attestation.
  174. The table below shows a threat matrix for the CoCo guest Linux kernel but
  175. does not discuss potential mitigation strategies. The matrix refers to
  176. CoCo-specific versions of the guest, host and platform.
  177. .. list-table:: CoCo Linux guest kernel threat matrix
  178. :widths: auto
  179. :align: center
  180. :header-rows: 1
  181. * - Threat name
  182. - Threat description
  183. * - Guest malicious configuration
  184. - A misbehaving host modifies one of the following guest's
  185. configuration:
  186. 1. Guest firmware or bootloader
  187. 2. Guest kernel or module binaries
  188. 3. Guest command line parameters
  189. This allows the host to break the integrity of the code running
  190. inside a CoCo guest, and violates the CoCo security objectives.
  191. * - CoCo guest data attacks
  192. - A misbehaving host retains full control of the CoCo guest's data
  193. in-transit between the guest and the host-managed physical or
  194. virtual devices. This allows any attack against confidentiality,
  195. integrity or freshness of such data.
  196. * - Malformed runtime input
  197. - A misbehaving host injects malformed input via any communication
  198. interface used by the guest's kernel code. If the code is not
  199. prepared to handle this input correctly, this can result in a host
  200. --> guest kernel privilege escalation. This includes traditional
  201. side-channel and/or transient execution attack vectors.
  202. * - Malicious runtime input
  203. - A misbehaving host injects a specific input value via any
  204. communication interface used by the guest's kernel code. The
  205. difference with the previous attack vector (malformed runtime input)
  206. is that this input is not malformed, but its value is crafted to
  207. impact the guest's kernel security. Examples of such inputs include
  208. providing a malicious time to the guest or the entropy to the guest
  209. random number generator. Additionally, the timing of such events can
  210. be an attack vector on its own, if it results in a particular guest
  211. kernel action (i.e. processing of a host-injected interrupt).
  212. resistant to supplied host input.