Skip to content

ci(publish): sign every published image with cosign, keyless - #875

Merged
bpalermo merged 3 commits into
mainfrom
feat/cosign-sign-images
Sep 20, 2026
Merged

bpalermo merged 3 commits into
mainfrom
feat/cosign-sign-images

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

Signs the eight images publish produces, and verifies the signatures in the same run.

Where the signature goes

Cosign's tag scheme puts it in the same repository as the image, under a tag derived from the image digest:

image:  ghcr.io/bpalermo/aether/agent@sha256:bb8298…
sig:    ghcr.io/bpalermo/aether/agent:sha256-bb8298….sig

It is an ordinary OCI image manifest whose layer is application/vnd.dev.cosign.simplesigning.v1+json, with the signature, Fulcio certificate and Rekor bundle in its annotations. No separate file and no separate location.

Why not rules_img's signing, or the referrers API

rules_img supports signing (signing_config + rules_img_signer_cosign), and it attaches signatures only as OCI 1.1 referrers — its docs say "no extra tag or naming convention is required" and state no registry-compatibility caveat.

ghcr.io does not implement the Referrers API. Verified against four repositories:

repo /referrers/<digest> /tags/list
bpalermo/aether/aether-proxy (authed) 404 200
oras-project/oras 404 200
fluxcd/source-controller 404 200
homebrew/core/jq 404 200

Same token, same path shape — the failure isolates to that one endpoint. Meanwhile the tag scheme demonstrably works there: fluxcd/source-controller carries 18 live .sig tags on ghcr today, and inspecting one shows a plain manifest with no subject field, which is precisely why it needs no referrers support.

So rules_img's signing is unusable for this repo. (Its signer module is also at 0.0.1, its only release — young for the release path.)

Details that carry weight

  • Keyless via the Actions OIDC token (id-token: write). Fulcio issues a short-lived cert bound to this workflow's identity — no private key to store or rotate.
  • Signs the resolved index digest, not a tag. Signing a tag re-resolves it inside cosign, a TOCTOU window against a mutable ref; dev is rewritten by every publish (publish: concurrent runs race on the same chart version tag — older build overwrote newer (77a7d45 over 95b158e), deploy silently lacked #689 #692), so the commit-suffixed tag is used only to find the digest.
  • --recursive, because the images are multi-arch indexes. Confirmed empirically — the published agent index carries amd64 and arm64 children, so signing the index alone would leave anyone pulling by per-arch digest with an unsigned manifest.
  • Signing runs after the pushes, as its own step. A signature that fails to attach must not leave the images unpublished.
  • Verify consumes exactly what sign recorded — not a second copy of the repo list (which can drift), and not a tag (which can resolve elsewhere).
  • Neither step can pass by doing nothing. Signing fewer images than the list, or verifying an empty list, fails the job. That is the No shell script in the root workspace is linted: the shellcheck aspect has no sh_* target to visit #853 defect and it is explicitly guarded.

Verification done before committing

Digest resolution was exercised against the live registry:

tag    = dev-034b8d333927ed741a910740ce6edff88f50f0e9
digest = sha256:bb8298421788f3cf5baf2538eb429ccd8d7ca332277cda9b40562d6c7cc866bb
mediaType: application/vnd.oci.image.index.v1+json
children: ['amd64', 'arm64']

The missing-tag path was exercised too, using a commit whose publish has not run yet: it fails closed with a named error rather than signing the wrong thing.

bash -n clean on every run block; YAML parses.

What cannot be tested until merge

publish only runs on push to main, so the signing itself first executes on merge. If it fails there, the images are still published and the job goes red — deliberate, per the ordering above. Worth watching that first run.

Follow-up, not in scope: the Helm charts are also OCI artifacts and could be signed the same way.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

Signs the eight images this workflow publishes, and verifies the signatures
in the same run.

Where the signature goes: cosign's tag scheme puts it in the SAME repository
as the image, under a tag derived from the image digest -- `sha256:abc…`
becomes the tag `sha256-abc….sig`. It is an ordinary OCI image manifest
whose layer is application/vnd.dev.cosign.simplesigning.v1+json, carrying the
signature, Fulcio certificate and Rekor bundle in its annotations. No
separate file and no separate location.

This is deliberately NOT the OCI 1.1 referrers scheme, and the choice is
forced: ghcr.io does not implement the Referrers API. Verified against four
repositories -- our own aether-proxy plus the public oras-project/oras,
fluxcd/source-controller and homebrew/core/jq -- where
GET /v2/<repo>/referrers/<digest> returns 404 while /tags/list and
/manifests/ succeed with the same token. The tag scheme demonstrably works
there: fluxcd/source-controller carries 18 live `.sig` tags on ghcr today,
and one of them is an ordinary manifest with NO `subject` field, which is
exactly why it needs no referrers support.

That is also why rules_img's own signing support (signing_config +
rules_img_signer_cosign) is unusable here: it attaches signatures only as
referrers, with no fallback, and its docs state no registry-compatibility
caveat. Its signer module is also at 0.0.1, its only release.

