Repository navigation
fix(verify): require TDX quote version 4 and validate expected digest lengths in verify_tdx_quote and verify_sev_snp_report (#283) - #288
Conversation
|
🟡 Contributor Check: MEDIUM
Automated check by AgenTrust Contributor Check. |
carloshvp
left a comment
There was a problem hiding this comment.
Reviewed exact head fa6f446cc727712e51845434825c240927d4f606 in an isolated checkout.
The TDX verifier requires the supported v4 layout and validates expected measurement/report-data byte lengths before appraisal. SNP expectations and the platform-bits option receive the corresponding type checks. All nine focused input/version cases pass here and fail against the baseline verifier modules at the expected guard boundary. Existing valid v4/SNP controls remain passing; no blocking source finding.
Independent validation in a fresh repository-hash-locked Python 3.12.10 environment: 785 tests passed, 16 skipped; pip check, configured Ruff, mypy, Bandit and diff whitespace checks passed. Commit sign-offs are present. Hosted CI and applicable independent maintainer/security gates remain separate prerequisites to merge.
Reviewed with OpenAI Codex.
fa6f446 to
1889ce4
Compare
carloshvp
left a comment
There was a problem hiding this comment.
Reviewed current head aabdad3eb9dabf4a73f19526c21971f104a90037 in an isolated checkout.
The scoped input-hardening behavior passes source review and the full local unit/conformance suite (841 passed, 16 skipped). Ruff lint, mypy, configured Bandit and dependency consistency pass; the commit is signed off.
The required ruff format --check src/ tests/ job still fails on this head, while the same command passes on current main. Please run the pinned formatter on src/ca2a_verify/tdx.py and rerun the format gate. The formatting diff is mechanical; no additional behavioral repair is requested by this review. Hosted CI and the independent security-review requirements still apply.
Reviewed with OpenAI Codex.
|
The requested formatting correction is ready for author adoption: dinakarjs#8, commit |
|
@carloshvp Amended and force-pushed |
aabdad3 to
d9e1939
Compare
There was a problem hiding this comment.
Reviewed commit d9e1939199795d4861442b55f44980fa0f8a43cd.
The requested formatting repair is complete. I compared the changed Python files with the revision from my prior review: their parsed ASTs are identical. The pinned repository formatter, Ruff, mypy and configured Bandit pass on this head. Focused tests: 25 passed, 1 hardware-dependent skip.
This resolves my formatting change request. The existing security impact and independent maintainer/CI requirements remain applicable.
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
d9e1939 to
d045d5a
Compare
zohebk8s
left a comment
There was a problem hiding this comment.
Thanks for hardening TDX and SNP verification. The TDX v4 requirement and validation of expected measurement and report-data lengths look correct, with regression coverage for invalid versions and inputs. Approved.
carloshvp
left a comment
There was a problem hiding this comment.
The TDX and SNP verifier changes are preserved on this head. The additional assertions exercise expected-digest validation. The TDX unit module produced 25 passes and one skip for a physical quote fixture.
There was a problem hiding this comment.
A few gaps remain against #283 and the stated goal:
- TDX version check is too late - verify_tdx_quote calls TdxQuote.parse() (which already uses hard-coded v4 offsets and parses the QE/PCK cert data) before checking quote.version == 4. Non-v4 quotes are still interpreted with the v4 layout; the version check only runs if parse succeeds, validate the version from the raw header (or inside TdxQuote.parse) before any v4-specific parsing. TdxProvider.attest() also calls parse directly and is uncovered.
- memoryview length check is incorrect - the new guards accept memoryview but use len(). For non-byte formats len() counts elements, not bytes. A 192-byte memoryview(array.array("I", [0]*48)) passes the 48-byte check, while a valid 48-byte typed view is rejected. Same issue in both TDX and SNP. Use .nbytes (or normalize to bytes first) and add tests for typed memoryviews.
- sev_snp_verifier still missing non-empty checks - issue #283 explicitly asked for validation that trusted_roots and vcek_chain are non-empty at construction time. The bool check was added, but empty lists are still accepted and only fail later during chain verification, kindly reject them with ValueError in the factory and add tests.
- Wrapper silently accepts integers - expected_measurement = bytes(expected_measurement) turns bytes(48) into 48 zero bytes. An integer is accepted instead of being rejected. Add an explicit bytes-like type check before conversion.
Also resolve conflicts and rebase onto main
… lengths in verify_tdx_quote and verify_sev_snp_report (agentrust-io#283) Signed-off-by: Raghuvar Karthik Durga <177662415+drk-ram@users.noreply.github.com>
d045d5a to
6a679ac
Compare
What
Require
quote.version == 4inverify_tdx_quote, validateexpected_mrtd/expected_measurement(48 bytes) andexpected_report_data(64 bytes) inverify_tdx_quoteandverify_sev_snp_report, and validateisinstance(reject_unrecognized_platform_bits, bool)inverify_sev_snp_reportandsev_snp_verifier.Why
Closes #283.
Security impact
Prevents non-v4 TDX quotes from being parsed with DCAP v4 offsets during verification and prevents caller misconfiguration with wrong-length expected measurements or report_data bindings.
Test plan
pytestpasses (pytest tests/unit/test_tdx.py tests/unit/test_sev_snp.py -q:54 passed, 2 skipped)ruff checkpasses (ruff check src tests/unit/test_tdx.py tests/unit/test_sev_snp.py:All checks passed!)mypypassesDCO sign-off
Developer Certificate of Origin (https://developercertificate.org).