|
| 1 | +# dstack-verifier |
| 2 | + |
| 3 | +A HTTP server that provides CVM (Confidential Virtual Machine) verification services using the same verification process as the dstack KMS. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- **TDX Quote Verification**: Uses dcap-qvl to verify TDX quotes |
| 8 | +- **Event Log Verification**: Validates event logs and extracts app information |
| 9 | +- **OS Image Hash Verification**: Uses dstack-mr to ensure OS image hash matches expected measurements |
| 10 | +- **Automatic Image Download**: Downloads and caches OS images automatically when not found locally |
| 11 | +- **RESTful API**: Simple HTTP endpoints for verification requests |
| 12 | + |
| 13 | +## API Endpoints |
| 14 | + |
| 15 | +### POST /verify |
| 16 | + |
| 17 | +Verifies a CVM attestation with the provided quote, event log, and VM configuration. |
| 18 | + |
| 19 | +**Request Body:** |
| 20 | +```json |
| 21 | +{ |
| 22 | + "quote": "hex-encoded-quote", |
| 23 | + "event_log": "hex-encoded-event-log", |
| 24 | + "vm_config": "json-vm-config-string", |
| 25 | + "pccs_url": "optional-pccs-url" |
| 26 | +} |
| 27 | +``` |
| 28 | + |
| 29 | +**Response:** |
| 30 | +```json |
| 31 | +{ |
| 32 | + "is_valid": true, |
| 33 | + "details": { |
| 34 | + "quote_verified": true, |
| 35 | + "event_log_verified": true, |
| 36 | + "os_image_hash_verified": true, |
| 37 | + "report_data": "hex-encoded-64-byte-report-data", |
| 38 | + "tcb_status": "OK", |
| 39 | + "advisory_ids": [], |
| 40 | + "app_info": { |
| 41 | + "app_id": "hex-string", |
| 42 | + "compose_hash": "hex-string", |
| 43 | + "instance_id": "hex-string", |
| 44 | + "device_id": "hex-string", |
| 45 | + "mrtd": "hex-string", |
| 46 | + "rtmr0": "hex-string", |
| 47 | + "rtmr1": "hex-string", |
| 48 | + "rtmr2": "hex-string", |
| 49 | + "rtmr3": "hex-string", |
| 50 | + "mr_system": "hex-string", |
| 51 | + "mr_aggregated": "hex-string", |
| 52 | + "os_image_hash": "hex-string", |
| 53 | + "key_provider_info": "hex-string" |
| 54 | + } |
| 55 | + }, |
| 56 | + "reason": null |
| 57 | +} |
| 58 | +``` |
| 59 | + |
| 60 | +### GET /health |
| 61 | + |
| 62 | +Health check endpoint that returns service status. |
| 63 | + |
| 64 | +**Response:** |
| 65 | +```json |
| 66 | +{ |
| 67 | + "status": "ok", |
| 68 | + "service": "dstack-verifier" |
| 69 | +} |
| 70 | +``` |
| 71 | + |
| 72 | +## Configuration |
| 73 | + |
| 74 | +Configuration can be provided via: |
| 75 | +1. TOML file (default: `dstack-verifier.toml`) |
| 76 | +2. Environment variables with prefix `DSTACK_VERIFIER_` |
| 77 | +3. Command line arguments |
| 78 | + |
| 79 | +### Configuration Options |
| 80 | + |
| 81 | +- `host`: Server bind address (default: "0.0.0.0") |
| 82 | +- `port`: Server port (default: 8080) |
| 83 | +- `image_cache_dir`: Directory for cached OS images (default: "/tmp/dstack-verifier/cache") |
| 84 | +- `image_download_url`: URL template for downloading OS images (default: GitHub releases URL) |
| 85 | +- `image_download_timeout_secs`: Download timeout in seconds (default: 300) |
| 86 | +- `pccs_url`: Optional PCCS URL for quote verification |
| 87 | + |
| 88 | +### Example Configuration File |
| 89 | + |
| 90 | +```toml |
| 91 | +host = "0.0.0.0" |
| 92 | +port = 8080 |
| 93 | +image_cache_dir = "/var/cache/dstack-verifier" |
| 94 | +image_download_url = "http://0.0.0.0:8000/mr_{OS_IMAGE_HASH}.tar.gz" |
| 95 | +image_download_timeout_secs = 300 |
| 96 | +pccs_url = "https://pccs.example.com" |
| 97 | +``` |
| 98 | + |
| 99 | +## Usage |
| 100 | + |
| 101 | +```bash |
| 102 | +# Run with default config |
| 103 | +cargo run --bin dstack-verifier |
| 104 | + |
| 105 | +# Run with custom config file |
| 106 | +cargo run --bin dstack-verifier -- --config /path/to/config.toml |
| 107 | + |
| 108 | +# Set via environment variables |
| 109 | +DSTACK_VERIFIER_PORT=9000 cargo run --bin dstack-verifier |
| 110 | +``` |
| 111 | + |
| 112 | +## Testing |
| 113 | + |
| 114 | +Two test scripts are provided for easy testing: |
| 115 | + |
| 116 | +### Full Test (with server management) |
| 117 | +```bash |
| 118 | +./test.sh |
| 119 | +``` |
| 120 | +This script will: |
| 121 | +- Build the project |
| 122 | +- Start the server |
| 123 | +- Run the verification test |
| 124 | +- Display detailed results |
| 125 | +- Clean up automatically |
| 126 | + |
| 127 | +### Quick Test (assumes server is running) |
| 128 | +```bash |
| 129 | +./quick-test.sh |
| 130 | +``` |
| 131 | +This script assumes the server is already running and just sends a test request. |
| 132 | + |
| 133 | +## Verification Process |
| 134 | + |
| 135 | +The verifier performs three main verification steps: |
| 136 | + |
| 137 | +1. **Quote Verification**: Validates the TDX quote using dcap-qvl, checking the quote signature and TCB status |
| 138 | +2. **Event Log Verification**: Replays event logs to ensure RTMR values match and extracts app information |
| 139 | +3. **OS Image Hash Verification**: |
| 140 | + - Automatically downloads OS images if not cached locally |
| 141 | + - Uses dstack-mr to compute expected measurements |
| 142 | + - Compares against the verified measurements from the quote |
| 143 | + |
| 144 | +All three steps must pass for the verification to be considered valid. |
| 145 | + |
| 146 | +### Automatic Image Download |
| 147 | + |
| 148 | +When an OS image is not found in the local cache, the verifier will: |
| 149 | + |
| 150 | +1. **Download**: Fetch the image tarball from the configured URL |
| 151 | +2. **Extract**: Extract the tarball contents to a temporary directory |
| 152 | +3. **Verify**: Check SHA256 checksums to ensure file integrity |
| 153 | +4. **Validate**: Confirm the OS image hash matches the computed hash |
| 154 | +5. **Cache**: Move the validated files to the cache directory for future use |
| 155 | + |
| 156 | +The download URL template uses `{OS_IMAGE_HASH}` as a placeholder that gets replaced with the actual OS image hash from the verification request. |
| 157 | + |
| 158 | +## Dependencies |
| 159 | + |
| 160 | +- dcap-qvl: TDX quote verification |
| 161 | +- dstack-mr: OS image measurement computation |
| 162 | +- ra-tls: Attestation handling and verification |
| 163 | +- rocket: HTTP server framework |
0 commit comments