Who vouches for the machine?
Attestation in SPIRE means proving what something is before it gets an identity. It happens twice: once for the machine, once for each program on it.
If an attacker could start a fake agent, every identity it handed out would be fake too. So the agent must prove its own machine before the server trusts anything it says.
By the end of this lesson
Note
I can work out which registration entries match a workload from its selectors.
Key words
| Word | What it means | Example |
|---|---|---|
| Node attestation | the agent proving its machine to the server | |
| Workload attestation | the agent finding out what a calling process is | |
| Selector | one fact about a node or workload | unix:user:basket |
| x509pop | node attestation by holding a key a known CA certified | |
| Join token | a one-use code that lets one agent attest | |
| Parent ID | the agent an entry belongs to |
The cells students fill in are left blank in this preview.
Node attestation: the agent proves its machine
Each SPIRE agent first proves the machine it runs on. In a cloud this can be the provider's signed instance document. In Kubernetes it can be a projected service account token.
This lab uses x509pop: at setup a small CA signed a certificate for the node. The agent proves it holds that certificate's key, and the server trusts the CA. The agent's ID is then built from the certificate's common name.
Read the node's certificate
openssl x509 -in /etc/spire/node.pem -noout -subject -issuerShown here, not run. Press Start lab to type it into your own lab’s terminal.
See the agent as the server does
sudo spire-server agent show -spiffeID spiffe://lab.test/spire/agent/x509pop/spire-labShown here, not run. Press Start lab to type it into your own lab’s terminal.
What the server knows about the node
The certificate prints subject=CN=spire-lab and issuer=CN=lab node CA. The agent ID ends in /x509pop/spire-lab because of that common name.
The agent's record ends with three node selectors. x509pop:subject:cn:spire-lab is the same everywhere. The CA fingerprint and the serial number differ in every copy, because each lab made its own keys.
A join token works once
Where a machine has nothing to prove itself with, an operator can make a join token. One agent may use it once to attest, and then it is spent.
The next Run makes one for a spare node. It prints Token: and a random value, different every time. Nothing uses it here, so it simply expires. Unlike x509pop, a token cannot attest the same node again after a restart.
Make a one-use join token
sudo spire-server token generate -spiffeID spiffe://lab.test/node/spareShown here, not run. Press Start lab to type it into your own lab’s terminal.
Workload attestation: the agent asks the kernel
A workload calls the agent over a Unix socket. The kernel tells the agent the caller's process ID, so the caller cannot lie about it. Plugins then turn that process into selectors.
The unix plugin gives the user, uid, group, gid and the program's path. The k8s plugin asks the kubelet which pod the process is in. An entry matches when every one of its selectors is among the workload's.
Worked example: does the entry match?
| Entry selectors | Workload has | Match? |
|---|---|---|
| unix:user:basket | unix:user:basket, unix:uid:1006, ... | Yes |
| unix:user:basket, unix:uid:0 | unix:user:basket, unix:uid:1006, ... | No: uid 0 is missing |
| unix:path:/usr/bin/python3.14 | any user running that program | Yes, for all of them |
| k8s:ns:demo, k8s:sa:printer | a pod in demo under printer | Yes |
The cells students fill in are left blank in this preview.
Read basket's entry again
sudo spire-server entry show -spiffeID spiffe://lab.test/basketShown here, not run. Press Start lab to type it into your own lab’s terminal.
A common mistake
Warning
Many people think more selectors make an entry match more workloads. It is the opposite: a workload must have every selector, so each one you add narrows the entry. One broad selector, such as a program's path, can give an ID to every user.