> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tofunmiadewuyi.com/custos/llms.txt
> Use this file to discover all available pages before exploring further.

# Release signing

> The key that decides what custosd binaries hosts will run as root, and how to manage it.

Every daemon release ships a manifest listing the release's version, its
[security floor](https://docs.tofunmiadewuyi.com/custos/hosts/updates.md#security-floor), and the SHA-256 of each tarball and the `custosd`
binary inside it. CI signs the manifest with an Ed25519 key. Hosts only install a release whose
manifest verifies against a public key compiled into `custosd`, so this key, not the control plane
or the release host, decides what runs as root across the fleet.

```text theme={null}
releases/custosd/v1.2.3/custosd_v1.2.3_linux_amd64.tar.gz
releases/custosd/v1.2.3/custosd_v1.2.3_linux_arm64.tar.gz
releases/custosd/v1.2.3/custosd_v1.2.3_manifest.json
releases/custosd/v1.2.3/custosd_v1.2.3_manifest.sig
```

## One-time setup

1. **Generate the key** on a trusted machine:

   ```bash theme={null}
   go run ./cmd/release keygen
   ```

   It prints `CUSTOS_RELEASE_SIGNING_KEY=...` (private) and `public key: ...`.

2. **Store the private key** as a secret named `CUSTOS_RELEASE_SIGNING_KEY` in the `prod`
   GitHub Actions environment. Do not keep other copies; if it is lost, rotate (below).

3. **Trust the public key** by adding it to `internal/release/keys.go`:

   ```go theme={null}
   var TrustedKeys = []string{"<public key>"}
   ```

4. **Release** as usual. The workflow fails if the secret is missing or its key is not in
   `TrustedKeys`, so a release the fleet would reject is never published.

Hosts running a daemon from before signing take one unsigned update to reach the first signed
release; every update after that is verified.

## Security floor

`SECURITY_FLOOR` at the repo root holds the floor for the next release. Raise it, in the same
change as the fix, when a release fixes a vulnerability that downgrades must not reintroduce:

```bash theme={null}
echo v1.4.2 > SECURITY_FLOOR   # versions below v1.4.2 are refused once a host installs this release
```

Leave it alone for ordinary releases. A host's floor only ever rises, and downgrades above it keep
working. The floor must not exceed the version being released.

## Rotating the key

1. Generate a new key and add its public key to `TrustedKeys` alongside the old one.
2. Release with the **old** key still in the secret, and roll it out to the fleet.
3. Replace the secret with the new key.
4. Once every host runs a release that trusts the new key, remove the old public key and release.

## If the private key leaks

Anyone holding it can sign a release that hosts will install as root once the control plane pushes
it, or that a host's `custos` user stages.

1. Generate a new key and make its public key the **only** entry in `TrustedKeys`.
2. Raise `SECURITY_FLOOR` to the version of this emergency release.
3. Release it signed with the **old** key, which is the only one hosts trust yet: set the
   `prod` environment variable `CUSTOS_RELEASE_RETIRING_KEY=true` so CI accepts a signing key that
   is no longer in `TrustedKeys`. Upgrade the fleet. Once a host installs it, old-key signatures
   and every older release are refused.
4. Replace the secret with the new key and delete `CUSTOS_RELEASE_RETIRING_KEY`.
5. Audit hosts for binaries installed outside your releases: `custosd status`, and compare
   `/usr/local/bin/custosd` with the published digests.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.