diff --git a/107-tee-boot-attestation.md b/107-tee-boot-attestation.md new file mode 100644 index 0000000..566bde2 --- /dev/null +++ b/107-tee-boot-attestation.md @@ -0,0 +1,360 @@ + +# enhancement-107: TEE Boot Attestation + + + + + + +- [Release Signoff Checklist](#release-signoff-checklist) +- [Summary](#summary) +- [Motivation](#motivation) + - [Goals](#goals) + - [Non-Goals](#non-goals) +- [Proposal](#proposal) + - [User Stories (optional)](#user-stories-optional) + - [Story 1](#story-1) + - [Story 2](#story-2) + - [Notes/Constraints/Caveats (optional)](#notesconstraintscaveats-optional) + - [Risks and Mitigations](#risks-and-mitigations) +- [Design Details](#design-details) + - [Test Plan](#test-plan) + - [Upgrade / Downgrade Strategy](#upgrade--downgrade-strategy) +- [Drawbacks](#drawbacks) +- [Alternatives](#alternatives) +- [Infrastructure Needed (optional)](#infrastructure-needed-optional) + + +## Release Signoff Checklist + + + +- [ ] Enhancement issue in release milestone, which links to pull request in [keylime/enhancements] +- [ ] Core members have approved the issue with the label `implementable` +- [ ] Design details are appropriately documented +- [ ] Test plan is in place +- [ ] User-facing documentation has been created in [keylime/keylime-docs] + + + +## Summary + + + +Trusted Execution Environments (TEEs) are a confidential computing and +virtualization technology that allow for the protection/encryption of guest VM +RAM, cache memory, and CPU registers for running sensitive applications on +potentially untrusted hosts within the cloud/edge. With TEEs, data written to +RAM, caches, or registers are encrypted with keys maintained by secure +processors embedded within a CPU, thus protecting confidential VM guests from +other guests on a host, or even the host system itself. With encryption fully +managed by the hardware, only the confidential VM (CVM) itself would be able to +read/write to its own memory, protecting against buggy/malicious hosts spying +on or tampering with the CVM. + +TEEs are for protecting applications/users on untrusted platforms. In-fact, the +confidential computing threat model assumes that the host in which a CVM is +running on top of is actively attempting to tamper or spy on guest memory. With +this, users must *ensure* that a host has launched their guest with all proper +TEE protections and didn't perform any other nefarious actions to tamper with +a CVM. That is, CVMs must *attest* their boot environment and prove the +*integrity* of their workload before any sensitive operations can be performed +within a CVM. + +This enhancement will introduce a new handler to the keylime verifier strictly +for performing TEE boot attestation. However, with untrusted hosts controlling +guest memory, certain attacks can take place *before* a guest OS is booted and a +keylime agent has been initialized. Timing of boot attestation is critical, +and thus a TEE boot attestation handler cannot assume that it is communicating +with a keylime agent. Furthermore, the TEE handler will release some secret +(whether that is a public key to extend an initial TPM measurement with, a LUKS +key to unlock some initial TPM state, or a combination of both) upon a +successful boot attestation that will be required for guest OS to boot or a +keylime agent to start running. In-effect, this handler would essentially +bootstrap a keylime agent running in a CVM, as the TEE boot environment would +need to be validated before a keylime agent could begin running. + +## Motivation + + + +As CVMs are deployed on untrusted systems, it is reasonable to assume that a +CVM user would also like to take advantage of system integrity monitoring +provided by keylime *in addition to* TEE technology. That is, it is reasonable +to expect that keylime agents will be deployed on CVMs. With that, it is +reasonable to include TEE attestation mechanisms for environments in which +keylime will already be running for system integrity monitoring purposes. + +### Goals + + + * Extend keylime verifier to include support for TEE boot attestation. + * Extend TPM measurements to account for TEE boot attestation within keylime. + * Fully support confidential computing systems' need for boot *and* runtime + attestation within keylime. + +### Non-Goals + + + * TODO + +## Proposal + + + +### User Stories (optional) + + + +Initially, the TEE handler will work in-tandem with [SVSM], which runs in +a tenant's firmware and provides privileged operations for CVM guests. SVSM will +handle TEE attestation before a guest OS boots. SVSM will be responsible for +unlocking state (provided by the keylime verifier) needed to begin the guest OS +boot process. + +#### Story 1 + * User launches a confidential VM, pointing it to the URL of the keylime + verifier's TEE handler to communicate with for boot attestation. + * CVM begins running in SVSM. SVSM gathers all necessary information needed for + TEE attestation. Information is dependant on the specific TEE architecture + the guest is running on top of (ARM CCA, Intel TDX, AMD SEV-SNP, etc...). + * SVSM sends all attestation information to TEE handler. + * TEE handler uses information to verify the boot environment. + * If boot attestation is successful, TEE handler reads the agent's TEE secret + from the registrar DB and sends to CVM. If boot attestation fails, TEE + handler sends error message. + * SVSM reads response from TEE handler. If successful, SVSM uses the TEE secret + to unlock some state and begin booting guest OS, with a keylime agent + eventually initializing and integrity monitoring continuing as normal. + * SVSM will extend system's TPM state to account for TEE boot attestation. + *This is intentially vague at the moment, as the exact design is still under + ongoing discussion*. + * Agent initializes and begins running as normal. Relevant additions are made + to verifier to check if TPM measurement includes the data returned from TEE + handler. *This is also still under ongoing discussion*. + +### Notes/Constraints/Caveats (optional) + + + * TODO + +### Risks and Mitigations + + + +The TEE handler will contain a very sensitive secret for unlocking some state +on the CVM. This secret must be properly protected and should only be made +available to a guest that has successfully attested. + +## Design Details + + + +The keylime verifier will implement a new handler at `/v_/verify/tee` which can +be accessed with a `POST` method. The request body is a JSON object with the +following properties: + +- `tee` (_string_) - TEE architecture that the `evidence` will be formatted in. +- `evidence` (_JSON object_) - TEE evidence. This will be deserialized + differently depending on the TEE architecture specified in `tee`. +- `pubkey_pem` (_string_) - PEM-encoded public key to encrypt the TEE secret + with upon a successful attestation. + +The RESTful parameters of this handler would also need to include an agent UUID, +as TEE secrets are specific to each agent. + +Upon a `POST` request to the TEE handler, the handler will deserialize the +request body from JSON to fetch the parameters listed above. The handler will +read the `tee` parameter and deserialize the `evidence` parameter accordingly. + +The handler will attest the TEE `evidence`. If successful, the handler will use +the `agent_uuid` from the RESTful parameters, read the agent's TEE secret from +the registrar, and encrypt the secret with the public key found from +`pubkey_pem` in the request body's JSON object. + +SVSM will decrypt the resource and use it to unlock some state within the +firmware of the CVM. With that, it will be able to begin the guest OS boot +process. + +*PROBABLE*: SVSM will extend its TPM measurement with some state (be it a public +key or certificate) provided by keylime. This will essentially require and +include the TEE boot attestation to be accounted for within an actual TPM +measurement checked at a later point within the keylime verifier. The design of +this is still under ongoing discussion, and this document will be updated when +the design is complete. + + +### Test Plan + + + + * New tests will need to be written specifically for TEE boot attestation + extension scenarios. + +### Upgrade / Downgrade Strategy + + + +TODO + +### Dependency requirements + + +No additional dependencies should be required. + +## Drawbacks + + +No drawbacks are known of. + +## Alternatives + + + * There are other TEE attestation servers released now, such as the [trustee] + service. However, using trustee would require keylime and trustee to work + in-tandem and communicate with each other. It would also require two separate + servers to be run for attesting one confidential VM (trustee for boot + attestation, and keylime for runtime attestation and integrity monitoring). + Keylime already offers the sufficient runtime services needed for integrity + monitoring, so it is reasonable for it to include extensions for boot + attestation rather than require another solution to be deployed alongside it. + This would also make keylime a one-stop solution for running sensitive CVM + workloads on the cloud or edge. + +## Infrastructure Needed (optional) + + +No infrastructure changes needed. + +[SVSM]: https://github.com/coconut-svsm/svsm/blob/main/README.md +[trustee]: https://github.com/confidential-containers/trustee/blob/main/README.md