Details that carry weight:

  - Keyless via the Actions OIDC token (id-token: write). Fulcio issues a
    short-lived certificate bound to this workflow's identity, so there is no
    private key to store or rotate.
  - Signs the resolved INDEX DIGEST, not a tag. Signing a tag re-resolves it
    inside cosign, a TOCTOU window against a mutable tag; `dev` is rewritten
    by every publish (#692), so only the commit-suffixed tag is immutable and
    it is used solely to find the digest.
  - `--recursive`, because the images are multi-arch indexes. Confirmed
    empirically: the published agent index carries amd64 and arm64 children,
    so signing the index alone would leave anyone pulling by per-arch digest
    with an unsigned manifest.
  - Signing runs AFTER the pushes, as its own step. A signature that fails to
    attach must not leave the images unpublished.
  - The sign step records each signed reference and the verify step consumes
    exactly that list -- not a second copy of the repo list, which could
    drift, and not a tag, which could resolve elsewhere.
  - Both steps refuse to report success on an empty set: signing fewer images
    than the list, or verifying an empty list, fails the job. A step that
    passes because it did nothing is the #853 defect.

The digest resolution was exercised against the live registry before
committing: tag `dev-034b8d33…` resolves to
sha256:bb8298421788f3cf5baf2538eb429ccd8d7ca332277cda9b40562d6c7cc866bb, an
OCI index with amd64+arm64 children. The missing-tag path was exercised too
(a commit whose publish has not run yet) and fails closed with a named error.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
@bpalermo
bpalermo force-pushed the feat/cosign-sign-images branch from c97246d to 6406b57 Compare September 20, 2026 19:02
@bpalermo
bpalermo merged commit f332061 into main Sep 20, 2026
22 checks passed
@bpalermo
bpalermo deleted the feat/cosign-sign-images branch September 20, 2026 19:26
bpalermo added a commit that referenced this pull request Sep 20, 2026
The sign step resolved each image's commit-suffixed tag with a single
unpaginated call to /v2/<repo>/tags/list. ghcr returns ONE PAGE -- 100
tags -- and signals the rest with an RFC5988 `Link: rel="next"` header the
step ignored. Tags come back in ascending order, so the tag just pushed
sorts LAST and is never in the first page.

Every image repo is past 100 tags (agent 667, cni-install 651, registrar
654, udsecho 159, proxy-supervisor 52), so the lookup found nothing and the
step failed on e3b58e6 with

  no tag ending in -e3b58e6... in bpalermo/aether/agent

while `dev-e3b58e6b3d3e23ee9c0bcd839741ce0779f2bf7a` was sitting in the
registry the whole time. Signing has therefore never once succeeded since
#875 merged -- and because `Verify the signatures` is skipped when the sign
step fails, the gate written to prove the signatures exist has never run
either. The images and charts were published normally; only the signatures
are missing.

Follows the `last=` cursor to the final page. ghcr's own next-URL carries
`n=0`, so the page size is re-stated rather than following that URL
verbatim. Also reports the scan size on both the success and the failure
path: "not found in 667" is a real absence, "not found in 100" means the
pagination regressed, and the two must never read the same again.

Verified by extracting the step's script from the YAML and running it
against the live registry: all 8 repos resolve the tag, scanning 52-667
tags each. The single-page repo (proxy-supervisor, 52) exercises the
no-Link-header exit. The pre-fix call returns 100 tags and <NONE> for every
repo, including the 159-tag one.


Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

Co-authored-by: Claude Opus 5 <[email protected]>
bpalermo added a commit that referenced this pull request Sep 23, 2026
…o out loud (#880) (#913)

A commit merged into a busy publish window can publish nothing, silently.
`publish.yaml` serialises on `concurrency: { group: publish-main,
cancel-in-progress: false }` (#692), which protects the RUNNING publish but does
not make the queue a queue: GitHub holds at most ONE pending run per concurrency
group, so the next merge cancels the previous merge's pending run. That run ends
`cancelled` — grey, not red — having started zero jobs, and the commit-suffixed
chart tag that #692 made THE deploy coordinate does not exist for that commit.
f332061 (#875) was lost that way on 2026-09-20.

The serialisation stays exactly as it is; the gap is made loud instead.

- scripts/verify-published-artifacts.sh asks GHCR directly, per commit: four
  commit-tagged charts, eight image tags ending in `-<full sha>`, and a cosign
  signature (`sha256-<digest>.sig`) for each of those eight. 20 coordinates. It
  never asks whether a workflow exited 0 — a run that exited 0 pushing nothing,
  a run cancelled at queue time and a run that never existed all answer the same
  way here. Read-only: every request is a GET or a HEAD, and nothing in it can
  push. Chart versions come from each charts/*/Chart.yaml AS OF that commit, and
  every commit-ish is expanded to 40 characters by git, never typed.

- .github/workflows/publish-verify.yaml runs it on `workflow_run: [completed]`
  of `publish` (fires whatever the conclusion, so the cancelled run is caught
  with no race) and every two hours over the last day of main as a backstop for
  the event itself. Its own concurrency group is per-commit, because one shared
  group is the defect being fixed. On failure it files/updates one rolling issue
  naming the missing coordinates.

- scripts/ghcr-lib.sh holds the registry-read helpers and the published-repo
  list, now shared with publish.yaml's sign step rather than duplicated. The
  sign step's own comment warned that a second copy of the list could drift; a
  drifted verifier would pass over an image nobody published.

Proven in both directions before merging: f332061 (never published) reports
20/20 missing and exits 1; 5b0c199 and 24cc1d7 report 20/20 present and exit 0;
2b6acc4 (published pre-#875) reports 8/20 missing, which is the signature half
of the check failing on its own. `make check-published` runs the same thing by
hand.

Closes #880.


Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

Co-authored-by: Claude Opus 5 <[email protected]>
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