Commit 724721e
committed
fix: avoid sending empty ShieldedInstanceInitialState on image create
CreateShieldedVMStateConfig has been returning a non-nil pointer to a
zero-value compute.InitialStateConfig{} whenever no signature inputs
(image_platform_key, image_key_exchange_key, image_signatures_db,
image_forbidden_signatures_db) were configured. Because Go's omitempty
tag only drops nil pointers (not pointers to empty structs), the image
insert request body included:
"shieldedInstanceInitialState": {}
GCP treats an explicit (even empty) shieldedInstanceInitialState as
*the* initial state for the new image and therefore replaces the
PK / KEKs / db / dbx that would otherwise be inherited from the source
disk. With no signature databases, UEFI Secure Boot has nothing to
validate the bootloader against, and any VM launched from such an
image with shielded-vm secure boot enabled fails to boot:
BdsDxe: failed to load Boot0001 "UEFI Google PersistentDisk"
... Status: Security Violation.
This regression was introduced in #318 (released in v1.2.5). Subsequent
work in #333 removed the UEFI_COMPATIBLE gate but kept the empty-struct
return path, so v1.2.6 is still affected.
Fix: return nil from CreateShieldedVMStateConfig when no signature
inputs are configured, so the caller leaves
compute.Image.ShieldedInstanceInitialState unset and GCP inherits the
initial state from the source disk.
Adds:
- Unit tests for CreateShieldedVMStateConfig covering both the
no-inputs (nil return) and inputs-provided (non-nil return) paths.
- Step-level regression test asserting that the image insert spec has
no ShieldedInstanceInitialState when no signature inputs are
configured.1 parent 6254a5d commit 724721e
3 files changed
Lines changed: 96 additions & 0 deletions
File tree
- builder/googlecompute
- lib/common
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
97 | 127 | | |
98 | 128 | | |
99 | 129 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
37 | 47 | | |
38 | 48 | | |
39 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
0 commit comments