Skip to content

fix(tee): validate SNP measurement against expected value (HW-002) - #233

Merged
imran-siddique merged 1 commit into
mainfrom
fix/hw-002-snp-measurement-validation
Jun 8, 2026
Merged

imran-siddique merged 1 commit into
mainfrom
fix/hw-002-snp-measurement-validation

Conversation

@imran-siddique

Copy link
Copy Markdown
Member

Summary

  • Adds expected_measurement field to AttestationConfig (optional, defaults to None)
  • SEVSNPProvider.__init__ accepts the value and stores it as _expected_measurement
  • On each get_attestation_report call, if configured, computes sha384 of the raw firmware measurement bytes and uses hmac.compare_digest for constant-time comparison — raises RuntimeError("measurement mismatch") on failure
  • detect_provider / _get_provider_impl now thread the config through so SEVSNPProvider receives expected_measurement at construction

Closes #172

Test plan

  • test_expected_measurement_loaded_from_config — field parsed from YAML
  • test_expected_measurement_defaults_to_none — omitting field leaves it None
  • test_expected_measurement_non_string_rejected — non-string value raises ConfigError
  • test_sevsnp_no_expected_measurement_skips_check — None value skips comparison
  • test_sevsnp_stores_expected_measurement — value stored on instance
  • test_sevsnp_rejects_mismatched_expected_measurement — mismatch raises RuntimeError
  • test_sevsnp_accepts_matching_expected_measurement — match returns report cleanly
  • test_detect_provider_passes_expected_measurement_to_snp — wired end-to-end

@imran-siddique
imran-siddique force-pushed the fix/hw-002-snp-measurement-validation branch from ddbd966 to caa1219 Compare June 7, 2026 23:50
@imran-siddique
imran-siddique merged commit ccfd6cb into main Jun 8, 2026
1 of 8 checks passed
@imran-siddique
imran-siddique deleted the fix/hw-002-snp-measurement-validation branch July 29, 2026 23:19
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.

MEDIUM: SNP report measurement field not compared with expected value — measurement tampering undetected (HW-002)

1 participant