Bug 2181920 - SecureBoot is always enabled for UEFI VMs
Summary: SecureBoot is always enabled for UEFI VMs
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Container Native Virtualization (CNV)
Classification: Red Hat
Component: User Experience
Version: 4.12.5
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: 4.14.0
Assignee: Hilda Stastna
QA Contact: Guohua Ouyang
URL:
Whiteboard:
Depends On:
Blocks: 2193004
TreeView+ depends on / blocked
 
Reported: 2023-03-26 22:29 UTC by Germano Veit Michel
Modified: 2023-11-08 14:05 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 2193004 (view as bug list)
Environment:
Last Closed: 2023-11-08 14:05:06 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github kubevirt-ui kubevirt-plugin pull 1236 0 None open Bug 2181920: Disable Secure Boot for UEFI Boot mode 2023-04-05 15:19:05 UTC
Github kubevirt-ui kubevirt-plugin pull 1287 0 None open Bug 2181920: Display "UEFI" for Boot mode for "efi: {}" in yaml 2023-05-02 16:59:26 UTC
Red Hat Issue Tracker CNV-27441 0 None None None 2023-03-26 22:29:23 UTC
Red Hat Product Errata RHSA-2023:6817 0 None None None 2023-11-08 14:05:19 UTC

Description Germano Veit Michel 2023-03-26 22:29:09 UTC
Description of problem:

In Virtual Machine -> Details -> Boot Mode, there are these options:

1. BIOS
2. UEFI
3. UEFI (Secure)

Note [2] sets the VM as:

        firmware:
          bootloader:
            efi: {}

But results in SecureBoot

/usr/libexec/qemu-kvm -name guest=openshift-cnv_fedora-y130ab1457eie7uw,debug-threads=on -S -object {"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/run/kubevirt-private/libvirt/qemu/lib/domain-1-openshift-cnv_fedora/master-key.aes"} -blockdev {"driver":"file","filename":"/usr/share/OVMF/OVMF_CODE.secboot.fd","node-name":"libvirt-pflash0-storage","auto-read-only":true,"discard":"unmap"}

And [3] sets the VM as:

        firmware:
          bootloader:
            efi:
              secureBoot: true

Which is the same, also SecureBoot enabled:

/usr/libexec/qemu-kvm -name guest=openshift-cnv_fedora-y130ab1457eie7uw,debug-threads=on -S -object {"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/run/kubevirt-private/libvirt/qemu/lib/domain-1-openshift-cnv_fedora/master-key.aes"} -blockdev {"driver":"file","filename":"/usr/share/OVMF/OVMF_CODE.secboot.fd","node-name":"libvirt-pflash0-storage","auto-read-only":true,"discard":"unmap"}

This means it is always enabling SecureBoot, even if the user sets is to option [2] in the UI.

According to https://kubevirt.io/user-guide/virtual_machines/virtual_hardware/#biosuefi
~~~
Enabling EFI automatically enables Secure Boot, unless the secureBoot field under efi is set to false.
~~~

Its a bit odd, as SecureBoot is usually opt-in and not opt-out, maybe the UI also expected that.

But because the default is enabled, the UI should:

For option [2]

        firmware:
          bootloader:
            efi:
              secureBoot: false

For option [3]

        firmware:
          bootloader:
            efi:
              secureBoot: true

        OR

        firmware:
          bootloader:
            efi: {}

Version-Release number of selected component (if applicable):
OCP 4.12.8
CNV 4.12.1

How reproducible:
Always

Steps to Reproduce:
1. Set VM to UEFI (not Secure)
2. Boot it
3. Check SecureBoot is enabled

Comment 2 Guohua Ouyang 2023-04-28 04:05:53 UTC
Failed to verify the bug on kubevirt-console-plugin-rhel9-container-v4.14.0-1047 which includes the fix.

Comment 3 Hilda Stastna 2023-04-28 09:51:45 UTC
Hi Guohua,

could you please add some more details about what went wrong when verifying the bug? Thanks.

