The co-signer
The co-signer, devvm-cosign, is the second of the two builders that sign each devvm release and each published base. It runs on a Linux machine of the maintainer’s, and a systemd timer starts it every hour. CI builds each release and hands its files and its signature over as a workflow artifact, because CI’s token can only read the repo. Each run, the co-signer downloads what CI handed over, rebuilds it with its own copy of devvm, and signs the manifest only when its build matches CI’s byte for byte. Then it makes the GitHub release itself, uploads CI’s files and both signatures, and publishes the release once two of the three keys signed it, then updates the Homebrew tap. CI can’t make or publish a release, so only the co-signer, and the maintainer by hand, can, and the co-signer raises an alert for any release published since its state began that it didn’t make, whatever its tag. Its code is cmd/devvm-cosign and internal/cosign, and its systemd units and install script are in packaging/cosign.
Releases go through CI and the co-signer once GitHub is set up for them, as Setting up GitHub for releases lists, and until then scripts/publish.sh --local publishes them from the maintainer’s machine, as Releasing describes.
What CI hands over
CI’s release workflow, .github/workflows/release.yml by default (release_workflow in the config), runs for each pushed release tag, and uploads one artifact named release. The artifact holds SHA256SUMS, CI’s signature of it, SHA256SUMS.ci.minisig, and every file SHA256SUMS lists, and nothing else, side by side, with no folders. The base workflow, .github/workflows/base.yml by default, uploads one artifact named base in the same way, with base-index.json, base-index.json.ci.minisig and the files the index lists.
The co-signer reads the workflow’s successful runs of this repo’s own, never a fork’s, through the Actions API. For a release, it takes each tag’s newest run that the tag’s push started, and for a base, the newest run on main. What a run hands over isn’t trusted for being CI’s: CI’s key has to have signed the manifest, and the co-signer’s own build has to match it.
What a run does
For each release CI handed over that the co-signer hasn’t published, oldest version first, though a run builds only one release or base, and the next waits for the next run:
- Its version is newer than every release the co-signer has signed, or it’s one it signed already, with the same
SHA256SUMS, because the run that signed it stopped before publishing. An older version, or a secondSHA256SUMSfor a version it signed, is refused, because that’s an old or another release replayed, and an older version is an alert until you ack it. - CI’s artifact checks out. The co-signer downloads the artifact into
/var/lib/devvm-cosign/stage/, which no build can write, checked against GitHub’s digest of it, and unzips it there, taking only plain files with names a manifest can list, each written new and hashed as it’s written, within the artifact’s limits. It checksSHA256SUMS.ci.minisigwith CI’s release key and the trusted commentdevvm-release <version>, exactly, throughinternal/minisign’sKeys.CheckRole. The artifact has to hold exactly the filesSHA256SUMSlists, each with its SHA-256, and nothing else. Before the build, the co-signer deletes those files from the stage and keeps onlySHA256SUMSand CI’s signature, so none of CI’s files is on disk while its own build runs, and nothing can have the build copy CI’s bytes in place of its own unless it has them from CI itself. - Its tag checks out. The co-signer clones its own devvm checkout, which is at the commit its config pins, into
/var/lib/devvm-cosign/src/, where no build’s container can reach it, fetches the tag andmainfrom GitHub, and checks the tag’s SSH signature against the tag signers its config pins, never a list read from GitHub or from the tag’s commit. The tag’s commit has to be onmain, and it has to be the commit CI’s run built, and the co-signer records the tag object’s ID. Before anything of the tag’s runs, the co-signer reads two files from the tag’s commit: the Homebrew formulas’ template,packaging/homebrew/devvm.rb, andCHANGELOG.md. - Its own build matches. The co-signer runs its clone’s
scripts/release.sh --tag <tag>, with its temporary files in/var/lib/devvm-cosign-build/work/, the one folder its containers write, and its finished files copied to a folder ofsrc/, where the co-signer reads them, which checks the tag again with git and the same signers, and builds the release in its pinned container. No code of the tag’s runs outside that container, though the tag does choose the container’s image and its Go and GoReleaser downloads, each pinned by its hash, so a tag that a pinned signer signed is what the co-signer trusts (Reproducible releases). git andrelease.shrun with an environment of their own, the machine’sPATH,HOME, locale and container runtime’s variables alone, and no git config but the command line’s, so a repository’s own config runs no hook or fsmonitor, and git reaches files and HTTPS alone. - On a match, it signs. Every file that
SHA256SUMSlists has to have the same SHA-256 in both builds, and the twoSHA256SUMShave to be the same bytes. The co-signer renders the tap’s formulas itself, from the tag’s template and the signedSHA256SUMS, asrelease.sh’sformulafunction does, and its build’s formulas have to be the same bytes, so neither builder’s container decides what Homebrew installs. It keeps the formulas and the release notes, the tag’sCHANGELOG.mdentry for the version, inkept/<version>/, and records their SHA-256s and the version as signed in its state. Then it signsSHA256SUMSwith its own key and the trusted commentdevvm-release <version>. - On a mismatch, it signs nothing. It writes a report to
/var/lib/devvm-cosign/reports/<tag>-<time>.txt, with each file that differs and both builds’ SHA-256s, files nothing publicly, and records theSHA256SUMSas refused, so it isn’t built or downloaded again. Every run fails until you clear it, as Refusals and alerts says. A build that fails rather than differs, such as one cut short by a full disk or a download that failed, is built again at the next run, but the third failure in a row refuses it in the same way, with a report that holds the last failure. A build that keeps failing would otherwise take every run’s one build, and hold up each newer release and base behind it. A build stopped with its run, at its time limit or bysystemctl stop, isn’t counted. - It makes the release. The co-signer downloads CI’s artifact again, checked as before, with the same
SHA256SUMS. It makes a draft release of the tag, titleddevvm <version>, with the notes it kept, as a prerelease for a version such as0.3.0-rc.1. It uploadsSHA256SUMS, both signatures and CI’s files from the stage, hashing each file as it’s sent, so a file that changed on disk after its check is deleted again rather than published. An asset it didn’t upload, such as a half-finished upload’s, is deleted, and one with the bytes it should have, by size and GitHub’s digest, is kept, so a run that stops can run again. - It checks the draft, then publishes. The draft’s signatures have to pass
Keys.Check, so two of CI’s, its own and the recovery key’s. While releases bridge from the old release key, it waits until you uploadSHA256SUMS.minisigto the draft, withscripts/publish.sh --sign-legacy, and checks it with that key and the trusted commentdevvm <version>, because devvm 0.1 and 0.2 check only that key, so while the bridge lasts, that key alone still signs a release for them. Each run fails while it waits, so you hear that the draft is waiting for you. Then it reads the draft again: its tag, title and notes have to be the ones it wrote, and its assets exactly the ones it uploaded, by GitHub’s ID, size and digest, with nothing added. The tag has to name the same tag object its rebuild checked, so a tag deleted or pushed again while the draft waited isn’t published. Only then does it publish the release, as GitHub’s latest release unless it’s a prerelease or older than a release it published, which happens when the old key signs a newer release’s draft first. - It checks the release again. When the published release differs from what it checked, the co-signer raises an alert and stops there, without updating the tap. devvm and the install script refuse a file that doesn’t match
SHA256SUMS, and Homebrew one that doesn’t match its formula, but compare the files by hand. With immutable releases on, the fix is a newer release. - Then the tap. It commits the formulas it kept, each checked against the SHA-256 its state recorded, to the tap’s
Formula/devvm.rbandFormula/devvm-rc.rb, with GitHub’s contents API, asscripts/publish.shdoes:devvm.rbonly for a release, not a prerelease, and each only when the tap’s formula is for an older version. A tap formula for a version newer than any the co-signer signed isn’t one it wrote, so that’s an alert. A run that stopped after publishing finishes the tap on the next run, without building again.
Before any of that, the co-signer looks at each published release it hasn’t finished. Its own draft, published without it seeing the answer, such as when GitHub’s answer to the publish was lost, is checked as a published release: its SHA256SUMS has to be the one it signed, both signatures and every file have to check out, downloaded, and its title and notes have to be its own. Only then does the co-signer finish the tap, and otherwise it raises an alert. init records the highest release ID GitHub showed, and the drafts there were then, and GitHub’s IDs only go up, so any other release published since, whatever its tag or version, is an alert too. Each run also reads GitHub’s latest release, the one /releases/latest/download/ serves to the install script, wherever the list puts it. init records which release that was, and the latest has to stay that one or become one the co-signer published: an older release made the latest again, such as one with a known flaw, is an alert, by latest:<tag>#<ID>, and so is the one init saw, or one of the co-signer’s own, once it’s older than a release the co-signer published.
Each step that fails is logged, and the run goes on to the next release, then exits 1. A run that stops at any step can run again safely, and since an Ed25519 signature of the same bytes and comment is always the same, a signature made again is the one the first run would have made.
Refusals and alerts
A refused build and an alert each fail every run, exit 1, until you deal with them, so the journal and the notify command keep saying so:
journalctl -u 'devvm-cosign@*' # what each run did, and why it failed
sudo -u devvm-cosign devvm-cosign retry v0.3.0 # build CI's v0.3.0 again, though it didn't match before
sudo -u devvm-cosign devvm-cosign ack v0.3.0 # clear v0.3.0's alert, once you've dealt with it- A refusal is a rebuild that didn’t match CI’s, or one that failed three times in a row. Read its report, and find out why, such as a full disk or a download cut short on the co-signer, or a build that isn’t reproducible. A new CI build of the same tag gives the same
SHA256SUMS, because builds are reproducible, so it stays refused. Once the cause is fixed,devvm-cosign retry <tag>lets the next run rebuild it once more. The co-signer never retries a refusal on its own. Once a newer release is signed, a refused older one can’t be signed any more, because versions only go up, so a retry of it raises the older-version alert, and its fix is a newer release. - An alert is something wrong that the co-signer can’t fix: a release someone else published, one of its own whose published files differ from what it checked, an older version CI handed over, a tap formula it didn’t write, or an older release made GitHub’s latest. Find out what happened and fix it by hand, such as by deleting a release that isn’t CI’s and the co-signer’s build, then ack it with what the alert names: the tag for its own release or base,
<tag>#<ID>for a release someone else published, so another release of that tag is alerted on again,tap:<formula>@<version>for a tap formula, andlatest:<tag>#<ID>for the latest release. After an ack, the next run checks its own release again, and raises the alert again if it still differs, and it leaves the rest alone. - A draft the co-signer didn’t make, for a tag CI handed over, stops that release every run. A run that stopped between making a draft and recording it leaves one too. Delete it by hand, and the next run makes its own.
Both commands take the state’s lock and fail at once when a run holds it, so run one again then. Neither reads a key file.
The notify command, notify in the config, is how you hear of a run that failed: a program and its arguments. Every unit of the co-signer’s that fails, a run killed at its time limit or one whose config won’t load included, starts devvm-cosign-failed.service (OnFailure=), which runs devvm-cosign failed. That runs the notify command with a line saying a run failed and the last run’s record, which says when it started and what failed, or that it never finished, on its standard input, at most 64 KiB, with an environment of its own, PATH, LANG and DEVVM_COSIGN_EVENT=failed alone, in /, for a minute at most, so it gets none of the co-signer’s credentials. Use a script that posts over HTTPS, such as curl to ntfy: a local mail server’s sendmail doesn’t work under the units’ NoNewPrivileges. A co-signer that’s down sends nothing, so a release tag that’s still not published a day on is the sign to look at it.
Bases
A base is a release of its own, base-<serial>, whose manifest is base-index.json and whose trusted comment is devvm-base <format> <serial> <expiry>, with each of those the same as the index’s fields. The co-signer checks a base CI handed over as it checks a release, with the base keys, and with these differences:
- Only CI’s newest base counts, as each base replaces the last. A run that the co-signer has published is never downloaded again.
- The serial only goes up, and the index has to be in date. Its expiry is the last day devvm takes it, in UTC, and it may be at most 31 days ahead.
- The snapshot can’t be old. An index whose Ubuntu snapshot is more than 60 days old (
max_snapshot_daysin[base]) is refused, whether or not it needs a rebuild. The expiry alone can’t keep users off an old base, because the co-signer re-signs an unchanged base with a new serial and expiry, so whoever holds CI’s base key could otherwise keep users on one snapshot, missing every update since, for as long as they sign. Ubuntu’s archive changes every day, so a base that’s two months old has missed security updates. - An unchanged base is signed without a rebuild. The co-signer records the SHA-256 of every base file that a rebuild of its own matched, and the last index it signed. A base that’s that index again, with a new serial and expiry, and whose files are all ones it has checked, is re-signed at once, which keeps the published base inside its 30 days while nothing changes. Any other index is rebuilt, so an older base’s files can’t come back with a new serial.
- Its release is made at the index’s commit, titled
devvm's base <serial>, with notes the co-signer writes from the index, and it’s never GitHub’s latest release, which stays devvm’s newest release. - No rebuild yet. Bases are built from the signing design’s fifth phase on, and until then a base with a file the co-signer hasn’t checked isn’t signed, and its log says why.
BaseBuilderis the seam for that build.
Without base keys in the config, the co-signer leaves bases alone.
Its files
| File | What |
|---|---|
/usr/local/bin/devvm-cosign | the program, built from a release tag the maintainer checked |
/etc/devvm-cosign/config.toml | everything it trusts and signs with, root’s, readable by its group, devvm-cosign |
/etc/devvm-cosign/*.key, app.pem | its minisign secret keys and the GitHub App’s private key, root’s, mode 0600, which reach the service as systemd’s credentials |
/var/lib/devvm-cosign/state.json | what it signed, made, published, refused and alerted on |
/var/lib/devvm-cosign/kept/<version>/ | each signed release’s formulas and notes, which it renders and checks before publishing |
/var/lib/devvm-cosign/reports/ | the reports of rebuilds that didn’t match |
/var/lib/devvm-cosign/stage/, src/ | CI’s artifacts, unzipped, and each build’s clone of the checkout, which release.sh runs from, and its finished files, both emptied at the start of each run |
/var/lib/devvm-cosign/cache/ | release.sh’s downloads, which only it, on the host, reads |
/var/lib/devvm-cosign/last-failure.txt | the last run’s record for the notify command: when it started, and what failed or that it never finished; removed when a run succeeds |
/var/lib/devvm-cosign-build/ | the build folder, the one the builds’ containers write: release.sh’s temporary files in work/, and rootless podman’s config, images and containers, all deleted each time the podman service starts |
The config:
repo = "devvmhq/devvm"
tap = "devvmhq/homebrew-tap"
# The SSH public keys whose signed tags it builds, as their .pub files have them.
tag_signers = ["ssh-ed25519 AAAA… cj@mini"]
# podman or docker, for release.sh; podman by default.
runtime = "podman"
# Run after each run that failed, with what failed on its stdin; none by default.
notify = ["/usr/local/bin/devvm-cosign-notify"]
# devvm's checkout that the release.sh it builds with is from: a release tag you checked.
[devvm]
checkout = "/opt/devvm-cosign/devvm"
commit = "<the tag's commit, all 40 characters>"
[release]
secret_key = "/etc/devvm-cosign/release.key"
keys = { ci = "RW…", cosign = "RW…", recovery = "RW…" }
# While releases bridge from the old release key: packaging/minisign.pub's key.
legacy_key = "RW…"
# Optional, until bases are published.
[base]
secret_key = "/etc/devvm-cosign/base.key"
keys = { ci = "RW…", cosign = "RW…", recovery = "RW…" }
[app]
id = "<the app's client ID or app ID>"
installation = 12345678
private_key = "/etc/devvm-cosign/app.pem"- The keys are each kind’s three public keys, the same as
packaging/keys’<kind>-<role>.pub, and the secret key’s public half has to be thecosignkey, or the config is refused. A config with a key it doesn’t know is refused too. - The key files are read from systemd’s credentials folder,
$CREDENTIALS_DIRECTORY, when the service runs, by the name each path in the config ends with, so those names have to be the units’ credential names:release.key,app.pemandbase.key. Run by hand, outside the units, they’re read from where the config says. Each has to be a regular file that only its owner can read, mode 0600 or 0400, or the config is refused, but for a credential, which systemd makes root’s, mode 0440, with an ACL for the service’s user, in a folder only that service sees, and which only has to be unreadable by others. git_url,api_urlanduploads_urldefault tohttps://github.com/<repo>.git,https://api.github.comandhttps://uploads.github.com, and each has to be HTTPS.state_dirdefaults to/var/lib/devvm-cosignandbuild_dirto/var/lib/devvm-cosign-build, and neither may be in the other, so the podman service’s unit can hide the state folder whole. The units name both folders, so change them only with the units changed to match.release_workflowand[base]’sworkfloware the workflow files’ names,release.ymlandbase.ymlby default, and[base]’smax_snapshot_daysis from 1 to 365, 60 by default.- The tap has to be under the same owner as the repo, as the app’s one installation covers both.
state.json records, for releases and for bases, the newest version or serial it signed, the SHA-256 of each manifest it signed and of each it refused with how often it was retried, how many of a manifest’s builds in a row failed, the draft releases it made, what it published, each alert and how often it was acked, the CI runs it signed, the SHA-256 of each file it kept, each release’s tag object, and each base file a rebuild matched, and the highest release ID GitHub showed and its latest release when init wrote it. It’s written whole, through a temp file that’s synced and renamed, and the folder is synced after, and a write that would record less than the file on disk, such as an older version or a dropped draft, is refused. At the start of each run the co-signer also compares it with GitHub: when a release or base, a draft or published, has a signature that checks out with the co-signer’s key and is newer than the state’s newest, which a state it wrote never is, the state was restored from an old backup or replaced, and the run stops before signing anything, so restore the newest backup. Only one run runs at a time, through a lock in the state folder.
GitHub lists releases and runs newest first, so the co-signer reads them a page at a time until a page holds only ones it’s finished with: published, and either from before its state began, its own and finished, or someone else’s that it has alerted on. Years of releases and bases never make it read more. Ten pages it hasn’t finished with are an error, never a list cut short.
Setting it up
The co-signer runs on any Linux machine with systemd, about 4 cores and 20 GB free, podman (or Docker), git, bash, curl and ssh-keygen. Nothing reaches it from outside: it calls GitHub’s API, fetches from GitHub, and its builds download Go, GoReleaser and Go’s modules.
Install what it runs, such as
sudo dnf install podman git curl openssh-clientson Fedora orsudo apt install podman git curl openssh-clienton Debian or Ubuntu, and mise, for the Go the tag pins.Register qemu-user with binfmt, once, on an x86_64 machine, so it can rebuild arm64’s base:
sudo dnf install qemu-user-staticon Fedora, orsudo apt install qemu-user-static binfmt-supporton Debian or Ubuntu, then check that/proc/sys/fs/binfmt_misc/qemu-aarch64exists. Releases don’t need it, because Go cross-compiles them, and an arm64 machine doesn’t need it at all.Check out devvm at a release tag and build the co-signer from it, with the Go that the tag’s
mise.lockpins:git clone https://github.com/devvmhq/devvm.git ~/devvm-cosign && cd ~/devvm-cosign git tag -v v<version> # signed by your key: compare its fingerprint git checkout v<version> mise trust && mise install go # the Go the tag's mise.lock pins CGO_ENABLED=0 mise exec -- go build -trimpath -o /tmp/devvm-cosign ./cmd/devvm-cosign # outside the checkout, which must stay clean sudo packaging/cosign/install.sh /tmp/devvm-cosign sudo mkdir -p /opt/devvm-cosign && sudo mv ~/devvm-cosign /opt/devvm-cosign/devvm sudo chown -R root:root /opt/devvm-cosign/devvm # the checkout config.toml names, root'sinstall.shinstalls the program and the systemd units, makes the userdevvm-cosignwith 65536 subordinate IDs for rootless podman, above every other user’s range so no two users’ containers share an ID, and makes/etc/devvm-cosign,/var/lib/devvm-cosignand/var/lib/devvm-cosign-buildwith the folders the units need. It installs no package and starts nothing, and it warns when there’s noqemu-aarch64handler.Write the config and copy the keys into
/etc/devvm-cosign: the config root’s, readable by the co-signer’s group, and each key file root’s alone,sudo chown root:devvm-cosign /etc/devvm-cosign/config.toml && sudo chmod 640 /etc/devvm-cosign/config.toml && sudo chown root:root /etc/devvm-cosign/*.key /etc/devvm-cosign/app.pem && sudo chmod 600 /etc/devvm-cosign/*.key /etc/devvm-cosign/app.pem. With a base key, runinstall.shagain, which then installs the drop-in that loads it.Check it, write its first state and start the timer:
sudo systemctl start devvm-cosign@check # the config, the keys and the checkout, offline sudo systemctl start devvm-cosign@init # state.json, from the newest release and base published journalctl -u devvm-cosign@check -u devvm-cosign@init sudo systemctl enable --now devvm-cosign.timer
init writes the first state.json from what GitHub has published, so the co-signer signs only newer releases and bases and alerts on any release published after it, and it refuses to replace a state there is.
The units:
devvm-cosign@.servicerunsdevvm-cosign <instance>asdevvm-cosign, once per start:devvm-cosign@runfor the timer, and@checkand@initfor setting up. It loads the release key and the app’s key as systemd’s credentials (LoadCredential=), and the base key through the drop-indevvm-cosign-base.conf, because a credential that isn’t there fails the service. It runs withNoNewPrivileges,ProtectSystem=strict,/var/lib/devvm-cosignand/var/lib/devvm-cosign-buildits only writable folders,ProtectHome, a private/tmp, a PID namespace of its own, no capabilities, and a 3-hour limit, and when it fails it startsdevvm-cosign-failed.service.devvm-cosign.timerstartsdevvm-cosign@runhourly, and at boot for a run the machine was off for.devvm-cosign-podman.serviceis the rootless podman service, as the same user, that the builds’ containers run in, throughCONTAINER_HOST. podman can’t map a user namespace for its containers underNoNewPrivileges, becausenewuidmapgets its privilege from a file capability, so the containers run in this service, which has noNoNewPrivilegesand whose cgroup is delegated to the user, sorelease.sh’s process and memory limits apply. ItsHOMEis the build folder, where podman keeps its config and storage. Each time it starts, it deletes the user’slibpod*files in/dev/shm, podman’s locks, which outlive the service, then everything in the build folder, its images and containers withpodman system reset, so each run pulls its build’s image again, and a start that fails startsdevvm-cosign-failed.service. A start fails when a build left files the co-signer’s user can’t delete, and until root deletes them,sudo rm -rf /var/lib/devvm-cosign-build/*, no run starts. It runs only while a run needs it (StopWhenUnneeded=).devvm-cosign-failed.servicerunsdevvm-cosign failed, which runs the notify command, and reads no key.
What a build’s container can reach
The builds’ containers run as the same user as the co-signer, because rootless podman maps a container’s root to it, and they have no capabilities and no network, but for the one that downloads Go’s modules, and run only code from a tag a pinned signer signed. A process that escapes a container lands in the podman service, and the units keep these from it:
- The keys and the config. The keys are root’s, and the co-signer gets them only as credentials, in a folder of its own service’s while it runs. The podman service sees neither
/etc/devvm-cosignnor any service’s credentials (InaccessiblePaths=). - The co-signer’s processes. The podman service and the run’s service each have a PID namespace of their own (
PrivatePIDs=), so an escaped process can’t see the co-signer,release.shor git, nor reach their files through/proc/<pid>/root.devvm-cosignalso makes itself non-dumpable when it starts, so no other process of its user can read its memory, where the keys and the GitHub token are, or trace it, though the programs it starts are dumpable. - The state and what the co-signer runs. The podman service can’t see
/var/lib/devvm-cosignat all: the state, the kept formulas, CI’s staged files, the download cache, the clone whoserelease.shand git config the co-signer runs, and the folderrelease.shcopies the finished build to, which the co-signer reads. It writes only the build folder. The co-signer runs nothing from there, and the one thingrelease.shreads from it once a container has run is the build’s output, which it copies to that private folder: a link there can only change what the co-signer compares, and none of CI’s files is on disk then, so a build it changed differs from CI’s and is refused. That holds unless CI is compromised too: whoever controls CI knows its files’ bytes, so an escape that downloads them into the build counts as the co-signer’s compromise, and both builders are then compromised, which two of three keys can’t stop. - Later builds. Each run builds once, and the podman service runs only while the run does, so a process that escaped a build is gone before the next build’s
release.shand git run. Each start of the service deletes the user’s podman files in/dev/shmand the whole build folder, podman’s config and images with it, so nothing a build left behind, such as a lock, a link or a config pointing podman at another runtime, reaches the next.
What’s still shared is the user and the machine. An escaped process can slow the build it’s in, or change it, which then doesn’t match CI’s, and use the machine’s network while that run lasts. An escape through the kernel, rather than podman or crun, gets past all of it, so keep the machine for the co-signer alone. Running podman as a build user of its own would take away the shared user, though that isn’t set up yet.
With Docker instead, set runtime = "docker", drop CONTAINER_HOST and the podman unit from the service, and add devvm-cosign to the docker group. Membership of that group is as good as root on the machine, so podman is the better choice.
Making its keys
The co-signer’s keys are minisign keys with no password, because nobody is there to type one, so the machine’s disk is what protects them:
sudo minisign -G -W -p release-cosign.pub -s /etc/devvm-cosign/release.key
sudo minisign -G -W -p base-cosign.pub -s /etc/devvm-cosign/base.keyCommit each public key to packaging/keys/<kind>-cosign.pub, and copy the release key into install.sh’s release_cosign_key line (Release keys). Keep an encrypted copy of each secret key offline, such as on a USB drive kept apart, and never on a machine you develop on, because that machine and CI would then hold two of the three keys.
The GitHub App
The co-signer calls GitHub with a GitHub App’s installation token, never a personal token. Each run signs a JSON Web Token with the app’s private key (RS256, issued a minute in the past and valid for nine minutes), trades it for an installation token, which lasts an hour, and asks for that token to reach only devvm and the tap, with Contents read and write and Actions read, and nothing else. The app’s actor isn’t the maintainer, so it has none of the maintainer’s bypasses of rulesets.
Setting up GitHub for releases has the clicks and the commands that check them.
- Create the app under the account that owns devvm, with no webhook, and the repository permissions Contents: read and write, Actions: read, and Metadata: read, which GitHub adds.
- Install it on
devvmandhomebrew-tapalone, and note the installation’s ID, the number at the end of its settings page’s URL. - Generate a private key, and copy the
.pemfile to/etc/devvm-cosign/app.pem. - Let the app through the tap’s ruleset, as a bypass for its
main, or the co-signer can’t update the formulas, and every run fails.
Every GitHub call goes through Client in internal/cosign/github.go and actions.go: listing releases, reading one, making a draft, uploading, deleting and downloading an asset, publishing, reading and writing the tap’s files, and listing a workflow’s runs and a run’s artifacts and downloading one. A download redirects to GitHub’s storage, and the token is never sent to a host other than the one it called.
Moving it to another machine
Set up the new machine as above, with the same config and keys, then stop the old one’s timer (sudo systemctl disable --now devvm-cosign.timer) and copy its /var/lib/devvm-cosign whole, but for stage/, src/ and cache/, which the new machine makes again, as it does the build folder, /var/lib/devvm-cosign-build, which isn’t copied. state.json alone isn’t enough, because a release signed on the old machine and not yet in the tap needs its kept/ files. Two machines with the same keys must never run at once, because each would publish.
A lost machine, or a co-signer key you no longer trust, needs new keys instead: make them on the new machine, then publish a release that embeds the new public key, signed by CI and the recovery key, which are two of three without the old key. From that release on, devvm checks the new key.
Its tests
internal/cosign’s tests run the co-signer against a fake GitHub in memory (fakegithub_test.go), which checks each call’s token and the app’s JWT, serves workflow runs and their artifacts, makes drafts, serves downloads from a storage server of its own, and can fail a call, leave a half-finished upload, lose a publish’s answer, or swap an asset. The rebuild is a stub in most tests, and build_test.go runs ReleaseBuild with real git repositories and a stub release.sh. The cases include a rebuild that doesn’t match and its retry, a build that keeps failing, an older release made the latest, a formula of the build’s own, a bad CI signature, an artifact with a file too many or too few, a zip with a link, a folder or a size that lies, a tag signed by an unpinned key, an older version replayed, a file swapped before or as it’s published, a release someone else published, a failure mid-upload and its retry, the release list past ten pages, a base on an old snapshot, and a state that would go backwards, and the parsers of outside input have fuzz tests.