Secret at instance start to gate the virtual TPM (so backups can't unseal)

Hi,

A VM backup includes the virtual TPM’s swtpm state, because it lives on the instance volume:

backup/virtual-machine/<instance>/tpm.<device>/tpm2-00.permall

That file holds the TPM’s SRK and NV state. So anyone with a backup can run swtpm on that state and unseal the systemd credentials the guest sealed (systemd-creds --with-key=tpm2). The TPM seal gives no protection against a backup holder.

What I want: the TPM should only work if a secret I keep in OpenBao is available when the instance starts. Without it, the TPM shouldn’t function.

swtpm can encrypt its state files (–keyfile/–pwdfile in swtpm_setup, --key file= / --migration-key file= in newer swtpm), so if incusd gave swtpm a key from OpenBao, the state on the instance volume would be encrypted at rest and a backup would carry an unusable TPM.

Two questions:

  1. Is there an existing way to hand a secret to incusd at instance start (exec hook, scriptlet, device option)? instances.placement.scriptlet and authorization.scriptlet don’t seem to fit.

  2. If not, what shape would work best: a tpm device option that runs a command, a server config key, or something else?

Thanks, Chuck

I don’t think that adding extra protection to the swtpm state here is the answer, rather, restricting who has the ability to access APIs like the instance backup API seems more important.

Anyone who has API access to the instance backup endpoint also has access to the instance memory dump function as well as the instance migration endpoint. The memory dump will almost certainly include the systemd credential and the instance migration endpoint not only provides access to the VM memory, CPU registers, … but also to the TPM state as is required during migration.

If using regular Incus exports as backups, you could have an encryption key in your vault which is used to encrypt the backups as they get streamed out of Incus so your backup is then safe to store.

Hi Stéphane, thank you for the quick response! I will take a look at both and report back. Chuck