254 lines · plain
1======================================================2Confidential Computing in Linux for x86 virtualization3======================================================4 5.. contents:: :local:6 7By: Elena Reshetova <elena.reshetova@intel.com> and Carlos Bilbao <carlos.bilbao.osdev@gmail.com>8 9Motivation10==========11 12Kernel developers working on confidential computing for virtualized13environments in x86 operate under a set of assumptions regarding the Linux14kernel threat model that differ from the traditional view. Historically,15the Linux threat model acknowledges attackers residing in userspace, as16well as a limited set of external attackers that are able to interact with17the kernel through various networking or limited HW-specific exposed18interfaces (USB, thunderbolt). The goal of this document is to explain19additional attack vectors that arise in the confidential computing space20and discuss the proposed protection mechanisms for the Linux kernel.21 22Overview and terminology23========================24 25Confidential Computing (CoCo) is a broad term covering a wide range of26security technologies that aim to protect the confidentiality and integrity27of data in use (vs. data at rest or data in transit). At its core, CoCo28solutions provide a Trusted Execution Environment (TEE), where secure data29processing can be performed and, as a result, they are typically further30classified into different subtypes depending on the SW that is intended31to be run in TEE. This document focuses on a subclass of CoCo technologies32that are targeting virtualized environments and allow running Virtual33Machines (VM) inside TEE. From now on in this document will be referring34to this subclass of CoCo as 'Confidential Computing (CoCo) for the35virtualized environments (VE)'.36 37CoCo, in the virtualization context, refers to a set of HW and/or SW38technologies that allow for stronger security guarantees for the SW running39inside a CoCo VM. Namely, confidential computing allows its users to40confirm the trustworthiness of all SW pieces to include in its reduced41Trusted Computing Base (TCB) given its ability to attest the state of these42trusted components.43 44While the concrete implementation details differ between technologies, all45available mechanisms aim to provide increased confidentiality and46integrity for the VM's guest memory and execution state (vCPU registers),47more tightly controlled guest interrupt injection, as well as some48additional mechanisms to control guest-host page mapping. More details on49the x86-specific solutions can be found in50:doc:`Intel Trust Domain Extensions (TDX) </arch/x86/tdx>` and51`AMD Memory Encryption <https://www.amd.com/system/files/techdocs/sev-snp-strengthening-vm-isolation-with-integrity-protection-and-more.pdf>`_.52 53The basic CoCo guest layout includes the host, guest, the interfaces that54communicate guest and host, a platform capable of supporting CoCo VMs, and55a trusted intermediary between the guest VM and the underlying platform56that acts as a security manager. The host-side virtual machine monitor57(VMM) typically consists of a subset of traditional VMM features and58is still in charge of the guest lifecycle, i.e. create or destroy a CoCo59VM, manage its access to system resources, etc. However, since it60typically stays out of CoCo VM TCB, its access is limited to preserve the61security objectives.62 63In the following diagram, the "<--->" lines represent bi-directional64communication channels or interfaces between the CoCo security manager and65the rest of the components (data flow for guest, host, hardware) ::66 67 +-------------------+ +-----------------------+68 | CoCo guest VM |<---->| |69 +-------------------+ | |70 | Interfaces | | CoCo security manager |71 +-------------------+ | |72 | Host VMM |<---->| |73 +-------------------+ | |74 | |75 +--------------------+ | |76 | CoCo platform |<--->| |77 +--------------------+ +-----------------------+78 79The specific details of the CoCo security manager vastly diverge between80technologies. For example, in some cases, it will be implemented in HW81while in others it may be pure SW.82 83Existing Linux kernel threat model84==================================85 86The overall components of the current Linux kernel threat model are::87 88 +-----------------------+ +-------------------+89 | |<---->| Userspace |90 | | +-------------------+91 | External attack | | Interfaces |92 | vectors | +-------------------+93 | |<---->| Linux Kernel |94 | | +-------------------+95 +-----------------------+ +-------------------+96 | Bootloader/BIOS |97 +-------------------+98 +-------------------+99 | HW platform |100 +-------------------+101 102There is also communication between the bootloader and the kernel during103the boot process, but this diagram does not represent it explicitly. The104"Interfaces" box represents the various interfaces that allow105communication between kernel and userspace. This includes system calls,106kernel APIs, device drivers, etc.107 108The existing Linux kernel threat model typically assumes execution on a109trusted HW platform with all of the firmware and bootloaders included on110its TCB. The primary attacker resides in the userspace, and all of the data111coming from there is generally considered untrusted, unless userspace is112privileged enough to perform trusted actions. In addition, external113attackers are typically considered, including those with access to enabled114external networks (e.g. Ethernet, Wireless, Bluetooth), exposed hardware115interfaces (e.g. USB, Thunderbolt), and the ability to modify the contents116of disks offline.117 118Regarding external attack vectors, it is interesting to note that in most119cases external attackers will try to exploit vulnerabilities in userspace120first, but that it is possible for an attacker to directly target the121kernel; particularly if the host has physical access. Examples of direct122kernel attacks include the vulnerabilities CVE-2019-19524, CVE-2022-0435123and CVE-2020-24490.124 125Confidential Computing threat model and its security objectives126===============================================================127 128Confidential Computing adds a new type of attacker to the above list: a129potentially misbehaving host (which can also include some part of a130traditional VMM or all of it), which is typically placed outside of the131CoCo VM TCB due to its large SW attack surface. It is important to note132that this doesn’t imply that the host or VMM are intentionally133malicious, but that there exists a security value in having a small CoCo134VM TCB. This new type of adversary may be viewed as a more powerful type135of external attacker, as it resides locally on the same physical machine136(in contrast to a remote network attacker) and has control over the guest137kernel communication with most of the HW::138 139 +------------------------+140 | CoCo guest VM |141 +-----------------------+ | +-------------------+ |142 | |<--->| | Userspace | |143 | | | +-------------------+ |144 | External attack | | | Interfaces | |145 | vectors | | +-------------------+ |146 | |<--->| | Linux Kernel | |147 | | | +-------------------+ |148 +-----------------------+ | +-------------------+ |149 | | Bootloader/BIOS | |150 +-----------------------+ | +-------------------+ |151 | |<--->+------------------------+152 | | | Interfaces |153 | | +------------------------+154 | CoCo security |<--->| Host/Host-side VMM |155 | manager | +------------------------+156 | | +------------------------+157 | |<--->| CoCo platform |158 +-----------------------+ +------------------------+159 160While traditionally the host has unlimited access to guest data and can161leverage this access to attack the guest, the CoCo systems mitigate such162attacks by adding security features like guest data confidentiality and163integrity protection. This threat model assumes that those features are164available and intact.165 166The **Linux kernel CoCo VM security objectives** can be summarized as follows:167 1681. Preserve the confidentiality and integrity of CoCo guest's private169memory and registers.170 1712. Prevent privileged escalation from a host into a CoCo guest Linux kernel.172While it is true that the host (and host-side VMM) requires some level of173privilege to create, destroy, or pause the guest, part of the goal of174preventing privileged escalation is to ensure that these operations do not175provide a pathway for attackers to gain access to the guest's kernel.176 177The above security objectives result in two primary **Linux kernel CoCo178VM assets**:179 1801. Guest kernel execution context.1812. Guest kernel private memory.182 183The host retains full control over the CoCo guest resources, and can deny184access to them at any time. Examples of resources include CPU time, memory185that the guest can consume, network bandwidth, etc. Because of this, the186host Denial of Service (DoS) attacks against CoCo guests are beyond the187scope of this threat model.188 189The **Linux CoCo VM attack surface** is any interface exposed from a CoCo190guest Linux kernel towards an untrusted host that is not covered by the191CoCo technology SW/HW protection. This includes any possible192side-channels, as well as transient execution side channels. Examples of193explicit (not side-channel) interfaces include accesses to port I/O, MMIO194and DMA interfaces, access to PCI configuration space, VMM-specific195hypercalls (towards Host-side VMM), access to shared memory pages,196interrupts allowed to be injected into the guest kernel by the host, as197well as CoCo technology-specific hypercalls, if present. Additionally, the198host in a CoCo system typically controls the process of creating a CoCo199guest: it has a method to load into a guest the firmware and bootloader200images, the kernel image together with the kernel command line. All of this201data should also be considered untrusted until its integrity and202authenticity is established via attestation.203 204The table below shows a threat matrix for the CoCo guest Linux kernel but205does not discuss potential mitigation strategies. The matrix refers to206CoCo-specific versions of the guest, host and platform.207 208.. list-table:: CoCo Linux guest kernel threat matrix209 :widths: auto210 :align: center211 :header-rows: 1212 213 * - Threat name214 - Threat description215 216 * - Guest malicious configuration217 - A misbehaving host modifies one of the following guest's218 configuration:219 220 1. Guest firmware or bootloader221 222 2. Guest kernel or module binaries223 224 3. Guest command line parameters225 226 This allows the host to break the integrity of the code running227 inside a CoCo guest, and violates the CoCo security objectives.228 229 * - CoCo guest data attacks230 - A misbehaving host retains full control of the CoCo guest's data231 in-transit between the guest and the host-managed physical or232 virtual devices. This allows any attack against confidentiality,233 integrity or freshness of such data.234 235 * - Malformed runtime input236 - A misbehaving host injects malformed input via any communication237 interface used by the guest's kernel code. If the code is not238 prepared to handle this input correctly, this can result in a host239 --> guest kernel privilege escalation. This includes traditional240 side-channel and/or transient execution attack vectors.241 242 * - Malicious runtime input243 - A misbehaving host injects a specific input value via any244 communication interface used by the guest's kernel code. The245 difference with the previous attack vector (malformed runtime input)246 is that this input is not malformed, but its value is crafted to247 impact the guest's kernel security. Examples of such inputs include248 providing a malicious time to the guest or the entropy to the guest249 random number generator. Additionally, the timing of such events can250 be an attack vector on its own, if it results in a particular guest251 kernel action (i.e. processing of a host-injected interrupt).252 resistant to supplied host input.253 254