Skip to content

fix(deploy): give apt only the pinned Docker and Caddy keys on servers - #312

Merged
samuelmbabhazi merged 2 commits into
mainfrom
fix/node-installer-signing-keys
Nov 16, 2026
Merged

samuelmbabhazi merged 2 commits into
mainfrom
fix/node-installer-signing-keys

Conversation

@samuelmbabhazi

@samuelmbabhazi samuelmbabhazi commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

What changed

  • deploy/install.sh (the server installer): the Docker and Caddy key files are imported into a temporary keyring that must hold exactly the pinned key, and apt is given gpg's export of that key (shipkeep-docker.gpg, shipkeep-caddy.gpg) instead of the downloaded file. Reading the keys no longer creates /root/.gnupg.
  • deploy/install_test.sh: checks of that function with generated keys.
  • docs/SPEC.md, docs/THREAT_MODEL.md: one sentence each.

Why

The installer compared the first fingerprint of each downloaded key file with the pinned one, then installed the whole file. A download holding the expected key followed by another key passed the check, and Signed-By then made apt trust both. CodeRabbit found this in the control plane installer (#310), where it was fixed; the server installer had the same code for two keys. It needs whoever serves the key file to be malicious, so it is hard to exploit, and it defeats the point of pinning.

How it was tested

In CI (deploy/install_test.sh): the expected key alone is accepted and the keyring written is gpg's binary export with one primary key; a second key after, before or inside the same armored block, a wrong fingerprint, a file that is not a key and a missing file are refused, and no keyring is written. Three mutations of the function are each caught. The two real key files, downloaded on 16 November 2026, pass with their pinned fingerprints.

By hand, on 16 November 2026: a control plane installed from the published v0.1.0-alpha.2 in a test container, then this installer run on a fresh Ubuntu 24.04 container with systemd and without Docker, with the arguments the Servers page passes (gateway, CA fingerprint, origin, agent checksums from that control plane's manifest) and the join token on standard input:

  • Exit 0. /etc/apt/keyrings holds two binary keyrings with one primary key each, the pinned ones; apt-get update succeeds; Docker 29.9 and Caddy 2.11 are installed from those repositories; no /root/.gnupg; the token does not appear in the output.
  • The agent enrolls and the server shows as ready; a deployment of docker.io/traefik/whoami:v1.10.3 succeeds and answers through the server's Caddy.
  • Run again, it refuses the existing installation.

Not tested: the command copied from the Servers page with this installer, since that needs an image built from this branch (the command wrapper is unchanged and only verifies the installer's checksum before running it); arm64; a real server.

Security considerations

This narrows what apt trusts and changes nothing else in the installer's behaviour. Servers installed with earlier versions keep their .asc key files: they hold the same single keys today, so nothing has to be done on them. The fix reaches users with the next release image, which serves the installer.

Summary by CodeRabbit

  • Bug Fixes

    • Docker and Caddy installation now verifies that downloaded signing-key files contain only the expected key before configuring package repositories.
    • Installations reject invalid, unexpected, or multiple signing keys instead of creating a keyring from them.
    • Preflight checks now detect existing GPG keyrings for Docker and Caddy.
  • Documentation

    • Updated installation guidance to describe Caddy’s persistent autosave storage, resume behavior, and restricted admin socket.
    • Clarified signing-key verification requirements for Docker and Caddy.

The server installer checked the first fingerprint of each downloaded key
file, then installed the whole file. A download holding the expected key
followed by another one passed, and apt then trusted both. The file is now
imported into a temporary keyring that must hold exactly the pinned key, and
only gpg's export of that key is installed, as the control plane installer
does since #310. Reading the keys no longer creates /root/.gnupg.

Signed-off-by: samuel mbabhazi <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The installer now accepts Docker and Caddy signing-key files only when each contains exactly the pinned key. It installs a GPG export of that key and configures APT to use the export. Tests cover valid and rejected key inputs. Documentation updates describe the key requirements and Caddy runtime settings.

Changes: APT signing-key installation

Layer / File(s) Summary
Validate and export pinned keys
deploy/install.sh, deploy/install_test.sh
single_signing_key imports a key into a temporary GPG home and exports it only when the file contains exactly the expected key. Tests check the expected key, mismatched keys, multiple keys, invalid input, and a missing file.
Install and reference validated keyrings
deploy/install.sh, docs/THREAT_MODEL.md, docs/SPEC.md
Docker and Caddy setup installs the exported .gpg keyrings and references them in APT sources. Preflight checks reject existing .gpg keyrings. The documentation describes the key-file requirements and Caddy runtime settings.

Estimated code review effort: 2 (Simple) | ~15 minutes

Change: Bug fix

Possibly related issues

  • Issue 239 concerns the verified installer’s Caddy installation path. This PR changes the Caddy signing-key validation, but does not test a real server or the Servers-page command.

Possibly related PRs

  • shipkeepdev/shipkeep#171: It introduced the installer’s Docker and Caddy repository setup. This PR changes the signing-key handling in that path.
Merge Risk: Minimal · up to 405f8

The installer now gives apt only the pinned Docker and Caddy signing keys and refuses key files with extra keys. No merge-blocking risk was found.

Security architecture risk: Minimal · up to 405f8

The change narrows repository trust to the pinned signing keys without expanding privileges or deployment scope. No introduced or worsened material security or recovery risk was identified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The relevant authority is host-level package installation on nodes running this installer. Control of a key-download response previously could add a repository trust anchor; exploiting that trust would additionally require supplying repository metadata and packages accepted under the added key. The head narrows this boundary without adding a new distribution or execution path.

Trust Boundaries and Controls

  • inferred — The material trailing-data proof gap does not establish a signing-key bypass. If GPG rejects such input, installation stops; if it accepts the valid key while ignoring trailing non-key bytes, APT still receives only the pinned key's export. A distinct additional primary key is rejected by the count check.

Resilience and Maintainability Implications

  • inferred — Interruption can leave the newly introduced temporary GPG home because its removal is not registered with the EXIT trap. That home contains imported public-key staging material and is not referenced by APT. This does not establish increased signing authority; concurrent installation and partial persistent writes remain limitations of the pre-existing nontransactional flow.
Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: the installer on servers now gives apt only the pinned Docker and Caddy signing keys. The raw summary and objectives confirm that install.sh imports each downloaded ke…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: the installer on servers now gives apt only the pinned Docker and Caddy signing keys. The raw summary and objectives confirm that install.sh imports each downloaded key into a temporary keyring, requires exactly the pinned key, and passes apt a binary export of that key instead of the downloaded file. The title is specific and matches the changeset. It also fits the commit history, which describes the first-fingerprint gap and the export fix.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 1e68d9c and 405f814.

Files selected for processing: 4

  • deploy/install.sh
  • deploy/install_test.sh
  • docs/SPEC.md
  • docs/THREAT_MODEL.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@samuelmbabhazi
samuelmbabhazi merged commit 077e8ed into main Nov 16, 2026
16 checks passed
@samuelmbabhazi
samuelmbabhazi deleted the fix/node-installer-signing-keys branch November 16, 2026 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant