Skip to content

fix(tdx): reject declared lengths that overrun the quote buffer - #250

Merged
imran-siddique merged 1 commit into
mainfrom
fix/tdx-cert-size-bounds
Jul 28, 2026
Merged

fix(tdx): reject declared lengths that overrun the quote buffer#250
imran-siddique merged 1 commit into
mainfrom
fix/tdx-cert-size-bounds

Conversation

@imran-siddique

Copy link
Copy Markdown
Contributor

Found while reviewing cmcp#420, which derives the same parse independently and has the same gap. I offered the fix there, so here it is on the shared side.

The gap

Four lengths in the TDX signature section are declared by the quote, which is untrusted input: the signature-data size, cert_size, qe_auth_size, and pck_size. Each was used to slice without checking it fits.

Python slicing clamps rather than overreading, so an inflated length produced a short slice and parsing continued against whatever happened to fit. Nothing read out of bounds, and the downstream signature check would fail, so this is fail-closed hardening rather than a memory-safety fix.

It is still worth rejecting. Appraising 300 bytes where the producer declared 400 means verifying something other than what they said they signed, and surfacing that as a generic signature failure hides the actual cause from whoever has to debug it. The new errors say which length was wrong and how much was available.

Tests

Three, each tampering one declared length in an otherwise valid quote built by the suite's own helper:

  • overstated cert_size
  • overstated signature-data size
  • overstated qe_auth_size

626 passed, 18 skipped. mypy, ruff, bandit clean.

pck_size gets the same check but no separate test: with the preceding checks in place it is unreachable from a single-field tamper, and a test that cannot fail before the fix is not worth having.

Four lengths in the signature section come from the quote, which is
untrusted input: the signature-data size, cert_size, qe_auth_size and
pck_size. Python slicing clamps instead of overreading, so an inflated
length yielded a short slice and parsing continued against whatever fit.

No read was ever out of bounds and the downstream signature verification
would fail, so this is fail-closed hardening rather than a memory-safety
fix. Still worth rejecting: appraising 300 bytes where the producer
declared 400 means verifying something other than what they said they
signed, and reporting that as a signature failure hides the real cause.

Found while reviewing the same parse in cmcp#420, which shares this
derivation and has the same gap.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@imran-siddique
imran-siddique merged commit 3979299 into main Jul 28, 2026
14 checks passed
@imran-siddique
imran-siddique deleted the fix/tdx-cert-size-bounds branch July 28, 2026 00:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant