public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Erdem Aktas" <erdemaktas@google.com>
To: Andrew Fish <afish@apple.com>
Cc: edk2-devel-groups-io <devel@edk2.groups.io>,
	James Bottomley <jejb@linux.ibm.com>,
	 "Yao, Jiewen" <jiewen.yao@intel.com>,
	"Xu, Min M" <min.m.xu@intel.com>,
	 Ard Biesheuvel <ardb@kernel.org>,
	"kraxel@redhat.com" <kraxel@redhat.com>,
	 Ard Biesheuvel <ardb+tianocore@kernel.org>,
	Jordan Justen <jordan.l.justen@intel.com>,
	 Brijesh Singh <brijesh.singh@amd.com>,
	Tom Lendacky <thomas.lendacky@amd.com>
Subject: Re: [edk2-devel] [PATCH V5 1/2] OvmfPkg: Introduce Tdx BFV/CFV PCDs and PcdOvmfImageSizeInKb
Date: Fri, 10 Sep 2021 20:03:53 +0300	[thread overview]
Message-ID: <CAAYXXYw=ksahuUs7K+ota40thoHShLAowEGvNccxygCVfvj-rg@mail.gmail.com> (raw)
In-Reply-To: <269131DD-C918-40F0-81D2-2151C177F407@apple.com>

I have few naive questions. Sorry if the answers were obvious.

>>TDVF also include a configuration firmware volume (CFV) that is separated
>>from the BFV. The reason is because the CFV is measured in RTMR, while
>>the BFV is measured in MRTD.

If I understand correctly, this means that the BFV is encrypted and
measured during TD build time. Since CFV is not included in the MRTD,
CFV region is not encrypted with the guest key, is it?

>> The measurement value of the CFV (provisioned configuration data) is extended to
>> RTMR registers (similar to TPM PCRs). At the same time it is recorded in the TD Event
>> log.

Even if it is measured at runtime, the content needs to be copied to
somewhere else, otherwise what stops VMM to change the content after
it is being measured (assuming that it is not encrypted).

>> As to the spare part in varstore, it is not external input, is it? It's produced and consumed
>> by code itself. From this perspective it should not be measured. If the spare part
>> is included in the measurement, then the *good* measurement is not known anymore.
>> Because no one knows about the content of spare part in advance.

I am confused about how this memory is initialized. If it is
encrypted, then no need to measure it but also it becomes useless as
the key will change in the next boot. If it is not encrypted, VMM can
always modify the content and might cause unexpected behavior at
runtime, right?

I might be missing something here but if this region is not encrypted:
- CFV content needs to be copied into an encrypted buffer after being
measured and should never be used again.
- Allowing variables to be stored in SPARE part seems like opening an
attack surface as no one knows what will be stored in that region.

Is this correct understanding?
-Erdem


On Wed, Sep 1, 2021 at 10:20 PM Andrew Fish <afish@apple.com> wrote:
>
>
> > On Sep 1, 2021, at 9:53 AM, James Bottomley <jejb@linux.ibm.com> wrote:
> >
> > On Wed, 2021-09-01 at 08:59 +0000, Yao, Jiewen wrote:
> >> Hi Min
> >> I agree with Gerd and Ard in this case.
> >>
> >> It is NOT so obvious that the FTW is produced then consumed in the
> >> code. What if the attacker prepares some special configuration to
> >> trigger the FTW process at the first boot, the code will do *read*
> >> before *write*? That is a potential attack surface.
> >
> > It's not just that: even if you can ensure nothing in the host changed
> > the variables, how do you know *your* code inside the guest is updating
> > them?  In ordinary OVMF we try to ensure that by having the variables
> > SMM protected so the only update path available to the kernel is via
> > the setVariable interface, but we can't do that in the confidential
> > computing case because SMM isn't supported.  That means a random kernel
> > attacker in the guest can potentially write to the var store too.
> >
> > At least for the first SEV prototype I had to make the var store part
> > of the first firmware volume firstly so it got measured but secondly so
> > it couldn't be used as a source of configuration attacks.
> >
> > I have a nasty feeling that configuration attacks are going to be the
> > bane of all confidential computing solutions because they give the
> > untrusted VMM a wide attack surface.
> >
>
> James,
>
> If we take a big step back the requirement for an EFI Runtime Service, like the variable API, is just exclusive access to hardware at OS runtime. The variable store needs to be on a hardware device that has a persistent reliable store. The FTW is really about maintaining the consistency of the store if the power gets yanked at the wrong moment. So the fact that the UEFI Variable Store is in NOR FLASH is a historical artifact more than architecture. Also on physical devices hardware cost money, and you need the NOR FLASH for the firmware so why change it. Thus conceptually the variable store could be backed by a virtual hardware device that was designed with security in mind. Maybe more of message passing interface and the reliability of updates is maintained by the hardware device not the UEFI code. It would also be possible for the hardware device to enforce security policy. You could even have EFI send a one shot message per 1st boot to the hardware to define a security policy. If you wanted the hardware device could even implement the UEFI Secure Boot infrastructure so the UEFI Variable Driver could be untrusted. I guess this hypothetical variable store virtual hardware device could also have hardware access to other security hardware resources (like a TPM) and implement security policies based on that.
>
> FYI on Macs with a T2 (security chip) the UEFI variable store lives on the T2.
>
> Thanks,
>
> Andrew Fish
>
>
> > James
> >
> >
> >
> >
> > 
> >
> >
>

  reply	other threads:[~2021-09-10 17:04 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-30  2:35 [PATCH V5 0/2] Add Intel TDX support in OvmfPkg/ResetVector Min Xu
2021-08-30  2:35 ` [PATCH V5 1/2] OvmfPkg: Introduce Tdx BFV/CFV PCDs and PcdOvmfImageSizeInKb Min Xu
2021-08-30  7:03   ` Gerd Hoffmann
2021-08-31  3:29     ` [edk2-devel] " Min Xu
2021-08-31  5:13       ` Gerd Hoffmann
2021-08-31  6:17         ` Min Xu
2021-08-31 10:21           ` Gerd Hoffmann
2021-09-01  5:18             ` Min Xu
2021-09-01  6:10               ` Gerd Hoffmann
2021-09-01  6:57                 ` Ard Biesheuvel
2021-09-01  7:19                   ` Min Xu
2021-09-01  7:44                     ` Gerd Hoffmann
2021-09-01  8:59                     ` Yao, Jiewen
2021-09-01 16:53                       ` James Bottomley
2021-09-01 19:19                         ` Andrew Fish
2021-09-10 17:03                           ` Erdem Aktas [this message]
2021-08-30  2:35 ` [PATCH V5 2/2] OvmfPkg/ResetVector: Enable Intel TDX in ResetVector of Ovmf Min Xu
2021-08-30  7:40   ` Gerd Hoffmann
2021-08-31  3:09     ` [edk2-devel] " Min Xu
2021-08-31  5:35       ` Gerd Hoffmann
2021-09-02  0:05         ` Min Xu
2021-09-02  7:18           ` Gerd Hoffmann
2021-09-02  7:49             ` Min Xu
2021-09-03  3:03               ` Yao, Jiewen
2021-09-03  5:39                 ` Gerd Hoffmann
2021-09-09 13:54                   ` Min Xu
2021-09-10  8:19                     ` Gerd Hoffmann
2021-09-14  3:54                       ` Yao, Jiewen
2021-09-11  1:17   ` Erdem Aktas

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='CAAYXXYw=ksahuUs7K+ota40thoHShLAowEGvNccxygCVfvj-rg@mail.gmail.com' \
    --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