Skip to content

Commit 8c1f88b

Browse files
authored
Merge pull request #34 from Dstack-TEE/configid-attest
Add mr_config_id based remote attestation
2 parents 40e08f3 + 2dc358a commit 8c1f88b

10 files changed

Lines changed: 585 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ These show useful patterns you may want to copy:
1515
## Illustrating Dstack Features
1616
- [./prelaunch-script](./prelaunch-script)
1717
- [./private-docker-image-deployment](./private-docker-image-deployment)
18+
- [./attestation](./attestation) shows how to verify attestation for Dstack apps
1819
## App examples
1920
- [./timelock-nts](./timelock-nts) a timelock decryption example using secure NTP (NTS) from Cloudflare as a time oracle
2021
## Tutorial (Coming soon)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/work
2+
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
# ConfigID-based Dstack Remote Attestation Verification
2+
3+
Dstack v0.5.1 introduced [compose_hash in mr_config_id](https://github.com/Dstack-TEE/dstack/pull/190), which simplifies the verification process compared to the RTMR3-based verification. The verification doesn't need to replay the RTMRs, and only needs to compare the RTMRs and mr_config_id to known good values.
4+
5+
## Steps
6+
7+
This guide walks you through the process of deploying a Dstack application and verifying its attestation using ConfigID-based verification.
8+
9+
### 1. Download Required Materials
10+
11+
```bash
12+
./attest.sh download
13+
```
14+
15+
**Explanation:** This step downloads all necessary tools and images required for the verification process:
16+
- dcap-qvl tool for verifying Intel TDX quotes
17+
- dstack-mr tool for calculating expected measurement values
18+
- Dstack VM image that will be used for deployment
19+
20+
The downloaded files are stored in the `work/bin` and `work/images` directories.
21+
22+
### 2. Prepare Application Composition
23+
24+
```bash
25+
./attest.sh compose
26+
```
27+
28+
**Explanation:** This step generates an `app-compose.json` file based on the `docker-compose.yaml`. The app-compose.json file defines what code to run in the App and the configuration of the App. The script also calculates a compose hash, which is a SHA-256 hash of the app-compose.json file. This hash is crucial for the attestation verification process as it's used to create the mr_config_id.
29+
30+
### 3. Calculate Known Good Measurement Registers
31+
32+
```bash
33+
./attest.sh calc-mrs
34+
```
35+
36+
**Explanation:** Before deploying the application, this step calculates the expected "known good" measurement register values that should be present in a legitimate, unmodified deployment. It uses the dstack-mr tool to:
37+
- Calculate the mr_config_id by taking the compose hash and padding it to 96 characters
38+
- Generate expected values for RTMR[0-2] based on the VM image metadata and configuration
39+
- Save these values to `known_good_mrs.json` for later comparison
40+
41+
### 4. Deploy the Application
42+
43+
```bash
44+
./attest.sh deploy
45+
```
46+
47+
**Explanation:** This step deploys the application to the Dstack environment:
48+
- Uploads the app-compose.json to the dstack-vmm
49+
- Creates a VM with the specified configuration
50+
- Waits for the VM to boot and initialize
51+
- Saves the instance ID for future reference
52+
53+
### 5. Verify Attestation
54+
55+
```bash
56+
./attest.sh verify
57+
```
58+
59+
**Explanation:** The final step verifies that the deployed application is running in a genuine Intel TDX environment with the expected configuration:
60+
- Requests a quote from the application's `/quote.json` endpoint
61+
- Verifies the quote using the dcap-qvl tool
62+
- Compares the measurement registers in the quote with the known good values calculated earlier:
63+
- mr_config_id (contains the app-compose.json hash)
64+
- mr_td (TD measurement register)
65+
- rt_mr0, rt_mr1, rt_mr2 (runtime measurement registers)
66+
- Displays the report data, which can contain application-specific attestation information
67+
68+
The verification process confirms that the application is running in a genuine TDX environment with the expected configuration and has not been tampered with.
69+
70+
71+
## Full log
72+
73+
```bash
74+
$ ./attest.sh download
75+
Downloading materials required for verification...
76+
Downloading DCAP QVL tool from https://github.com/Phala-Network/dcap-qvl/releases/download/v0.2.4/dcap-qvl-linux-amd64
77+
% Total % Received % Xferd Average Speed Time Time Time Current
78+
Dload Upload Total Spent Left Speed
79+
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
80+
100 7144k 100 7144k 0 0 11.8M 0 --:--:-- --:--:-- --:--:-- 11.8M
81+
Downloading Dstack MR tool from https://github.com/kvinwang/dstack-mr/releases/download/v0.5.0/dstack-mr-linux-amd64
82+
% Total % Received % Xferd Average Speed Time Time Time Current
83+
Dload Upload Total Spent Left Speed
84+
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
85+
100 6603k 100 6603k 0 0 11.6M 0 --:--:-- --:--:-- --:--:-- 104M
86+
Downloading Dstack image...
87+
Downloading image from https://github.com/Dstack-TEE/meta-dstack/releases/download/v0.5.1/dstack-0.5.1.tar.gz
88+
% Total % Received % Xferd Average Speed Time Time Time Current
89+
Dload Upload Total Spent Left Speed
90+
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
91+
100 161M 100 161M 0 0 76.3M 0 0:00:02 0:00:02 --:--:-- 98.5M
92+
Extracting image...
93+
Image extracted successfully
94+
Downloads completed successfully
95+
```
96+
97+
98+
```bash
99+
$ ./attest.sh compose
100+
Preparing app-compose.json for deployment...
101+
Generating app-compose.json
102+
app-compose.json has been prepared and is ready for deployment
103+
Compose hash: eaae2351f15ecb6db16135b31039afa2a8b023e287c28200c44aeae5f0c206bd
104+
```
105+
106+
```bash
107+
$ ./attest.sh calc-mrs
108+
Calculating known good MRs before deployment...
109+
Using mr_config_id: eaae2351f15ecb6db16135b31039afa2a8b023e287c28200c44aeae5f0c206bd00000000000000000000000000000000
110+
Running dstack-mr to calculate MRs...
111+
MRs calculation completed. Results saved to known_good_mrs.json
112+
```
113+
114+
```bash
115+
$ ./attest.sh deploy
116+
Deploying app...
117+
Deploying app...
118+
✅ App deployed successfully!
119+
VM ID: 5ba3bcd0-7344-4450-b919-e86e52dd3b6c
120+
Waiting for the app to start...
121+
Boot progress: booting
122+
Boot progress: booting
123+
Boot progress: booting
124+
Boot progress: booting
125+
Boot progress: initializing data disk
126+
Boot progress: initializing data disk
127+
Boot progress: initializing data disk
128+
✅ App started successfully!
129+
Instance ID: 41c97635037ba6e5ac6752be10ed1036bb4797a7
130+
```
131+
132+
```bash
133+
$ ./attest.sh verify
134+
Requesting quote from the app and verifying attestation...
135+
Requesting quote from /quote
136+
✅ Quote downloaded successfully!
137+
Verifying attestation using DCAP QVL tool
138+
Getting collateral from PCS...
139+
Quote verified
140+
✅ Attestation verification successful!
141+
Comparing RTMRs with known good values...
142+
Using TD10 report for verification
143+
✅ mr_config_id matches known good value
144+
✅ mr_td matches known good value
145+
✅ rt_mr0 matches known good value
146+
✅ rt_mr1 matches known good value
147+
✅ rt_mr2 matches known good value
148+
Report data:
149+
12340000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
150+
```

0 commit comments

Comments
 (0)