|
1 | 1 | # Remote Attestation Framework for AWS Nitro Enclaves |
| 2 | + |
| 3 | + |
| 4 | +This repository demonstrates a simple end-to-end flow against an AWS Nitro Enclave: **ECDH key exchange & attestation verification → confidential computation (example: adding two integers)**. |
| 5 | + |
| 6 | +- **Parent VM**: An AWS EC2 instance (Ubuntu 24.04) with Nitro Enclaves enabled. Runs the Enclave and the vsock proxy. |
| 7 | +- **Client**: Can run on any machine, but this README assumes you run it on the Parent VM (localhost). |
| 8 | + |
| 9 | +## Tested environment (detailed) |
| 10 | + |
| 11 | +### Parent VM (AWS EC2) |
| 12 | + |
| 13 | +- **Instance type**: `c5.xlarge` |
| 14 | + - vCPUs: 4 |
| 15 | + - Memory: 8 GiB |
| 16 | + - CPU arch: `x86_64` |
| 17 | +- **AMI**: Ubuntu Server 24.04 LTS |
| 18 | + - AMI ID: `ami-06e3c045d79fd65d9` |
| 19 | +- **Storage**: 64 GiB `gp3` |
| 20 | +- **Kernel**: 6.14.0-1018-aws |
| 21 | +- **Nitro Enclaves**: Enabled |
| 22 | +- **Nitro Enclaves CLI / driver**: v1.4.4 |
| 23 | +- **Rust toolchain**: v1.90.0 |
| 24 | + |
| 25 | +### Enclave |
| 26 | + |
| 27 | +- **OS**: Ubuntu 24.04 |
| 28 | +- **Allocated vCPUs**: 2 |
| 29 | +- **Allocated Memory**: 512 MiB |
| 30 | +- **OS**: Ubuntu 24.04 |
| 31 | +- **Rust toolchain**: v1.90.0 |
| 32 | + |
| 33 | +### Client |
| 34 | + |
| 35 | +- Ran on the same Parent VM (localhost). |
| 36 | + |
| 37 | +## Architecture |
| 38 | + |
| 39 | +- `enclave/`: Enclave application (listens on vsock `port=5000`) |
| 40 | +- `proxy/`: **untrusted** HTTP → vsock proxy (listens on HTTP `ip:port`, forwards to vsock `port=5000`) |
| 41 | +- `client/`: Client app (POSTs JSON to the proxy, verifies attestation, then calls the confidential computing API) |
| 42 | + |
| 43 | +## Quick start (all on the Parent VM) |
| 44 | + |
| 45 | +Clone the repository: |
| 46 | + |
| 47 | +```bash |
| 48 | +git clone <THIS_REPOSITORY> |
| 49 | +cd <THIS_REPOSITORY> |
| 50 | +``` |
| 51 | + |
| 52 | +### 1. Parent VM setup (Ubuntu 24.04) |
| 53 | + |
| 54 | +```bash |
| 55 | +make setup-docker |
| 56 | +make setup-nitro-cli |
| 57 | +``` |
| 58 | + |
| 59 | +### 2. Client setup (this README runs it on the Parent VM) |
| 60 | + |
| 61 | +```bash |
| 62 | +make setup-client |
| 63 | +``` |
| 64 | + |
| 65 | +### 3. Build the Enclave image and copy PCRs into `client-configs.json` |
| 66 | + |
| 67 | +```bash |
| 68 | +make build-enclave |
| 69 | +``` |
| 70 | + |
| 71 | +When you run `make build-enclave`, PCR measurements are printed like this (example): |
| 72 | + |
| 73 | +```text |
| 74 | +Enclave Image successfully created. |
| 75 | +{ |
| 76 | + "Measurements": { |
| 77 | + "HashAlgorithm": "Sha384 { ... }", |
| 78 | + "PCR0": "...", |
| 79 | + "PCR1": "...", |
| 80 | + "PCR2": "..." |
| 81 | + } |
| 82 | +} |
| 83 | +``` |
| 84 | + |
| 85 | +Copy **PCR0/1/2** into `"PCRs"` in `client-configs.json`. |
| 86 | + |
| 87 | +### 4. Build the vsock proxy |
| 88 | + |
| 89 | +```bash |
| 90 | +make build-proxy |
| 91 | +``` |
| 92 | + |
| 93 | +### 5. Start the Enclave |
| 94 | + |
| 95 | +```bash |
| 96 | +make run-enclave |
| 97 | +``` |
| 98 | + |
| 99 | +### 6. Start the vsock proxy |
| 100 | + |
| 101 | +```bash |
| 102 | +make run-proxy |
| 103 | +``` |
| 104 | + |
| 105 | +### 7. Build and run the client |
| 106 | + |
| 107 | +```bash |
| 108 | +make build-client |
| 109 | +make run-client |
| 110 | +``` |
| 111 | + |
| 112 | +After ECDH key exchange and attestation verification, the client calls the Enclave’s “add two integers” API and then closes the session. |
| 113 | + |
| 114 | +### 8. Stop the Enclave |
| 115 | + |
| 116 | +```bash |
| 117 | +make terminate-enclave |
| 118 | +``` |
| 119 | + |
| 120 | +## Configuration |
| 121 | + |
| 122 | +### Change Enclave Memory / vCPU Allocation |
| 123 | + |
| 124 | +- **Update Makefile variables** |
| 125 | + - `ENCLAVE_MEMORY`(MiB) |
| 126 | + - `ENCLAVE_CPU_COUNT` |
| 127 | +- **Update allocator config** |
| 128 | + - Update `/etc/nitro_enclaves/allocator.yaml` accordingly |
| 129 | +- **Restart the allocator** |
| 130 | + ```bash |
| 131 | + sudo systemctl restart nitro-enclaves-allocator.service |
| 132 | + ``` |
| 133 | + |
| 134 | +### Change Proxy IP / port |
| 135 | + |
| 136 | +- Update `SERVER_IP` / `SERVER_PORT` in `Makefile` |
| 137 | +- Update `"server-ip"` / `"server-port"` in `client-configs.json` |
| 138 | + |
| 139 | +If you run the client from a different machine, allow inbound access to `SERVER_PORT` in the Parent VM security group / firewall rules. |
| 140 | + |
| 141 | +### Client configuration (`client-configs.json`) |
| 142 | + |
| 143 | +- `"PCRs"`: Expected PCR values. Copy from `make build-enclave` output PCR[0-2]. |
| 144 | +- `"print-attestation-json"`: Print the attestation document payload as JSON if `true` |
0 commit comments