Conversation
…rifier fetch_and_verify takes the AMD KDS branch whenever cert_chain is empty, and that branch handed the report straight to AttestationReport::from_bytes. The `sev` crate reads bytes[0..4] there, and bytes[392] for a version it does not know, without looking at the length, so a report shorter than that is an index out of range -- and release builds are panic = "abort", so it takes down dstack-verifier or dstack-kms rather than failing one request. Both fields are free-form in the attestation blob a POST /verify body carries, and the parse runs before any KDS fetch, signature check or report_data comparison, so an empty report is enough. The other three callers of the same parser already reject anything that is not 1184 bytes, each with its own copy of the check. Make the precondition the parser's own: one decode_amd_snp_report that checks the length and then decodes, and four callers that cannot skip it. thread '...' panicked at sev-6.0.0/src/firmware/guest/types/snp.rs:193:45: range end index 4 out of range for slice of length 0
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.
dstack-verifier'sPOST /verifyis unauthenticated, and release builds arepanic = "abort"(dstack/Cargo.toml:312-313), so a panic in a parser on thatpath is a whole-process abort rather than a failed request. This is one.
What happens
QuoteVerifier::fetch_and_verifytakes the AMD KDS branch whenevercert_chainis empty, and that branch handed the report straight to
AttestationReport::from_bytes. Thesevcrate readsbytes[0..4]there, andbytes[392]for a version it does not recognise, without looking at the lengthfirst:
reportandcert_chainare free-formVec<u8>/Vec<Vec<u8>>in theattestation envelope (
dstack-attest/src/v1.rs:84-88), and the parse runsbefore any KDS fetch, signature check or
report_datacomparison, so an emptyreport in the request body is enough:
Triggering bodies:
report = [], orreport = [03 00 00 00]— any report of4..=392 bytes whose first four bytes are not 0, 1 or 2.
Pre-fix,
cargo test -p sev-snp-qvl:and the same abort through the whole request path,
cargo test -p dstack-attest --test sev_snp_verify:The fix
The other three callers of the same parser already rejected anything that is not
1184 bytes — each with its own copy of the check. The bug is that the
precondition was a convention rather than something the parser owned. One
decode_amd_snp_reportnow checks the length and decodes, and all four callersgo through it, so the next caller gets it right by construction.
Tests
Two regression tests, both of which fail on
nextwith the output above:sev-snp-qvl:fetch_and_verifywith an emptycert_chainand a 0-, 4- and1183-byte report.
dstack-attest: the real SEV-SNP fixture with its report andcert_chainemptied, re-encoded, decoded through
VersionedAttestation::from_bytesandrun through
verify— the exact shape of a/verifybody.cargo test -p dstack-mr -p dstack-types -p tpm-qvl -p tpm-types -p dstack-attest -p sev-snp-qvl -p cc-eventlog -p dstack-verifieris green,cargo clippy -p sev-snp-qvl -p dstack-attest --lib -- -D warnings --allow unused_variablesis clean,cargo fmt --all -- --checkis clean.(
cargo clippy --all-targetsdoes not pass onnexteither, so the lib-targetgate is what is used here.)
No measurement byte moves: the change is confined to
sev-snp-qvl, which nomeasurement path calls.
dstack-mr'ssev::tests::measurement_vector_does_not_drift,the inline TDX vectors, and the
--ignoredtdvf_parsetest against the cachedreal v0.5.5 image all pass unchanged.
Relation to the other open parser PRs
This came out of a full inventory of the binary attestation and measurement
parsers. Everything else the inventory turned up in this area is either already
bounded or already has an open PR bounding it — #1231 (PE headers), #1236 (TDVF
and the TD HOB witness), #1238 (TPM collateral), #1248 (SNP certificate table),
#1252 (SEV page budget), #1267 (duplicate PCR indices), #1275 (
compute_pcr_digestboundaries and four more), #1249 (the proptest harness and corpus). This is the
one reachable abort none of them covers.
Test-merges: clean against #1231, #1236, #1238, #1252 and #1267. One trivial
conflict each with #1248 and #1249 (both add a
constnext toCERT_TABLE_ENTRY_SIZE— keep both). One conflict with #1275, which renamesparse_amd_snp_reporttoparse_unverified_amd_snp_reportin the same placethis lifts the guard out — keep #1275's rename and doc on the public wrapper and
let its body call
decode_amd_snp_report. All three resolutions were appliedlocally and the suites pass.