> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tinfoil.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Backend infrastructure

> This page provides a description of the different components that make up our backend infrastructure. It also describes how Tinfoil guarantees code auditability and data confidentiality using these components.

## Prerequisites

This page assumes some familiarity with the different parts of the
Tinfoil system and the goals associated with attestation and
supply chain transparency verification.

We recommend reading the [technical overview](/verification/verification-in-tinfoil)
first to familiarize yourself.

## Backend infrastructure

The backend architecture is illustrated in Figure 1. All security-critical
components are open source and available on GitHub.

<img src="https://mintcdn.com/tinfoil/QPXTScLceEkhaLM_/images/diagrams/backend-diagram.jpeg?fit=max&auto=format&n=QPXTScLceEkhaLM_&q=85&s=96830c1363a5b7b96c6c943ef06be937" alt="Tinfoil Attestation Architecture" width="2360" height="818" data-path="images/diagrams/backend-diagram.jpeg" />

<p className="text-center text-sm text-gray-500 mt-2">
  Figure 1: Overview of Tinfoil's backend infrastructure and attestation architecture.
</p>

<Note>
  For simplicity, we omit backend components that are not part of the security-critical
  path, such as billing and user account management.
  These are closed-source orchestration-layer components
  that do not need to be attested since they do not touch user requests.
</Note>

### The Secure Enclave Components

The secure enclave consists of the OVMF firmware that boots the confidential VM (CVM) image.
The CVM serves the attestation and terminates the TLS connection from clients.

#### Confidential VM Image

