Attesting a buckypaper VM

This tutorial is aimed at creating an attestation for confidential VMs.

Create a namespace (Optional)

If the plugin was enabled with the namespacing option, you will need to create a namespace for your attestation. You can learn how to create and use namespaces in the documentation.

Register new attestation

After creating the required identities and a policy, you are ready to create an attestation. This will hold the information for a specific workload.

Method and URL

POST http://localhost:8200/v1/auth/{mount}/attestations

Headers

Name
Value

X-Vault-Token

Body

Name
Type
Description

name

string

Test-VM

description

string

Example VM on CSP

namespace

string

your-namespace

policy

string

test

events

string

http://localhost:3000/webhook

Request

vault write auth/ratls/attestations - <<'EOF'
{
  "name": "Example",
  "description": "Add your text",
  "namespace": "my-namespace",
  "events": "http://localhost:8000",
  "policy": "test"
}
EOF

Response

Key            Value
---            -----
created        1734563330
description    Add your text
events         http://localhost:8000
name           Example
namespace      my-namespace
nonce          n/a
policy         test
updated        0
uuid           ae294417-95ca-4aad-9647-77dbd3249771

Create a VM

At this stage, we will create an Azure VM from the DC2as_v5 family with the Ubuntu 20_04-lts-cvm operating system version, as it supports confidential VMs.

Use the provider azure-sev-snp-vtpm.

Download and run the vhsm agent inside the VM with your desired configuration. The binary is available from the attestation server at http://localhost:8200/static/vhsm.

When creating the VM, you can include all of this in cloud-init to automate the process.

Configuration

auto_auth {
  method {
    type        = "nitride"
    mount_path  = "ratls"
    min_backoff = "1h"
    max_backoff = "2h"

    config {
      provider = "aws-sev-snp-raw"
      workload = "ae294417-95ca-4aad-9647-77dbd3249771"
    }
  }
}

template_config {
  static_secret_render_interval = "5m"
  exit_on_retry_failure         = true
}

vault {
  address = "https://external-address:8200"
}

You can generate this config with this command:

vhsm agent generate-config -attested -provider=aws-sev-snp-raw -workload=$uuid

Attesting

vhsm agent -config=agent.hcl

Webhook data

Once all the steps have been completed, the result of the attestation will be sent to the webhook you specified when creating the attestation. Below is an example of what is sent to the webhook. Ensure that the webhook accepts the HTTP POST method.

{
    "Success": bool,
    "Message": string,
    "Instance": string,
    "Quote": string,
    "Warnings": []string,
}

This will indicate errors using the Success field with an optional Message. Instance corresponds to your attestation instance. Quote contains the raw received attestation. If there were some recoverable errors during the verification, these will be included as Warnings. This can include the inability to fetch the most recent certificates from the respective service and a fallback to cached values that are still valid.

Provisioning a secret

Using the vhsm agent you can also provision secrets with the received token, that is optionally restricted to a child namespace. The required configuration can be generated:

vhsm agent generate-config -file=/tmp/secret=buckypaper/:uuid/env/:name

This will template a file at /tmp/secret with the contents of a secret in the mount buckypaper at the path :uuid/env/:name. You can modify the contents using the go templating.

template {
  destination          = "/tmp/secret"
  create_dest_dirs     = true
  contents             = "{{ with secret \"buckypaper/data/:uuid/env/:name\" }}{{ .Data.data | toJSONPretty }}{{ end }}"
  error_on_missing_key = true
  perms                = "0600"
}

Last updated

Was this helpful?