Comment 4 Guohua Ouyang 2023-04-28 10:12:38 UTC
(In reply to Hilda Stastna from comment #3)
> Hi Guohua,
> 
> could you please add some more details about what went wrong when verifying
> the bug? Thanks.

The issue is still reproduced. Create a VM with Bootmode UEFI, the VM is started with SecureBoot enabled.

Comment 5 Hilda Stastna 2023-04-28 16:32:14 UTC
Hi,

could you please add more details? How exactly were you reproducing the bug? Thanks.

Comment 6 Hilda Stastna 2023-04-28 16:44:50 UTC
I am attaching the screenshots showing the bug is not reproducible anymore, already fixed.

Comment 9 Hilda Stastna 2023-04-28 16:50:15 UTC
Note that you have to restart the VM once you change the boot mode, to apply the change successfully.

Comment 10 Guohua Ouyang 2023-04-28 23:26:45 UTC
(In reply to Guohua Ouyang from comment #4)
> (In reply to Hilda Stastna from comment #3)
> > Hi Guohua,
> > 
> > could you please add some more details about what went wrong when verifying
> > the bug? Thanks.
> 
> The issue is still reproduced. Create a VM with Bootmode UEFI, the VM is
> started with SecureBoot enabled.

The reproduce steps are:
1. create the Fedora VM from catalog
2. the default bootmode of the VM is UEFI
3. check the VM YAML, the bootmode section is
        firmware:
          bootloader:
            efi: {}
4. wait for the VM become running or start it if it's not started yet.
5. the VM is started with SecureBoot enabled

However, if open the bootmode modal either in catalog(before VM is created) or in VM details tab (after VM is created) and save it, the value is saved correctly:
        firmware:
          bootloader:
            efi:
              secureBoot: false

So the issue only happens when creating VM from a template which has the UEFI as bootmode.

Comment 11 Hilda Stastna 2023-04-29 10:21:31 UTC
Thanks for the details, it was very useful. From the info you've provided it seems the bug is in the original YAML of the selected template.
I can take a look, but I am not sure if we can influence how the default/Red Hat templates look like.

Comment 12 Hilda Stastna 2023-05-02 11:17:13 UTC
Hi Guohua,

according to the fact we cannot change (and shouldn't) default/Red Hat templates, do you agree on such fix,
that I'd update the basic yaml (creates "example" VM Template) the way that secure boot will be disabled
plus I'd update the UI the way that it will show "UEFI (secure)" in case that "efi: {}" will be in the YAML.
WDYT?

Comment 13 Hilda Stastna 2023-05-02 11:57:37 UTC
Note that I am not sure if we should change the default template. Maybe not. 
Anyway, changing the UI to show "UEFI (secure)" for both "efi: {}" and "efi: secureBoot: true"
could solve the problem the way that the user would see the correct value corresponding with the yaml,
no matter how the templates look like or what is the default value.

Comment 14 Hilda Stastna 2023-05-02 12:19:16 UTC
(In reply to Hilda Stastna from comment #13)
> Note that I am not sure if we should change the default template. Maybe not. 
> Anyway, changing the UI to show "UEFI (secure)" for both "efi: {}" and "efi:
> secureBoot: true"
> could solve the problem the way that the user would see the correct value
> corresponding with the yaml,
> no matter how the templates look like or what is the default value.

I meant for both VMs and VM Templates, because the issue is in both places (VM and Template Details > Boot mode).

Comment 15 Guohua Ouyang 2023-05-02 12:54:45 UTC
Maybe we should ask the backend team to fix the issue, not boot the VM with secureBoot when it's "efi: {}", then no changes are needed from templates and UI.

Comment 16 Hilda Stastna 2023-05-02 13:12:05 UTC
It would be helpful if the backend fixed it the way that only "efi: secureBoot: true" would represent the secure boot enabled.
But till they fix it, we need to make a change in the UI anyway, because it doesn't display the values properly in Templates Details. 
In other words, I found just now that we need to put the rest of the UI to harmony with my previous fix:
https://github.com/kubevirt-ui/kubevirt-plugin/pull/1236
This is true till both "efi: {}" and "efi: secureBoot: true" represent the secure boot enabled (and from our experience after we create,
boot such VMs with such settings and check boot mode, they do).

Comment 17 Guohua Ouyang 2023-05-02 23:30:17 UTC
I'm fine with this fix as the backend treat `efi: {}` as UEFI secure boot.
https://kubevirt.io/user-guide/virtual_machines/virtual_hardware/#biosuefi

Comment 18 Hilda Stastna 2023-05-03 08:39:36 UTC
Guohua, I think they already do (otherwise this BZ wouldn't exist).
The actual problem is that both "efi: secureBoot: true" and "efi: {}" represent secure boot enabled.
It would be helpful if the backend fixed it the way that only "efi: secureBoot: true" would represent the secure boot enabled, IMO.
Then we wouldn't need 2 PRs I've created to UI.

Comment 20 Guohua Ouyang 2023-05-15 02:02:47 UTC
Verified on kubevirt-console-plugin-rhel9-container-v4.14.0-1283, the UI mark the `efi: {}` as UEFI secure boot.

Comment 23 errata-xmlrpc 2023-11-08 14:05:06 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Important: OpenShift Virtualization 4.14.0 Images security and bug fix update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2023:6817


Note You need to log in before you can comment on or make changes to this bug.