A [confidential VM](https://github.com/tinfoilsh/cvmimage) (CVM) is a virtual machine whose memory is encrypted by the
CPU so that the host operator (including the hypervisor and any privileged
software) cannot read or tamper with its contents. This is the foundation of
[confidential computing](/verification/secure-enclave-primer). Tinfoil's CVM
image is based on Ubuntu with an [AMD SEV-SNP compatible kernel](https://github.com/amdese/linux/tree/snp-host-latest),
which enables the CPU's hardware memory encryption and attestation capabilities.
We [chose to use Ubuntu](https://ubuntu.com/engage/tinfoil-confidential-computing-guide)
because it provides broad driver and package support
needed for GPU workloads. At runtime, the CVM runs a reverse proxy that terminates
TLS and serves the attestation document, the user's workload
(e.g., an inference server), and any supporting services like model weight
verification. All virtual disks are mounted read-only. The firmware,
kernel, and initrd are measured into the attestation report at boot
time, while read-only model weight volumes are verified separately
with dm-verity and checked against the expected values from the
Sigstore bundle during verification.

#### OVMF Firmware

When a confidential VM starts, the very first code that runs is its boot
firmware. This firmware is essentially the "BIOS" of the confidential VM and
initializes the hardware, sets up memory encryption, and hands off to the Linux kernel.
The firmware is the first thing measured by the CPU for the attestation report.
To ensure reproducibility, Tinfoil uses [a pinned version of the OVMF firmware](https://github.com/tinfoilsh/edk2).
Each build is attested to Sigstore and the exact firmware binary running in the
enclave can be verified against the build log.

### Supply Chain Security Architecture

Outside of the secure enclave, we have a release pipeline that provides
supply chain security for all components that become part of the enclave.
This starts with pinned releases of the firmware, CVM image, and model weights.
The sha256 hash of each of these is configured inside a `tinfoil-config.yml`
which is then committed to a public GitHub repo. A GitHub action runs to
create a release consisting of the build and hardware measurements.
These measurements are then committed to a public append-only transparency log.

#### Modelwrap - ensuring model weights are attested

One challenge we need to address in our supply chain security story is the
problem of loading model weights into the secure enclave at runtime. We get
around this by generating a read-only volume with the model weights and
computing a cryptographic commitment to it that is pinned inside the configuration
file. At runtime, the enclave loads the read-only model weights and rejects any
disk that doesn't correspond to the exact attested commitment. We built a utility
we called [modelwrap](https://github.com/tinfoilsh/modelwrap), which is used both
to generate a pinned version of Hugging Face model weights and at runtime to
verify that the pinned model-weight volume mounted in the enclave matches its attested commitment. You can read more about this
in our [technical blog post](https://tinfoil.sh/blog/2026-02-03-proving-model-identity) on the subject.

#### tinfoil-config.yml

The Tinfoil configuration file is a manifest specifying the model commitment (generated via modelwrap),
container images, CVM version, and resource allocation. It is committed to a
deployment repo and its SHA256 hash is embedded in the kernel command line,
creating a cryptographic link between the config and the running enclave.
This config file is used by the measure-image-action GitHub action to generate
hardware measurements that get pinned to the transparency log.

#### measure-image-action

The [measure-image-action](https://github.com/tinfoilsh/measure-image-action) is our
GitHub Actions workflow that converts a
`tinfoil-config.yml` into a deployment config. When a new release is tagged and pushed
to the config repo,
this workflow builds the enclave image and publishes a signed
Sigstore bundle containing the expected measurements,
linking the open source code to the attested binary.
This bundle is signed with a Sigstore keyless certificate issued for the GitHub Actions workflow and committed to the Sigstore transparency log
making it impossible for us to change the code without also changing
the expected attestation measurements.

### Hardware Attestation

Hardware attestation is the process by which the CPU and GPU produce
cryptographic proof of what code is running inside the enclave. This proof
is what clients verify, in tandem to the bundles committed to the transparency log
at build time, before sending any data.

#### Boot sequence and CPU measurement

When a confidential VM starts, the CPU measures each stage of the boot
process — hashing the code and configuration at each step — and records
the results in a hardware-signed attestation report. Here is the sequence
of what happens during boot:

1. **Firmware**: The [OVMF firmware](#ovmf-firmware) initializes the VM.
   Because it is the very first code to execute, it is also the first thing
   the CPU measures and includes in the attestation report.

2. **Kernel**: The OS kernel and initrd load from the read-only root
   filesystem. These are also measured by the CPU.

3. **Configuration verification**: The
   [boot process](https://github.com/tinfoilsh/cvmimage/blob/main/tinfoil/cmd/boot/main.go)
   checks that the `tinfoil-config.yml` on disk matches the attested hash
   embedded in the kernel command line. This ensures the enclave is running
   the exact configuration that was committed to during the
   [build](#supply-chain-security-architecture).

4. **Model weight verification**: Read-only model weight volumes are mounted
   and verified against their
   [modelwrap](#modelwrap---ensuring-model-weights-are-attested) commitments
   using [dm-verity](https://docs.kernel.org/admin-guide/device-mapper/verity.html).
   dm-verity is a Linux kernel subsystem that intercepts every disk read and
   validates it against a Merkle tree root hash, ensuring that no block of
   data has been tampered with. See our
   [blog post on proving model identity](https://tinfoil.sh/blog/2026-02-03-proving-model-identity)
   for a deeper explanation.

5. **Service startup**: The reverse proxy and workload containers start
   using the configuration from the attested config.

The CVM is designed to be entirely stateless, meaning that all virtual disks are mounted read-only,
and ephemeral data uses a ramdisk created at boot. There is no persistent
state that could be modified between boots.

#### GPU verification

For GPU workloads, the boot process includes an additional step: it queries
each NVIDIA GPU to verify it is running in confidential compute mode using
NVIDIA's [`local-gpu-verifier`](https://github.com/NVIDIA/nvtrust/tree/main/guest_tools/gpu_verifiers/local_gpu_verifier).
This creates a chain of trust from the CPU to the GPU. If the CPU fails to
verify the GPU's attestation, it aborts the boot process and the enclave
does not start. Because the GPU attestation is linked to the CPU attestation
report, clients verifying the CPU attestation are also transitively
verifying the GPU configuration.

### Client-side verification

Before exchanging application data (e.g., chat completions)
with an enclave, the [Tinfoil SDK](/sdk/overview) verifies the enclave's identity
and integrity. The SDK fetches the
[attestation document](/verification/predicate) from the enclave, which
includes signed runtime measurements, and verifies the certificate chain back
to the CPU's hardcoded root
certificate ([AMD](https://github.com/tinfoilsh/tinfoil-go/blob/main/verifier/attestation/genoa_cert_chain.pem)).
It then fetches the Sigstore bundle, verifies its
signatures against Sigstore's [root trust anchor](https://github.com/tinfoilsh/tinfoil-go/blob/main/verifier/sigstore/sigstore.go#L22),
and checks the [measurement predicates](/verification/predicate#supported-formats)
to ensure the source code and runtime enclave measurements match. Finally, it
opens a TLS connection and confirms the server's public key matches the one in
the attestation document, binding TLS to the attested key and guaranteeing that
the connection terminates inside a verified enclave.

#### Attestation Proxies

The client-side verification process requires data from several external sources:
the enclave's attestation document, hardware manufacturer's certificate chain,
and the Sigstore bundle from GitHub. Fetching each of these directly can hit
rate limits, add latency, and complicate client implementations. Tinfoil operates
three caching proxies to address this. Importantly, none of these proxies are
trusted — every piece of data they serve is independently verified by the client
against hardcoded root certificates or Sigstore's trust anchor.

**Attestation Bundle Proxy**
Tinfoil runs a proxy that returns
everything the verifier needs in a single request: the enclave's attestation
report, the cert chain, the Sigstore bundle, and the enclave's TLS certificate.
This avoids multiple round-trips to different services during connection-time
verification. The [JavaScript SDK](/sdk/javascript-sdk), for example, uses this
proxy by default. This makes the actual verification code stateless -- it's just
a utility that takes a Tinfoil attestation bundle and verifies everything.

**GitHub Proxy**
`github-proxy.tinfoil.sh` caches GitHub release data, including the
Sigstore bundles published by the [measure-image-action](https://github.com/tinfoilsh/measure-image-action).
The cached data is verified through Sigstore's transparency log and cannot
be forged without Sigstore's signing keys.

**AMD KDS Proxy**
`kds-proxy.tinfoil.sh` caches AMD Key Distribution Service (KDS) certificates
used to validate the CPU attestation. The root AMD certificate is embedded
in the [verifier code](https://github.com/tinfoilsh/tinfoil-go/blob/main/verifier/attestation/genoa_cert_chain.pem),
so the proxy cannot forge certificates — full chain validation is always
performed by the client.

## Transport Security

Tinfoil uses two complementary mechanisms to ensure data is encrypted
end-to-end to verified enclaves: TLS key binding and the
Encrypted HTTP Body Protocol (EHBP).

### TLS Key Binding

TLS key binding ensures all TLS sessions terminate inside a verified enclave,
never on a non-enclave host. The enclave’s attestation includes an
enclave-generated TLS public key tied to the measured runtime,
and terminates TLS inside the enclave (inside the CVM) with a non-exportable
private key that never leaves enclave memory. The client verifier compares
the server’s TLS key to the attested key — if they differ, verification fails
and no data is sent. This guarantees that only verified enclaves can decrypt
traffic; intermediaries can forward TCP but cannot terminate or read plaintext.

### Encrypted HTTP Body Protocol (EHBP)

In environments where TLS certificate pinning is not available (such as
browsers), or where the connection needs to pass through an intermediate
server for billing, authentication, or rate limiting, Tinfoil uses
[EHBP](/resources/ehbp) to encrypt HTTP request and response bodies
end-to-end. The SDK fetches the enclave’s attested HPKE public key and
encrypts all message bodies directly to that verified key using
[HPKE (RFC 9180)](https://datatracker.ietf.org/doc/html/rfc9180). HTTP
headers remain in the clear for routing, but the payload is only
decryptable by the attested enclave. This provides the same data confidentiality
guarantee as TLS key binding for request and response bodies, for clients that cannot pin certificates.

A common pattern is to run a proxy server on your backend that adds your
API key and handles user authentication, while EHBP ensures the proxy
never sees the plaintext request or response bodies. See the
[proxy server guide](/guides/proxy-server) for a complete walkthrough
with code examples.

## Chaining Enclaves

In some deployments, multiple enclaves work together to serve a single
request. Each enclave in the chain verifies the next one before forwarding
data, extending the same attestation guarantees across the entire pipeline.

For example, in our inference API backend, verification is chained across
two enclaves. The client SDK verifies the
[confidential model router](https://github.com/tinfoilsh/confidential-model-router),
which runs in its own enclave. The router then verifies the target model
enclave before forwarding the request. Data is encrypted end-to-end at
each hop using attested keys, so neither the host nor the router can read
plaintext outside of a verified enclave.
