Skip to content

vtpm: offline mitigation for vtpm corruption #1539

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

mayank-microsoft
Copy link

Adding an offline mitigation library for recovering from vtpm state corruption.

@mayank-microsoft mayank-microsoft requested review from a team as code owners June 18, 2025 19:16
@mayank-microsoft mayank-microsoft force-pushed the vtpm-offline-mitigation branch from d5c979a to b5aefae Compare June 18, 2025 19:19
@mayank-microsoft mayank-microsoft changed the title vtpm: offline mitigation for vtpm vtpm: offline mitigation for vtpm corruption Jun 18, 2025
@mayank-microsoft mayank-microsoft force-pushed the vtpm-offline-mitigation branch from b5aefae to ce114e6 Compare June 18, 2025 19:53
@@ -0,0 +1,19 @@
[package]
name = "vtpm-mitigation"
version = "0.1.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the version - we explicitly don't allow versions here since we don't publish any crates externally

[package]
name = "vtpm-mitigation"
version = "0.1.0"
edition = "2021"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove edition - should be inherited

use ms_tpm_20_ref::MsTpm20RefPlatform;
use parking_lot::Mutex;
use core::fmt;
use std::{borrow::Cow, sync::Arc, time::Instant};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these need to be split on different lines


/// status codes for tpm state blob validation
/// STATUS_VALID_TPM_STATE: The input blob is a valid TPM state blob
pub const STATUS_VALID_TPM_STATE: u64 = 0x0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this status code an enum, or something?

}

/// Recover the given blob and return the recovered blob
fn recover_vtpm_blob(original_blob: &[u8]) -> Result<Vec<u8>, bool> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't use bool as an error type, make an explicit error type that is clear about what kind of error is being represented here.

#[test]
fn test_corrupted_tpm_state_is_revovered() {
setup_logging();
let path: &'static str ="./test-data/corrupted_blob.bin";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you want to do fs reads in tests like this, should we use include_bytes! instead? @smalis-msft thoughts?

@mayank-microsoft mayank-microsoft force-pushed the vtpm-offline-mitigation branch 2 times, most recently from dbe7f42 to a3c2bee Compare June 19, 2025 09:58
@mayank-microsoft mayank-microsoft force-pushed the vtpm-offline-mitigation branch from a3c2bee to ab9f9e2 Compare June 19, 2025 10:03
@mayank-microsoft mayank-microsoft force-pushed the vtpm-offline-mitigation branch from ab9f9e2 to 1624128 Compare June 19, 2025 14:49
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.

2 participants