Reporting Issues
Bug 3077 - SEV Encrypted Boot for Ovmf (remote attestation)
Summary: SEV Encrypted Boot for Ovmf (remote attestation)
Status: RESOLVED FIXED
Alias: None
Product: Tianocore Feature Requests
Classification: Unclassified
Component: Code (show other bugs)
Version: Current
Hardware: All All
: Normal normal
Assignee: James.Bottomley@HansenPartnership.com
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-11-16 13:47 UTC by Laszlo Ersek
Modified: 2021-03-18 14:14 UTC (History)
3 users (show)

See Also:
EDK II Code First industry standard specifications: ---
Branch URL:
Release(s) the issue is observed: EDK II Master
The OS the target platform is running: ---
Package: OvmfPkg
Release(s) the issues must be fixed: EDK II Master
Tianocore documents:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Laszlo Ersek 2020-11-16 13:47:57 UTC
On 11/12/20 01:13, James Bottomley wrote:
>| From: James Bottomley <James.Bottomley@HansenPartnership.com>
>|
>| This patch series is modelled on the structure of the Bhyve patches
>| for Ovmf, since it does somewhat similar things.  This patch series
>| creates a separate build for an AmdSev OVMF.fd that does nothing
>| except combine with grub and boot straight through the internal grub
>| to try to mount an encrypted volume.
>|
>| Concept: SEV Secure Encrypted Images
>| ====================================
>|
>| The SEV patches in Linux and OVMF allow for the booting of SEV VMs in
>| an encrypted state, but don't really show how this could be done with
>| an encrypted image.  Since the key used to decrypt the image must be
>| maintained within the SEV encryption envelope, encrypted QCOW is not
>| an option because the key would then have to be known to QEMU which is
>| outside the encryption envelope.  The proposal here is that an
>| encrypted image should be a QCOW image consisting of two partitions,
>| the normal unencrypted EFI partition (Identifying it as an OVMF
>| bootable image) and a luks encrypted root partition.  The kernel would
>| be inside the encrypted root in the /boot directory.  The secret
>| injected securely through QEMU is extracted by OVMF and passed to grub
>| which uses it to mount the encrypted root and boot the kernel
>| normally.  The creator of the secret bundle must be satisfied with the
>| SEV attestation before the secret is constructed.  Unfortunately, the
>| SEV attestation can only be on the first QEMU firmware volume and
>| nothing else, so this patch series builds grub itself into a firmware
>| volume and places it inside OVMF so that the entire boot system can be
>| attested.  In a normal OVMF KVM system, the variable store is on the
>| second flash volume (which is read/write).  Unfortunately, this
>| mutable configuration provided by the variables is outside the
>| attestation envelope and can significantly alter the boot path,
>| possibly leading to secret leak, so encrypted image boot should only
>| be done with the OVMF.fd that combines both the code and variables.
>| the OVMF.fd is constructed so that it becomes impossible to interrupt
>| the boot sequence after attestation and the system will either boot
>| the image or fail. The boot sequence runs the grub.efi embedded in the
>| OVMF firmware volume so the encrypted image owner knows their own
>| version of grub is the only one that will boot before injecting the
>| secret.  Note this boot path actually ignores the unencrypted EFI
>| partition.  However, as part of this design, the encrypted image may be
>| booted by a standard OVMF KVM boot and in that case, the user will
>| have to type the encryption password.  This standard boot will be
>| insecure but it might be used by the constructor of the encrypted
>| images on their own private laptop, for instance.  The standard boot
>| path will use the unencrypted EFI partition.
>|
>| Patches Required Outside of OVMF
>| ================================
>|
>| There is a patch set to grub which allows it to extract the SEV secret
>| area from the configuration table and use the secret as a password to
>| do a luks crypto mount of root (this is the sevsecret grub module).
>|
>| There is also a patch to qemu which allows it to search through the
>| OVMF.fd and find the SEV secret area which is now described inside the
>| Reset Vector using the existing SEV_ES reset block.  This area is the
>| place QEMU will inject the encrypted SEV secret bundle.
>|
>| Security of the System
>| ======================
>|
>| Since Grub is now part of the attested OVMF.fd bundle, the VM owner
>| knows absolutely that it will proceed straight to partition decryption
>| inside the attested code and boot the kernel off the encrypted
>| partition.  Even if a different QCOW image is substituted, the boot
>| will fail without revealing the secret because the system is designed
>| to fail hard in that case and because the secret is always contained
>| within the encrypted envelope it should be impossible for the cloud
>| operator to obtain it even if they can pause the boot and examine the
>| machine memory.
>|
>| Putting it All Together
>| =======================
>|
>| This is somewhat hard.  You must first understand how to boot a QEMU
>| system so as to have the VM pause after firmware loading (-S option)
>| and use the qmp port to request an attestation.  Only if the
>| attestation corresponds to the expected sha256sum of OVMF.fd should
>| the secret bundle be constructed and injected using qmp.  The tools
>| for constructing the secret bundle are in
>|
>| https://github.com/AMDESE/sev-tool/
Comment 2 James.Bottomley@HansenPartnership.com 2020-11-16 14:54:20 UTC
Assigning to myself
Comment 4 James.Bottomley@HansenPartnership.com 2020-12-02 16:02:49 UTC
v3:

[PATCH v3 0/6] SEV Encrypted Boot for Ovmf
Msgid: <20201130202819.3910-1-jejb@linux.ibm.com>
https://edk2.groups.io/g/devel/message/68087
https://www.redhat.com/archives/edk2-devel-archive/2020-November/msg01247.html
Comment 5 Laszlo Ersek 2020-12-14 11:34:29 UTC
A github.com pull request has been submitted for the v3 series:

  https://github.com/tianocore/edk2/pull/1175

however, it was rejected by (unreasonable) ECC warnings (treated as errors).

In turn, a PR has been submitted to disable ECC for OvmfPkg:

  https://github.com/tianocore/edk2/pull/1224

However, this latter PR is not being merged due to an unspecified issue with the edk2 CI system, or the Mergify bot (the CI run completes fine for PR#1224, but Mergify is not acting upon the CI completion, and so the patch remains unmerged, and the PR open).
Comment 6 Laszlo Ersek 2020-12-14 14:57:21 UTC
Merged as commit range ef3e73c6a0c0..01726b6d23d4, via <https://github.com/tianocore/edk2/pull/1175>.
Comment 7 Laszlo Ersek 2021-03-10 14:00:36 UTC
Related:

* [edk2-devel] [PATCH 0/2]
  Maintainers: create the "OvmfPkg: Confidential Computing" subsystem

message-id: 20210310185649.19801-1-lersek@redhat.com
https://listman.redhat.com/archives/edk2-devel-archive/2021-March/msg00384.html
https://edk2.groups.io/g/devel/message/72637
Comment 8 Laszlo Ersek 2021-03-18 14:14:28 UTC
(In reply to Laszlo Ersek from comment #7)
> Related:
> 
> * [edk2-devel] [PATCH 0/2]
>   Maintainers: create the "OvmfPkg: Confidential Computing" subsystem
> 
> message-id: 20210310185649.19801-1-lersek@redhat.com
> https://listman.redhat.com/archives/edk2-devel-archive/2021-March/msg00384.
> html
> https://edk2.groups.io/g/devel/message/72637

Merged as commit range 9fd7e88c23f6..eb07bfb09ef5, via <https://github.com/tianocore/edk2/pull/1506>.