Commit b6e905e
authored
attest/internal: skip SignatureHeaderSize vendor bytes in parseEfiSignatureList (#502)
* attest/internal: skip SignatureHeaderSize vendor bytes in parseEfiSignatureList
Per UEFI specification section 31.4.1, an EFI_SIGNATURE_LIST contains
SignatureHeaderSize bytes of vendor-specific data between the fixed
28-byte header and the actual signature entries.
parseEfiSignatureList() did not advance the buffer past these vendor
bytes before reading entries. For hashSHA256SigGUID lists, this allowed
attacker-controlled vendor header bytes to be appended to the trusted
SHA256 hash list. A crafted TPM event log could inject arbitrary SHA256
hashes into the verifier's trusted measurement database, enabling a
remote attestation verifier to accept a compromised boot state.
Fix:
- Validate: SignatureHeaderSize must not exceed remaining list space
- Skip SignatureHeaderSize vendor bytes via binary.Read before entry loops
- Fix both certX509SigGUID and hashSHA256SigGUID loop start offsets
- Add regression test confirming vendor bytes are not trusted as hashes
Reported via Google OSS VRP issue #513787653.
* attest/internal: address review feedback on SignatureHeaderSize fix
- Use buf.Seek() instead of binary.Read() to skip vendor header bytes
(no need to allocate vendorHeader since we do not use its contents)
- Add sha256HashSize const instead of magic literal 32
- Reuse buildEFISignatureListData() in regression test
- Use efiSignatureListHeaderSize instead of magic literal 28
* attest/internal: fix gofmt formatting
* attest/internal: split SignatureHeaderSize test into two deterministic tests
Split TestParseEfiSignatureListNonZeroSignatureHeaderSize into:
- TestParseEfiSignatureListOversizedSignatureHeaderSize: verifies the
bound check rejects SignatureHeaderSize >= remainingListSize
- TestParseEfiSignatureListVendorHeaderNotTrusted: verifies vendor bytes
are skipped and do not appear in the trusted hash list
* attest/internal: simplify TestParseEfiSignatureListVendorHeaderNotTrusted
Check length and first element directly instead of iterating,
as suggested by reviewer.
---------
Co-authored-by: Prasanna Dabi <prasanna8585@users.noreply.github.com>1 parent 33eb399 commit b6e905e
2 files changed
Lines changed: 69 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
381 | 381 | | |
382 | 382 | | |
383 | 383 | | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
384 | 399 | | |
385 | 400 | | |
386 | 401 | | |
387 | 402 | | |
388 | | - | |
| 403 | + | |
389 | 404 | | |
390 | 405 | | |
391 | 406 | | |
| |||
404 | 419 | | |
405 | 420 | | |
406 | 421 | | |
407 | | - | |
| 422 | + | |
408 | 423 | | |
409 | 424 | | |
410 | 425 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
0 commit comments