public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Gerd Hoffmann" <kraxel@redhat.com>
To: "Yao, Jiewen" <jiewen.yao@intel.com>
Cc: "devel@edk2.groups.io" <devel@edk2.groups.io>,
	"Justen, Jordan L" <jordan.l.justen@intel.com>,
	Ard Biesheuvel <ardb+tianocore@kernel.org>,
	Oliver Steffen <osteffen@redhat.com>,
	Pawel Polawski <ppolawsk@redhat.com>
Subject: Re: [edk2-devel] [PATCH 1/1] OvmfPkg/QemuFlashFvbServicesRuntimeDxe: add security warning
Date: Tue, 20 Dec 2022 08:18:39 +0100	[thread overview]
Message-ID: <20221220071839.zawewnst5bmfhw5z@sirius.home.kraxel.org> (raw)
In-Reply-To: <MW4PR11MB58723DFF1A8A88A0ED86D8528CE59@MW4PR11MB5872.namprd11.prod.outlook.com>

  Hi,

> > Well, the OS can write directly to flash, bypassing the firmware.  It
> > can update secure boot efi variables without the firmware enforcing the
> > usual restrictions (KEK signature being required for db/dbx updates
> > etc).
> 
> [Jiewen] I would say: It is the typical use case. But not the only use case.
> Typically, the BIOS shall configure the flash to prevent OS directly to flash, with SMM in this case. I do not disagree.
> That feature fully really on the hardware (on a real platform) or VMM (on a virtual platform).
> 
> However, in confidential computing use case, the flash is controlled by the untrusted entity - VMM.
> It is *impossible* to lock down the flash, even with SMM enabled. That is because the VMM is also emulating SMM.
> To rely on an untrusted entity (VMM) to provide security protection (e.g. SMM) is meaningless.

In the confidential computing use case there is no flash in the first
place.  At least for the cases where the processor not the VMM manages
guest memory (i.e SEV-SNP and TDX) the qemu patches I've seen so far
handle it that way.

That configuration goes into the (3a) bucket.  No flash (and no other
place to store any state which survives reboot -> stateless).  Guest
starts with a fixed varstore coming from the firmware rom.

> The best way we can do is to enable measured boot together with secure
> boot.

measured boot can be used to attest the VM actually runs the
configuration it is supposed to run.  That is independent from secure
boot, even though it is possible to combine the two and in that case
also measure secure boot configuration.

Works in both confidential and non-confidential VMs.

> In summary, Secure boot in CC cannot resist the policy override,
> but Measured boot in CC will detect such override, and mitigate such threat.
> That is fine, because it is meaningless to enable CC without measured boot.

If you don't want trust the VMM, then yes, measured boot is required to
make sure the VMM actually started the VM the way it is supposed to be
started.

For attacks against the guest OS there isn't that much of a difference
between CC and non-CC guests.  I think in both cases the (hacked) guest
OS can't change the secure boot configuration.  Even in case the guest
OS manages to modify the varstore the firmware will never use the
modification.  For non-confidential guests the firmware will initialize
the varstore with the pristine copy from firmware rom on reset.  For CC
guests there is no reset in the first place (reset requires the VMM
changing guest state), you can only kill and restart the VM, which will
likewise start with pristine varstore state.

> > I don't see how "secure boot without SMM" is easier to understand than
> > "stateless".
> 
> [Jiewen] "stateless" is a new term introduced in this patch. Not in UEFI spec, nor in EDKII.
> If you want to use it, please define it clearly. At least, I don't understand.

"stateless" == no persistent variable store, i.e. no flash.

> >  It also is x64-specific.
> 
> [Jiewen] I don't understand why it is x64-specific.

SMM is x86-specific, that's why I don't like the term "secure boot
without SMM".

> > > 4) What is the purpose of "Log a warning" ?
> > > Is that to tell people, DON'T DO IT?
> > 
> > Yes.
> 
> [Jiewen] Disagree. It can work together with measured boot in CC use case.
> If you really really want to add something, you should also check if CC is enabled.

See above.  CC runs without flash anyway so no warning in that case.

> > In 2022-08 and older the world is relatively simple.  We have
> > three possible build configurations
> > 
> >   (1) SECURE_BOOT_ENABLE=FALSE SMM_REQUIRE=FALSE
> >       Build without secure boot support.
> > 
> >   (2) SECURE_BOOT_ENABLE=TRUE SMM_REQUIRE=TRUE
> >       Build with secure boot support, secure.
> > 
> >   (3) SECURE_BOOT_ENABLE=TRUE SMM_REQUIRE=FALSE
> >       Build with secure boot support, not secure.
> > 
> > Linux Distributions typically provide builds for (1) and (2),
> > so (3) existing isn't much of a problem in practice because
> > people typically don't compile edk2 by themself.
> 
> [Jiewen] Above description is based upon assumption that SMM is trusted.

Yes.

> It is TRUE in non-CC use case.  However, the assumption is wrong in CC
> use case, because VMM is untrusted and SMM might colluder.  The VMM
> may fake the flash lock in SMM, and allow OS to bypass the flash
> protection.  Following your logic, I would say: even with SMM, it is
> still not secure.

Not sure what you are trying to tell me.  In CC mode SMM is not
supported in the first place, so your argument doesn't make sense to me.

> > In 2022-11 the (3) case is splitted into two:
> > 
> >   (3a) build being used with ROM (or r/o flash):
> >        -> this is the new "stateless secure boot" mode.
> >   (3b) build being used with writable flash:
> >        -> insecure configuration.
> 
> [Jiewen] If you want to use term "stateless", please define it.

"stateless" == no persistent variable store, i.e. no flash.

> Also, I think we can separate the non-CC and CC use case, because the TCB is totally different.

CC goes into (3a).

take care,
  Gerd


  reply	other threads:[~2022-12-20  7:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-16 10:11 [PATCH 1/1] OvmfPkg/QemuFlashFvbServicesRuntimeDxe: add security warning Gerd Hoffmann
2022-12-17  3:10 ` Yao, Jiewen
2022-12-19  8:53   ` Gerd Hoffmann
2022-12-19 14:47     ` [edk2-devel] " Yao, Jiewen
2022-12-20  7:18       ` Gerd Hoffmann [this message]
2022-12-21  6:25         ` Yao, Jiewen
     [not found] ` <173175F495CB0C1B.6312@groups.io>
2022-12-17  3:14   ` Yao, Jiewen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221220071839.zawewnst5bmfhw5z@sirius.home.kraxel.org \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox