Repository navigation
abi: reject overlapping certificate table ranges - #212
Merged
Merged
Conversation
brongan
force-pushed
the
cert-table-alloc-bound
branch
from
November 11, 2026 23:08
9406ab3 to
9c69919
Compare
brongan
force-pushed
the
cert-table-alloc-bound
branch
5 times, most recently
from
November 12, 2026 22:19
ecffe76 to
1946a6b
Compare
brongan
marked this pull request as ready for review
November 12, 2026 22:34
yawangwang
approved these changes
Nov 24, 2026
Return an error when two entries in a certificate table overlap. Verifiers parse untrusted certificate tables before they check report signatures. If several entries point to the same bytes, a small input can cause gigabytes of allocation. Checking for overlap directly instead of summing entry lengths also catches overlaps inside zero-padded 4 KiB request pages.
brongan
force-pushed
the
cert-table-alloc-bound
branch
from
December 2, 2026 20:21
1946a6b to
5f0cbd7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CertTable.Unmarshalnow returnsabi.ErrCertTableOverlapwhen two entries have overlapping byte ranges.Problem
Verifiers parse untrusted certificate table bytes before they check the attestation report signature.
CertTable.Unmarshalcopied a new byte slice for each header entry without checking for overlap. A 1 MiB input with21,844entries (524,280header bytes including the terminator) all pointing to the same524,296-byte range madeUnmarshalallocate11,452,721,824bytes (~10.7 GiB).flowchart LR subgraph Input["1 MiB input"] H0["Entry 0: offset=524280, len=524296"] --> P["Shared bytes (524,296 B)"] H1["Entry 1: offset=524280, len=524296"] --> P HN["Entry 21843: offset=524280, len=524296"] --> P end Input -->|"Before"| OOM["10.7 GiB allocated"] Input -->|"After"| Err["ErrCertTableOverlap (0 B copied)"]Design
Extended guest requests use 4 KiB pages and pad unused space at the end with zeros. Summing entry lengths and comparing against the data block size misses overlapping entries whenever that zero padding is large enough to cover the duplicate bytes. Checking directly that entry byte ranges do not overlap catches every overlap regardless of page padding or entry order, and keeps total certificate bytes at or below the data block size.
dataSizeLength == 0)dataSizeN * LbytesErrCertTableOverlapErrCertTableOverlapSpec and implementation comparison
SNP Extended Guest Request): Definescert_tableat offset0x0of the guest data pages as 24-byte(GUID, Offset, Length)entries ending with an all-zero entry. It does not say whether entry ranges can overlap.sev_report_new: Copies from offset0up tomax(offset + length)once as a flat buffer capped at 16 KiB.CertTable.Unmarshalaccepts untrusted buffers of any size and copies each entry into its own slice. Separate copies protect parsed certificates if the caller reuses the buffer and let Go free the rest of the input. Rejecting overlapping ranges stops memory amplification before signature verification and still accepts every layout fromCertTable.Marshal, Linuxsev-guest, and 4 KiB page padding.Testing
go test -race -cover ./abireaches100.0%statement coverage on(*CertTable).Unmarshal, andFuzzCertTableUnmarshalpasses without changes.