|
| 1 | +--- |
| 2 | +title: Runtime Attestation |
| 3 | +date: 2025-01-08 |
| 4 | +description: Measurement from workload at runtime |
| 5 | +categories: |
| 6 | +- feature |
| 7 | +tags: |
| 8 | +- attestation |
| 9 | +--- |
| 10 | +Workloads can request runtime attestation of arbitrary data via a generic interface. |
| 11 | +Not all hardware platforms support runtime attestation, but those that do |
| 12 | +will fulfill the request. |
| 13 | + |
| 14 | +On these platforms, the Attestation Agent maintains an event log, |
| 15 | +which tracks attestation events. This log will be forwarded to Trustee |
| 16 | +via the KBS protocol and compared to the hardware evidence. |
| 17 | + |
| 18 | +### Enabling |
| 19 | + |
| 20 | +To enable this feature, set the following parameter in the guest kernel command line. |
| 21 | +```bash |
| 22 | +agent.guest_components_rest_api=all |
| 23 | +``` |
| 24 | +{{% alert title="Warning" color="primary" %}} |
| 25 | +Note that this configuration will also allow the workload to fetch attestation |
| 26 | +reports at runtime. In some configurations this can be dangerous. |
| 27 | +See [attestation report](get-attestation) page for more information. |
| 28 | +{{% /alert %}} |
| 29 | + |
| 30 | +The Attestation Agent configuration must also have runtime attestation enabled. |
| 31 | +This can be set via Init-Data, with the `[eventlog_config]` section below. |
| 32 | +This configuration can also specify the measurement index that will be used. |
| 33 | +On platforms with limited indices, the index will be mapped to the available |
| 34 | +registers. For example, on TDX setting the measurement index to 17 will usually |
| 35 | +result in extending RTMR 3. |
| 36 | + |
| 37 | +```toml |
| 38 | +version = "0.1.0" |
| 39 | +algorithm = "sha384" |
| 40 | +[data] |
| 41 | +"aa.toml" = ''' |
| 42 | +[token_configs] |
| 43 | +[token_configs.kbs] |
| 44 | +url = "http://<trustee-uri>" |
| 45 | +
|
| 46 | +[eventlog_config] |
| 47 | +init_pcr = 17 |
| 48 | +enable_eventlog = true |
| 49 | +''' |
| 50 | + |
| 51 | +"cdh.toml" = ''' |
| 52 | +[kbc] |
| 53 | +name = "cc_kbc" |
| 54 | +url = "http://<trustee-uri>" |
| 55 | +''' |
| 56 | +``` |
| 57 | + |
| 58 | +The above configurations can be added to a workload as annotations. |
| 59 | +See the [Init-Data](initdata) page for more information on using Init-Data. |
| 60 | +```yaml |
| 61 | +apiVersion: apps/v1 |
| 62 | +kind: Deployment |
| 63 | +metadata: |
| 64 | + name: nginx |
| 65 | + labels: |
| 66 | + app: nginx |
| 67 | +spec: |
| 68 | + replicas: 1 |
| 69 | + selector: |
| 70 | + matchLabels: |
| 71 | + app: nginx |
| 72 | + template: |
| 73 | + metadata: |
| 74 | + labels: |
| 75 | + app: nginx |
| 76 | + annotations: |
| 77 | + io.katacontainers.config.hypervisor.kernel_params: "agent.guest_components_rest_api=all" |
| 78 | + io.katacontainers.config.hypervisor.cc_init_data: "H4sIAAAAAAAAA4WOwQ6DIBBE7/sVhos3xGpSa9IvMYQgUiEiGFz9/kLTHtpLjzO7M29OHXcbfHEvCKM1ZQSkm0O0aNbs7UY2XUtgmCRKDkRKimF1JN3KsoQBw6K9UME/7LzzH02XMXlHdLnJIG59VdWMXtqWMnpr+o51iQeDPrVHF+Z3joP1FsWmYsrVV9Bejk6Lz1cyMR4aMh+Imsz3omVUHLxcdYYqJZImfze8up7xdiRhCwEAAA==" |
| 79 | + spec: |
| 80 | + runtimeClassName: (...) |
| 81 | + containers: |
| 82 | + - name: nginx |
| 83 | + (...) |
| 84 | +``` |
| 85 | +### Runtime Attestation |
| 86 | +
|
| 87 | +Once enabled, runtime attestation can be triggered via the rest API. |
| 88 | +```bash |
| 89 | +curl -X POST http://127.0.0.1:8006/aa/aael \ |
| 90 | + -H "Content-Type: application/json" \ |
| 91 | + -d '{"domain":"test","operation":"test","content":"test"}' |
| 92 | +``` |
| 93 | + |
| 94 | +The `domain` and `operation` are context fields that will be included in the event log. |
| 95 | + |
| 96 | +You can check that the event log was updated by inspecting an attestation token. |
| 97 | +```bash |
| 98 | +curl http://127.0.0.1:8006/aa/token\?token_type\=kbs | jq -r '.token |split(".") | .[1] | @base64d | fromjson' |
| 99 | +``` |
| 100 | +The event log may contain boot-time entries, but at the end you should see your entry. |
| 101 | + |
| 102 | +```json |
| 103 | +{ |
| 104 | + "details":{ |
| 105 | + "data":{ |
| 106 | + "content":"test", |
| 107 | + "domain":"test", |
| 108 | + "operation":"test" |
| 109 | + }, |
| 110 | + "string":"test test test", |
| 111 | + "unicode_name":"AAEL" |
| 112 | + }, |
| 113 | + "digest_matches_event":true, |
| 114 | + "digests":[ |
| 115 | + { |
| 116 | + "alg":"SHA-384", |
| 117 | + "digest":"1495be3eb2120e59facb8f92447d64f..." |
| 118 | + } |
| 119 | + ], |
| 120 | + "event":"TEVBQREAAAB0ZXN0IHRlc3QgdGVzenp6dA==", |
| 121 | + "index":4, |
| 122 | + "type_name":"EV_EVENT_TAG" |
| 123 | +} |
| 124 | +``` |
0 commit comments