Attestation for a Confidential VM instance is the process of improving confidence
that the instance is legitimate and operating in an expected state. It's a
[vital tool](https://confidentialcomputing.io/2023/04/06/why-is-attestation-required-for-confidential-computing/)
in validating that your workload is running in a trusted execution environment
(TEE).

## CPU-based attestation

Attestation reports are the evidence that your VM is running in a TEE. They are
generated by the Confidential VM instance, and depending on the
Confidential Computing technology used are signed either by a software-based
vTPM, or a dedicated, hardware-based Trusted Security Module (TSM). Attestation
reports contain measurements related to bootloader activity, hardware
configuration, firmware configuration, and other boot-time logged events that
help to validate the Confidential VM instance's state and identity.

The type of attestation report you can request depends on the
Confidential Computing technology your Confidential VM instance is using.

| Signing source | Type | Report coverage | Confidential Computing technology |||
| Signing source | Type | Report coverage | SEV | SEV-SNP | Intel TDX |
|---|---|---|---|---|---|
| **Google-managed vTPM** | Software-based vTPM | Boot loader activity, kernel integrity | Yes | Yes | Yes |
| **AMD Secure Processor** ^1^ | Hardware-based TSM | Hardware and firmware environment | No | Yes | No |
| **Intel TDX module** | Hardware-based TSM | Hardware and firmware environment^2^ | No | No | Yes |


1. The AMD Secure Processor is a shared resource available to all hosts on
the physical server it's present in. A host can throttle guest access to the
Secure Processor, and firmware updates to the Secure Processor (which are
considered
[host events](https://docs.cloud.google.com/compute/docs/instances/host-maintenance-overview))
can happen at any time.


2. The initial launch component (the firmware) for TDX Confidential VM
instances is measured into the Measurement of the Trust Domain (MRTD), while
the remaining boot chain is measured into the Runtime Measurement Registers
(RTMR), rooting all measurements in hardware. Users can extend the RTMR\[3\]
register with user space measurements.

### Request an attestation report

You can request attestation reports from the Google-managed vTPM, AMD's Secure
Processor, and Intel's TDX module with the following tools:

- [Go-TPM](https://github.com/google/go-tpm)

- [Go-TPM tools](https://github.com/google/go-tpm-tools) (version 0.4.4 or later
  is required for AMD SEV-SNP and Intel TDX support)

The `GceNonHostInfo` event in the vTPM attestation event log shows what
Confidential Computing technology is in use. Go-TPM tools can request an
attestation report from the AMD Secure Processor if AMD SEV-SNP is used, or from
the Intel TDX module if Intel TDX is used.

For hardware attestation reports only, you can send a cryptographic challenge to
the TSM with the following tools:

- For AMD SEV-SNP, use [SEV Guest](https://github.com/google/go-sev-guest).
  Version Chip Endorsement Key (VCEK) certificates are cached on the VM instead
  of requested directly from AMD's key distribution system (KDS).

- For Intel TDX, use [TDX Guest](https://github.com/google/go-tdx-guest).

#### Intel TDX on Ubuntu

For Ubuntu images on kernel 1016 and newer, the `tdx_guest` module is in the
`linux-modules-extra` package.

To install the `linux-modules-extra` package, run the following command:

    sudo apt-get install linux-modules-extra-gcp

If you encounter problems while installing `linux-modules-extra-gcp`, you can
update the kernel by running the following command:

    sudo apt-get upgrade

You must reboot or manually load the module for the changes to take effect. To
manually load the module, run the following command:

    sudo modprobe tdx_guest

### Verify attestation reports with Google Cloud Attestation

If your trust model allows it, instead of writing and running an attestation
verifier yourself, you can use
[Google Cloud Attestation](https://docs.cloud.google.com/confidential-computing/docs/attestation).
This involves using [Go-TPM tools](https://github.com/google/go-tpm-tools) to
retrieve an attestation quote from a Confidential VM instance's vTPM, and sending
it to Google Cloud Attestation for verification. If the quote passes
verification, Google Cloud Attestation returns a
[token](https://docs.cloud.google.com/confidential-computing/confidential-vm/docs/token-claims) containing VM information that you can
then
[compare against your own policy](https://docs.cloud.google.com/confidential-computing/confidential-space/docs/connect-external-resources#parse_and_validate_attestation_tokens)
to confirm whether or not the VM should be trusted.

Google Cloud Attestation can be used with Confidential VM instances that use the
following Confidential Computing technologies:

- AMD SEV

- Intel TDX on
  [C3 machine types](https://docs.cloud.google.com/confidential-computing/confidential-vm/docs/supported-configurations#machine-types)

For an end-to-end example of working with Google Cloud Attestation, see the
[vTPM Remote Attestation on Confidential Virtual Machine](https://codelabs.developers.google.com/codelabs/vtpm-remote-attestation-on-confidential-virtual-machine#0)
codelab.

## GPU-based attestation

The GPU attestation involves verifying the GPU driver, the GPU device, or both.

### Known issues

GPU attestation might fail, reporting a mismatched measurement record at
index 9. Google and NVIDIA are working on a fix.

To work around the issue, perform a full
[stop and restart of the Confidential VM](https://docs.cloud.google.com/compute/docs/instances/stop-start-instance).
Rebooting the VM from the VM's guest OS does not fix the issue.

### GPU Driver attestation

To ensure robust attestation, enable
[Secure Boot](https://docs.cloud.google.com/compute/shielded-vm/docs/shielded-vm#secure-boot)
when creating your Confidential VM instance.

Secure Boot allows for the loading of only distribution-signed GPU drivers.
This verification is essential for confirming that the GPU driver is officially
released and provided by NVIDIA. An official driver is important as it
establishes a secure Security Protocol and Data Model (SPDM) session with
GPU devices and serves as the root of trust for NVIDIA GPU device attestation.

### NVIDIA GPU Device attestation

In addition to GPU driver attestation, you can further attest to NVIDIA GPU
devices. NVIDIA GPU device attestation verifies the Video BIOS (VBIOS) running
on the GPU. This lets you identify NVIDIA software versions and assess the
presence of potential vulnerabilities.

To perform NVIDIA GPU device attestation, install `go-nvattest-tools`
dependencies and build the `nvattest` tool from
[`google/go-nvattest-tools`](https://github.com/google/go-nvattest-tools):

1. Install the build dependencies:

       sudo apt-get update && sudo apt-get install -y \
         git gcc pkg-config libxml2-dev curl

2. Download and install Go:

       GO_VERSION="1.25.0"
       curl -fsSL \
         "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz" \
         -o go.tar.gz
       sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go.tar.gz
       rm go.tar.gz
       export PATH=/usr/local/go/bin:$PATH

3. Clone the repository and compile the `nvattest` binary:

       git clone https://github.com/google/go-nvattest-tools.git
       cd go-nvattest-tools
       go build -o nvattest ./cmd/nvattest

#### Local GPU device attestation

Local GPU device attestation lets you perform the attestation process directly
on your VM instance and view the results locally to verify the integrity of your
GPU.

To perform live local GPU device attestation, run the `nvattest` tool directly
on your Confidential VM instance:

    sudo ./nvattest attest --device=gpu

Optionally, you can separate evidence collection from verification:

1. Generate a 32-byte hex nonce and collect the attestation evidence:

       NONCE=$(openssl rand -hex 32)
       sudo ./nvattest collect-evidence \
         --device=gpu \
         --nonce="${NONCE}" \
         --evidence_file=gpu_evidence.json

2. Verify the collected evidence locally:

       ./nvattest attest \
         --device=gpu \
         --nonce="${NONCE}" \
         --evidence_file=gpu_evidence.json