Your Trust Store Is an Authentication Database: Inside the LXD API

Site Admin · 4 Dec 2026 · Cloud & Virtualization

LXD uses mutual TLS with a self-signed client model, so the daemon authenticates clients in application code. The trust store is an authentication database: every entry is a login, and the difference between checking one certificate and checking a chain is the whole vulnerability.

LXD does not use passwords for remote API clients. It uses mutual TLS, and the trust store is the table of identities that TLS is allowed to represent. Every entry is a potential login, which is why the difference between checking one certificate and checking a chain is the whole vulnerability.

The listener

The LXD daemon listens for remote API clients on TCP 8443. The same port serves the main API, the metrics endpoint, the cluster database gateway, and inter-member traffic. Locally, lxc talks over a Unix socket, which is a different path with different permissions.

The server's TLS configuration is deliberate:

config.ClientAuth = tls.RequestClientCert

RequestClientCert asks the client for a certificate but does not validate the chain against a CA. LXD cannot use RequireAndVerifyClientCert in the ordinary way because its clients are self-signed: there is no public CA behind a lxc remote add. The daemon therefore accepts any certificate at the handshake and performs its own check afterwards.

That design is legitimate, but it moves the entire authentication decision into application code. The TLS handshake proves one thing only: the client holds the private key for the first certificate in the chain it sent. Everything after the first certificate is attacker-supplied data.

The trust store

Trusted certificates live in LXD's cluster database and are managed with:

lxc config trust list
lxc config trust add client.crt
lxc config trust remove <fingerprint>

Each row stores a SHA-256 fingerprint and the certificate itself. There are several certificate types: client certificates for API users, metrics certificates limited to the metrics endpoint, and server certificates for cluster members. A cluster join adds each member's server certificate to the others' trust stores.

The trust store is not a list of users in the usual sense. It has no password, no MFA, and no session. Possession of the private key that matches a row is the entire credential.

The authentication path

When a request arrives, Daemon.Authenticate runs before any handler. In the vulnerable code it did roughly this:

  1. Take r.TLS.PeerCertificates, the chain the client sent.
  2. Compute a fingerprint for every certificate in that list.
  3. Ask the trust store which of those fingerprints it recognises.
  4. If one matches, treat the caller as the owner of that certificate.
  5. Run CheckMutualTLS on the matched certificate and the stored copy.

Step 5 looks like a key check, but it is not. CheckMutualTLS compares the certificate's DER bytes with the stored certificate's DER bytes. When the matched certificate is the one the attacker appended, the comparison is the certificate against itself. It always succeeds. No private key is involved.

What the handshake actually proves

TLS 1.3 clients sign a transcript of the handshake with the private key of their leaf certificate. The server verifies that signature during CertificateVerify. That is the proof of possession.

Intermediate and root certificates are not used to sign the handshake. The client does not have their private keys, and it does not need them: the chain is there to establish a path to a trust anchor, not to authenticate each certificate individually. A server that treats every chain element as an identity has confused the path with the endpoint.

The cluster bus

LXD clusters make the problem worse because the trust store contains server certificates as well as client certificates. Server certificates are not secret. Every TLS handshake returns the server's certificate in the clear. An attacker who can reach any cluster member can obtain a certificate that another member trusts, append it to a chain, and be treated as that member.

The database gateway uses the same identity. So does the vsock connection between the host and a VM's agent. The flaw was not confined to the user-facing API; it ran through every place that asked "is this certificate trusted?" and answered by scanning the chain.

Why the design is hard to get right

LXD's model is not unusual. Many self-signed mTLS systems work this way: accept any certificate, then look up its fingerprint. The subtlety is that "the certificate" has to mean the leaf. Once the code iterates over PeerCertificates, it has left the identity model and entered a list of public objects.

The fix is correspondingly small: a helper that returns PeerCertificates[0], and every trust check rewritten to use it. That is what upstream shipped. Part 7 walks through the exact diff.

Next: Part 6 — six places the same loop ran: the smaller certificate failures around the main API, and the audit batch that followed.