Skip to content

trustee-attester failing on TPM access in TDX VM since 0.16.0 #1277

@berrange

Description

@berrange

Describe the bug

Since updating to 0.16.0, attempts to run trustee-attester in my TDX development VM fail with an error about incorrect TPM handle usage

  "the handle is not correct for the use (associated with handle number 1)"

Bisecting points to the changes in #1093 to introduce the TPM as a secondary attestation device.

This is a TDX virtual machine running under KVM with QEMU 10.1.2. The VM is configured with a virtual TPM backed by swtpm 0.10.1 on the host OS. Such a host backed vTPM should NOT be trusted to be confidential, and thus arguably is pointless to enable it in a VM. None the less trustee formerly worked and now it fails.

The first question is what is the root cause of trustee having incorrect TPM handle usage "Error when getting ESYS handle from TPM handle: the handle is not correct for the use (associated with handle number 1)" and how can that be fixed ?

Second, if collecting evidence from the primary TEE succeeds, a failure to collect evidence from a secondary device perhaps should not be a fatal error.

The trustee server configured attestation policy ought to be enforcing whether the absence of attestation info from the secondary device is considered fatal or not.

How to reproduce

Create a QEMU/KVM TDX enabled VM, with an swtpm backed virtual TPM present. I suspect the same may happen with a QEMU SEV-SNP VM too, if swtpm is present, but I have not personally tested that.

Attempt to attest it with trustee-attester version 0.16.0 or later

CoCo version information

guest-components 0.16.0

What TEE are you seeing the problem on

Tdx

Failing command and relevant log output

# ./trustee-attester  --url http://192.168.122.1:9000   get-resource --path fo/bar/wiz
[2026-01-23T13:28:46Z INFO  attester::tpm::utils] TPM device detected: /dev/tpm0
[2026-01-23T13:28:46Z INFO  attester::tpm::utils] AA_TPM_AK_HANDLE not set, using default handle: 0x81010002
[2026-01-23T13:28:46Z INFO  attester::tpm] [TPM Attester] Initialized using TPM device: /dev/tpm0 and AK handle: 2164326402
[2026-01-23T13:28:46Z INFO  attester::tpm::utils] TPM device detected: /dev/tpm0
[2026-01-23T13:28:46Z INFO  attester::tpm::utils] AA_TPM_AK_HANDLE not set, using default handle: 0x81010002
[2026-01-23T13:28:46Z INFO  attester::tpm] [TPM Attester] Initialized using TPM device: /dev/tpm0 and AK handle: 2164326402
[2026-01-23T13:28:46Z INFO  attester::tpm::utils] Creating TCTI configuration for device: /dev/tpm0
WARNING:esys:src/tss2-esys/api/Esys_ReadPublic.c:320:Esys_ReadPublic_Finish() Received TPM Error 
ERROR:esys:src/tss2-esys/esys_tr.c:278:Esys_TR_FromTPMPublic_Finish() Error ReadPublic ErrorCode (0x0000018b) 
ERROR:esys:src/tss2-esys/esys_tr.c:402:Esys_TR_FromTPMPublic() Error TR FromTPMPublic ErrorCode (0x0000018b) 
[2026-01-23T13:28:46Z ERROR tss_esapi::context::general_esys_tr] Error when getting ESYS handle from TPM handle: the handle is not correct for the use (associated with handle number 1)
[2026-01-23T13:28:46Z INFO  tss_esapi::context] Closing context.
[2026-01-23T13:28:46Z INFO  tss_esapi::context] Context closed.
[2026-01-23T13:28:46Z WARN  kbs_protocol::client::rcar_client] RCAR handshake failed: RcarHandshake("Error {\n    context: \"get composite evidence failed\",\n    source: GetEvidence(\n        \"the handle is not correct for the use (associated with handle number 1)\",\n    ),\n}"), retry 1...

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions