Skip to content

fix(tdx): delegate quote signature parsing to agent-manifest - #528

Open
devdiv07 wants to merge 1 commit into
agentrust-io:mainfrom
devdiv07:fix/delegate-tdx-signature-parser
Open

fix(tdx): delegate quote signature parsing to agent-manifest#528
devdiv07 wants to merge 1 commit into
agentrust-io:mainfrom
devdiv07:fix/delegate-tdx-signature-parser

Conversation

@devdiv07

Copy link
Copy Markdown

What

Delegates cMCP's duplicate Intel TDX DCAP v4 signature-section parser to the
canonical parser already shipped by the required agent-manifest dependency.
parse_td_quote() remains as a thin local adapter that keeps cMCP's existing
_ParsedQuote shape and ValueError contract.

Follow-up to #420.

Why

src/cmcp_verify/tdx.py carried its own copy of the nested DCAP v4 signature
layout while its own comment already stated that the parse was delegated to
Agent Manifest. The comment and the implementation contradicted each other.

The local copy also read attacker-controlled declared lengths — the outer
signature-data size, the nested QE certification-data size, the QE auth-data
size and the PCK-chain size — and sliced with them directly. Python slicing
clamps an out-of-range range instead of raising, so an overstated length
produced a silently shorter buffer rather than a rejection.

The shared parser explicitly validates those declared lengths before slicing.

This change keeps cMCP-specific behavior at the adapter boundary:

The follow-up direction was suggested directly in the #420 review: consolidate
on the Agent Manifest parser rather than maintain another copy of the DCAP v4
signature layout.

Security impact

Positive hardening of the TDX verification path.

The change removes a duplicated parser for attacker-controlled DCAP quote bytes
and delegates nested signature-section parsing to the canonical Agent Manifest
implementation, which performs explicit bounds checks on declared signature,
QE certification, QE auth-data, and PCK-chain lengths.

Regression tests demonstrate that the previous local parser did not reject
overstated declared lengths because Python slicing silently truncated the
requested range.

No TDX cryptographic verification policy is changed. Quote-signature
verification, QE binding, QE-report signature verification, PCK-chain
verification, report-data comparison, and the raw-TDREPORT path are otherwise
unchanged.

Real-hardware behavior is not newly claimed by this PR. The existing
CMCP_TDX_FIXTURE_DIR tests remain the hardware-gated validation path.

Test plan

  • pytest tests/unit/test_tdx_quote_verify.py -v
    • 9 passed, 2 skipped
    • skipped tests require CMCP_TDX_FIXTURE_DIR
  • pytest tests/unit/ -q
    • 1135 passed, 8 skipped
  • ruff check src/cmcp_verify/tdx.py tests/unit/test_tdx_quote_verify.py
  • mypy src/cmcp_verify/
  • bandit -r src/ -c pyproject.toml
  • Manual hardware test performed
    • Not performed locally; no real TDX fixture was available.

Regression coverage added for:

  • cMCP/shared-parser field equivalence on the synthetic nested DCAP v4 quote;
  • overstated outer signature-section length;
  • overstated nested QE certification-data length;
  • overstated QE auth-data length.

The malformed-length regressions were also run against the pre-change parser:
the overstated signature and QE-certification cases failed with DID NOT RAISE,
confirming they exercise behavior changed by this patch rather than merely
duplicating an existing check.

DCO sign-off

Signed-off-by: devdiv07 <sarvenclothing@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@imran-siddique
imran-siddique self-requested a review August 18, 2026 18:57
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