Skip to content

Commit 4596f70

Browse files
committed
Add UEFI variable append tests
Fallout from the varstored update. At the moment, test the following scenarios: * From the varstored defaults, append MS dbx and verify VM boots * From the varstored 1.2.0-3.1 defaults, append MS dbx and verify VM boots (which implies not having the oversized variable append bug) Signed-off-by: Tu Dinh <[email protected]>
1 parent 7ff012d commit 4596f70

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed
23.5 KB
Binary file not shown.

contrib/varstored/dbx_poison.auth

38.8 KB
Binary file not shown.

lib/efi.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ def db_uefi_2023(self):
7272
def db_oprom_2023(self):
7373
return str(self._prefix / "secureboot_objects/DB/Certificates/microsoft option rom uefi ca 2023.der")
7474

75+
def dbx_hashes_ms_amd64(self):
76+
return str(self._prefix / "secureboot_objects/DBX/amd64/DBXUpdate.bin")
77+
78+
def dbx_poison(self):
79+
return str(self._prefix / "varstored/dbx_poison.auth")
80+
7581

7682
SB_CERTS = _SecureBootCertList()
7783

@@ -91,6 +97,7 @@ def as_str(self):
9197

9298
# Variable attributes for time based authentication attrs
9399
EFI_AT_ATTRS = 0x27
100+
EFI_VARIABLE_APPEND_WRITE = 0x40
94101

95102
time_seed = datetime.now()
96103
time_offset = 1

tests/uefi_sb/test_varstored_sb.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
import logging
44

5-
from lib.efi import SB_CERTS, EFIAuth
5+
from lib.commands import SSHCommandFailed
6+
from lib.efi import EFI_AT_ATTRS, EFI_VARIABLE_APPEND_WRITE, SB_CERTS, EFIAuth, image_security_database_guid
67
from lib.vm import VM
78

89
from .utils import (
@@ -87,6 +88,38 @@ def test_sb_off_really_means_off(self, uefi_vm):
8788
logging.info("Check that SB is NOT enabled according to the OS.")
8889
assert not vm.booted_with_secureboot()
8990

91+
def test_append_with_default(self, uefi_vm: VM):
92+
vm = uefi_vm
93+
vm.host.pool.clear_custom_uefi_certs()
94+
vm.set_uefi_user_mode()
95+
vm.set_variable_from_file(
96+
SB_CERTS.dbx_hashes_ms_amd64(),
97+
image_security_database_guid,
98+
"dbx",
99+
EFI_AT_ATTRS | EFI_VARIABLE_APPEND_WRITE,
100+
)
101+
vm.start()
102+
vm.wait_for_vm_running_and_ssh_up()
103+
104+
def test_append_with_poison(self, uefi_vm: VM):
105+
vm = uefi_vm
106+
vm.host.pool.clear_custom_uefi_certs()
107+
vm.set_uefi_user_mode()
108+
vm.set_variable_from_file(SB_CERTS.dbx_poison(), image_security_database_guid, "dbx", EFI_AT_ATTRS)
109+
try:
110+
vm.set_variable_from_file(
111+
SB_CERTS.dbx_hashes_ms_amd64(),
112+
image_security_database_guid,
113+
"dbx",
114+
EFI_AT_ATTRS | EFI_VARIABLE_APPEND_WRITE,
115+
)
116+
except SSHCommandFailed:
117+
# Appending the MS dbx may succeed or fail, doesn't matter, as appending the poison may not necessarily take
118+
# dbx over the DATA_LIMIT. The important thing is that the VM boots up following this append attempt.
119+
pass
120+
vm.start()
121+
vm.wait_for_vm_running_and_ssh_up()
122+
90123

91124
@pytest.mark.usefixtures("host_at_least_8_3")
92125
@pytest.mark.usefixtures("windows_vm")

0 commit comments

Comments
 (0)