Files
coder/docs/admin/security
Kyle CarberryandClaude Opus 5.5 11f72a8ae9 ci: publish release images and charts through coder/ghcr-publisher (#32566)
GitHub grants package write access to a whole repository, not to a
workflow, branch or environment. Today `ghcr.io/coder/coder`,
`coder-base` and the OCI charts list coder/coder with Write, so any
workflow on any branch here can request `packages: write` and overwrite
a release tag with this repository's `GITHUB_TOKEN`. The `release`
environment and the tag rulesets don't stop that. GHCR accepts neither
App tokens nor OIDC, so the repository boundary is the only way to
separate who publishes.

With this change, releases push to `*-staging` packages and trigger
**coder/ghcr-publisher**, a locked repository that will be the only one
with Write on the public packages. Before copying a digest, it verifies
three things:
- this `release.yaml` attested it,
- on `release/X.Y` (or `main` for an RC), with the signer being
`release.yaml` at that same ref,
- built from the commit the `vX.Y.Z` tag points to.

It copies by digest and never moves an existing version tag. It moves
`latest` only to the highest stable version.

### Changes
- **release.yaml**
- Images, the base image and the OCI charts are pushed to
`coder-staging`, `coder-base-staging` and `chart-staging/*`.
- The charts get attestations for their OCI manifest digests. The
existing `.tgz` attestations don't cover those digests.
- The base and image attestations no longer `continue-on-error`, because
promotion depends on them.
  - The final image is built on the fresh base image **by digest**.
- A `repository_dispatch` is sent with a `coder-ghcr-dispatch` token
(`contents: write` on `ghcr-publisher` only).
- The job waits until every public tag serves the expected digest,
before the GitHub release is published.
- `latest` is no longer built here. The separate latest SBOM asset is
dropped; it described the same image.
- **docker-base.yaml**
- Only checks, on PRs that touch them, that `Dockerfile.base` builds for
every platform. It no longer publishes, and no longer needs `packages:
write`.
- Non-release and local builds keep using
`ghcr.io/coder/coder-base:latest`. coder/ghcr-publisher moves it to the
base of each new highest stable release (roughly weekly for 2.39),
instead of the Monday/Wednesday/Friday rebuild. So preview images and
the `coder-preview:main` scan see Alpine updates about weekly, and a
`Dockerfile.base` change reaches preview images at the next stable
release. Release images always build a fresh base.
- **verify-releases.md**
- Releases since 2026-11-16 (#32212) are built on `release/X.Y`, so the
documented `--source-ref refs/tags/vX.Y.Z` and cosign identity fail for
current releases.
- Checked: `gh attestation verify` on v2.39.4 fails with the tag ref and
passes with `refs/heads/release/2.39`. v2.39.1 still passes with its
tag. Cosign verifies v2.39.4 with the new identity.

### Review fixes (second commit set)

Two independent reviews (one functional, one adversarial) found the
following, now fixed:
- **A writer could get a real release to attest their image.** The index
was built from, and its digest read back from, mutable staging tags. A
writer moving `coder-staging:vX` mid-release could get their image
attested. Now every digest comes from the registry's response to our own
push (`docker push`, `docker manifest push`, depot, `helm push`), the
index is built from per-arch **digests**, and syft and cosign run on
`image@digest`. Tested against a local registry with Docker 29: each
parsed digest matches what the registry stores, and the index contains
exactly the pushed children.
- **Commit binding.** The provenance commit field is the dispatched
branch head, not the released commit (which differs whenever an older
commit is released). Each artifact now gets a release attestation
(`https://coder.com/attestations/release/v1`) stating version, commit
and target package, and the publisher requires it, plus an approved
`release` environment on the run.
- **Re-runs:** a tag an earlier attempt promoted is accepted, and the
publisher keeps that build.
- **Tokens:** the tagging and promotion App tokens are revoked right
after use.
- **Docs:** `SOURCE_REF` is now correct for RCs (checked in bash and
PowerShell).

Image *provenance* attestations are best-effort again, as before; the
publisher relies on the release attestations instead.

### Prerequisites (all done 2026-11-22)
1. coder/ghcr-publisher#1 and coder/ghcr-publisher#2 merged (#2 checks
the release attestations this PR now produces).
2. The staging packages exist (created 2026-11-20), with coder/coder
**Write** and `ghcr-publisher` **Read** set under Manage Actions access:
`coder-staging`, `coder-base-staging`, `chart-staging/coder`,
`chart-staging/coder-provisioner`, `chart-staging/coder-ai-gateway`.
3. The `coder-ghcr-dispatch` App exists and is installed on
`ghcr-publisher` only (coder/gcp#472, coder/github-org-terraform#206),
and `CODER_GHCR_DISPATCH_APP_ID` and `CODER_GHCR_DISPATCH_APP_KMS_KEY`
are set in the `release` environment. `coder-release-publisher` is
uninstalled from `ghcr-publisher`.

### After merge
- Backport to release/2.39, 2.38, 2.37, 2.34 and 2.29. Each branch runs
its own `release.yaml`.
- After one real release promotes successfully, switch the five public
packages to coder/coder **Read** and ghcr-publisher **Write**. Only then
is the overwrite path closed.

Tested:
- The publisher's checks against the real v2.39.4 attestations: pass on
the right ref, fail on a wrong ref, wrong commit or wrong signer.
- The anonymous digest lookup against live image, base and chart tags
(matches crane).
- actionlint and zizmor are clean.
- No release has run with this yet.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:05:46 -05:00
..