systemd-creds: TPM and host binding solve different theft cases
Encrypted service credentials are often treated as a single category. On systemd systems, systemd-creds supports encryption keys derived from the local TPM2 device, a host file, or a combination. Those choices protect against different attackers. An operator who selects a mode without understanding the difference can create a credential that survives an image copy or one that fails after a legitimate upgrade.
The host key is stored on the host file system, commonly under /var/lib/systemd/. It protects a credential from casual inspection of the service unit or a backup that contains only the encrypted file. Anyone who obtains the encrypted credential and the host key can decrypt it. The TPM2 mode derives protection from the local device. The man page notes that a TPM-only credential cannot be decrypted on another machine without the original TPM chip.
The combined mode binds the credential to both the TPM and the host state. Current systemd documentation also describes additional TPM2 protections and PCR policies. Those details matter for recovery: a firmware or boot measurement change can intentionally make a credential unavailable until the policy is updated. That is a security property, but it is also an availability risk for unattended services.
An inventory should record who can read the encrypted file, which service consumes it, which TPM policy is used, and what happens during image cloning, host replacement, or disaster recovery. Do not assume a VM snapshot behaves like a physical machine. Test restoration with the same policy applied in the target environment. Keep a break-glass procedure that does not require weakening the normal encryption mode.
The decrypted credential still exists in the service at runtime. systemd can pass a credential to a unit, but the service process must treat it as a secret. A crash dump, debug log, or inherited file descriptor can expose it. Use NoNewPrivileges, a minimal runtime user, and a restricted environment where appropriate. Review child processes for accidental inheritance.
The TPM path also needs operational evidence. Confirm that the device is available and actually used, inspect the selected PCR policy, and document what firmware or kernel changes would invalidate it. If the service starts by silently falling back to a less protected method, the effective posture may differ from the design. Fail closed when the intended mode is unavailable.
Finally, separate rotation of the service credential from rotation of the encryption key. Re-encrypting a file does not change the upstream API token. Rotating the token does not repair a broken TPM policy. A short runbook can make both paths explicit and prevent an incident response from choosing the wrong one.
Top comments (0)