flashbots / flashbots/attested-tls

feat: decouple platform and measurements, allow flexible policies

Open
#28 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Rust
Stars
5
Forks
3
Avg merge
4d 1h
Merged PRs (30d)
8

Description

currently, the measurement policies look like:

```json5
[
{
"measurement_id": "dcap-tdx-example",
"attestation_type": "dcap-tdx",
"measurements": {
"mrtd": {
"expected_any": [
"47a1cc074b914df8596bad0ed13d50d561ad1effc7f7cc530ab86da7ea49ffc03e57e7da829f8cba9c629c3970505323"
]
},
"rtmr0": {
"expected_any": [
"da6e07866635cb34a9ffcdc26ec6622f289e625c42c39b320f29cdf1dc84390b4f89dd0b073be52ac38ca7b0a0f375bb"
]
},
// ...
}
}
]
```

which poses 2 problems:

- it gives false impression that attestation type binds the measurements to platform (e.g. `qemu-tdx` vs. `gcp-tdx`)
- it makes hard to write complex policies (e.g. if we want to allow any permutation of 2 values for RTMR0 and 3 values for RTMR1, then we'd have to create a list of 6 entries)

the suggestion is to consider moving towards policies that are built along the lines of:

```rust
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub enum TdxRegister {
MRTD,
RTMR(u8),
}

pub type TdxMeasurement = [u8; 48];

#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub enum PcrRegister {
Pcr(u8),
}

pub type PcrMeasurement = [u8; 32];

#[derive(Clone, Debug, PartialEq, Eq)]
pub enum Measurements {
Dcap(HashMap),
Vtpm(HashMap),
None,
}

#[derive(Clone, Debug, PartialEq, Eq)]
pub enum ExpectedMeasurement {
Dcap(HashMap>),
Vtpm(HashMap>),
None,
}

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum DcapPlatform {
Azure,
Gcp,
Qemu,
None,
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct MeasurementRecord {
#[serde(skip_serializing_if = "Option::is_none")]
pub platform: Option,

#[serde(skip_serializing_if = "Option::is_none")]
pub measurements: Option>,

#[serde(skip_serializing_if = "Option::is_none")]
pub comment: Option,
}

#[derive(Clone, Debug, PartialEq, Eq)]
pub enum MeasurementClause {
Match(Box),

Not(Box),
And(Box>),
Or(Box>),
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub struct MeasurementPolicy {
pub policy: MeasurementClause,

#[serde(skip_serializing_if = "Option::is_none")]
pub comment: Option,
}
```

this would allow:

- writing complex policies with and/or/not logical predicates
- decouple platform from measurements (e.g. if in the future azure implements native tdx attestation, we could easily extend support for that)
- when we have DCAP verification implemented, it could be easily plugged into `DcapPlatform`

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.