Skip to content

build(ci): upgrade cosign to v3, and hold the signature layout while doing it - #924

Merged
bpalermo merged 2 commits into
mainfrom
build/cosign-v3-upgrade
Sep 23, 2026
Merged

bpalermo merged 2 commits into
mainfrom
build/cosign-v3-upgrade

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

Upgrades the image signer from cosign v2.4.1 to v3.0.6, and — because v3 changes where a signature lands — holds the on-registry layout fixed rather than letting a version bump migrate the artifact format as a side effect.

Three functional lines change:

-        uses: sigstore/[email protected]
+        uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2
-            cosign sign --recursive "ghcr.io/${repo}@${digest}"
+            cosign sign --recursive --new-bundle-format=false "ghcr.io/${repo}@${digest}"
             cosign verify \
+              --new-bundle-format=false \

Everything else is comment recording why.

What we were actually running

[email protected] has no cosign-release: set, and its default input is v2.4.1. Confirmed not by reading the README but by downloading the binary: the SHA-256 hardcoded in that action commit, 8b24b946…89249b, is the real cosign-linux-amd64 for v2.4.1. This repo has been signing with cosign 2 the whole time, so this is genuinely a major upgrade.

The finding: v3 moves the signature

cosign v3 defaults sign to --new-bundle-format=true (options/sign.go:155). That routes signing through signDigestBundle → ociremote.WriteAttestationNewBundleFormat → WriteReferrer, which pushes an OCI 1.1 referring artifact with a subject (sign.go:117, write.go). It is listed as an intended v3 default in the v3.0.0 release notes: "container signatures stored as an OCI Image 1.1 referring artifact".

On a registry with no Referrers API, go-containerregistry does not fail — it writes the referrers fallback tag, sha256-<hex> (colon→dash, no .sig), holding an application/vnd.oci.image.index.v1+json.

ghcr is such a registry, re-confirmed here rather than inherited from the existing comment — same token, same repo:

GET /v2/bpalermo/aether/agent/referrers/sha256:c8a2dd3a…  -> 404
GET /v2/bpalermo/aether/agent/tags/list?n=1               -> 200

Measured, on a throwaway local registry that 404s /referrers exactly as ghcr does

No real package touched, no publish triggered, no public transparency log written.

### 0. does this registry implement the OCI referrers API?
  GET /v2/probe-default/referrers/sha256:2293b3… -> HTTP 404

### 1. cosign v3.0.6 sign with DEFAULT flags == what a blind version bump gives us
  tags in probe-default now:
     latest
     sha256-2293b36c7c9082bf4115aab724b4d2cddec82c8eba39bf27ac0517e159acf150     <-- no .sig

### 2. cosign v3.0.6 sign with --new-bundle-format=false == this PR
  tags in probe-legacy now:
     latest
     sha256-2293b36c7c9082bf4115aab724b4d2cddec82c8eba39bf27ac0517e159acf150.sig

### 6. what IS the v3-default artifact at sha256-<hex>?
   mediaType: application/vnd.oci.image.index.v1+json
   -> application/vnd.oci.image.manifest.v1+json  application/vnd.oci.empty.v1+json  sha256:0a88e58a…

So a blind bump makes scripts/ghcr-lib.sh's ghcr_signature_tag() resolve a tag that is never written, and scripts/verify-published-artifacts.sh (#880, #913) reports eight MISSING signatures per commit — for artifacts that were, in fact, signed.

The worse half: a green publish and blind verifiers

### 3. can a cosign v2.4.1 client read the v3-DEFAULT signature?
  v2.4.1 verify of v3-default signature: exit=10
     Error: no signatures found

### 4. can a cosign v2.4.1 client read the --new-bundle-format=false signature?
  v2.4.1 verify of v3 legacy-format signature: exit=0

### 5. does cosign v3.0.6 verify BOTH?
  v3 verify of v3-default:  exit=0
  v3 verify of legacy:      exit=0

A cosign 2 client does not fail closed on a v3 signature — it reports no signatures found, byte-identical to "this image was never signed". And because this workflow verifies with the same binary it just signed with, and v3 reads both formats, CI would have been green the whole time. That is the #853 / #882 / #906 shape — a check that cannot fail — so it is called out explicitly rather than discovered later.

Why hold the layout instead of migrating

Every artifact this repo has ever published is the legacy layout (78 .sig tags in each of the eight image repositories; zero bare sha256-<hex> tags, so nothing else here writes referrers either). Keeping it means no flag day, no split history for the verifier to straddle, and no silent break for any consumer pinned to cosign 2. Migrating the format is a real decision with its own blast radius; it should not ride along inside "upgrade the signer".

--new-bundle-format is deprecated upstream ("this will be the only supported format in future versions" — the deprecation notice lands in v3.1.x), so this is a stay of execution, not a permanent answer. scripts/ghcr-lib.sh now records the coupling in the one place that would go wrong: when the flag disappears, the signer and ghcr_signature_tag() move in the same commit, or the verifier goes blind.

Why the same flag on verify — it is an assertion, not compatibility

v3's verify auto-detects: it looks for a Sigstore bundle and silently falls back to the tag scheme when it finds none (verify.go:154-159). Left alone it therefore passes against either layout — blind to the exact drift it exists to catch. Pinned, it fails closed:

v3 verify --new-bundle-format=false  of a v3-FORMAT signature: exit=10  (no signatures found)
v3 verify (auto-detect)              of the same:              exit=0

The gate can fail. Proven, not asserted.

Why pinned by commit, unlike every other action here

This job holds packages: write and id-token: write. Whoever controls the action installed here can push to our repositories and sign with our OIDC identity — and cosign verify would pass, because the Fulcio certificate really would be this workflow's. A moved tag is enough. The signature does not protect against a swapped signer; only the pin does.

v4.1.2 = 6f9f17788090df1f26f669e9d70d6ae9567deba6, "Bump cosign to 3.0.6" (resolved via the API, not copied).

Why no cosign-release:

Unset, the action installs its bootstrap version by comparing the download against a SHA-256 hardcoded in the pinned commit — so the action pin fixes the cosign binary too, trusting no release asset and no raw.githubusercontent.com fetch. Verified end to end: the real cosign-linux-amd64 v3.0.6 hashes to c956e5df…3f4c74, exactly the constant in 6f9f177.

Naming a version takes the action's other branch (fetch the release public key, verify the download against it). In v4 that branch is sound — the key's digest is pinned and the old --insecure-ignore-tlog is gone — but it is more moving parts for no gain, and a cosign-release: nobody remembers to bump silently outlives the pin.

Version note, stated plainly: cosign's own latest is v3.1.3 (2026-08-06); no installer release ships it (v4.1.2 predates it). v3.1.3 fixes GHSA-fx35-mq7g-6g98, which the advisory scopes to verify-blob / verify-blob-attestation with legacy JSON bundles and states explicitly does not affect OCI container image verification — the only cosign flow this repo uses. So v3.0.6 is not exposed here, and the comment says to revisit when an installer release bootstraps 3.1.x. The 3.x installer line is abandoned (last release 2025-10-16, still bootstrapping cosign v2.6.1); 4.x is the only line shipping.

Evidence summary

Claim How it was established
We sign with cosign v2.4.1 today Downloaded v2.4.1; SHA matches the constant in [email protected]
v4.1.2 installs cosign v3.0.6 Downloaded v3.0.6; SHA matches the constant in 6f9f177
ghcr has no Referrers API GET /referrers/<digest> → 404, tags/list → 200, same token, aether's own repo
v3 default writes sha256-<hex>, not .sig Local registry probe, plus cosign + ggcr source
v2 cannot read a v3 signature Local probe: exit=10, no signatures found
v3 reads v2 signatures Read-only against ghcr: cosign 3.0.6 verify with this workflow's exact flags → exit 0 on agent@sha256:c8a2dd3a… (a real 7de67d2 artifact)
--new-bundle-format=false reproduces today's layout Local probe: .sig tag written; v2.4.1 verifies it, exit 0
The verifier still agrees scripts/verify-published-artifacts.sh 7de67d2 b680a00 → PASS: 40 artifact(s), identical before and after
Gates bazel run //:format.check clean (no files rewritten); bazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //... green; scripts/ghcr-lib.sh is inside //scripts:scripts_shell's glob, so shellcheck really does lint it

What I could NOT prove, and what to watch

The signing step itself was never executed. Keyless signing needs the workflow's OIDC token, and the rule here is that the release workflow is the only publisher — so nothing in this PR was tested by publishing. Everything above about this repo's signing path is source-derived plus a local-registry rehearsal with a throwaway key; the ghcr side was exercised read-only.

On the first publish after merge, check, in order:

  1. Sign published images prints Pushing signature to: ghcr.io/bpalermo/aether/<img> — the new-bundle path prints a different line and would indicate the flag did not take.
  2. Verify the signatures prints verified 8 signature(s). With --new-bundle-format=false this now fails closed if the layout moved.
  3. bash scripts/verify-published-artifacts.sh <merge sha> → PASS: 20 artifact(s). This is the real assertion that the .sig tag exists; publish-verify runs it automatically after the run concludes.

If (2) or (3) go red, the rollback is one line: restore sigstore/[email protected]. The images are pushed by digest in an earlier step, so a signing failure never leaves them unpublished.

Noted, not changed

  • cosign verify has no --recursive. sign --recursive signs the index and every child manifest, but the verify loop reads one index digest per repository, so the per-arch manifests are signed and never verified. Pre-existing, unchanged by this PR, and worth its own issue rather than being smuggled into a version bump.
  • The rules_img comment stands. It claims rules_img's signing support attaches signatures only as referrers. I re-derived rather than inheriting either the comment or a peer's correction of it: rules_img 0.3.21's own signing_config docstring says "The signature is then pushed to the image's repository as an OCI referrer." _SIGN_TARGETS = ["roots", "child_manifests", "referrers"] is indeed which descriptors get signed and not where signatures go — but that does not rescue the approach here, because img deploy still pushes the signer's output as a referrer. Left alone.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

…doing it

`sigstore/[email protected]` bootstraps cosign **v2.4.1** (the SHA-256
hardcoded in that action matches the real v2.4.1 binary, 8b24b946…89249b), so
this repo has been signing with cosign 2 all along. Move to the 4.x installer
line, pinned by commit: v4.1.2 (6f9f177, "Bump cosign to 3.0.6") installs cosign
**v3.0.6**, sha256 c956e5df…3f4c74 — verified by downloading the binary and
comparing it against the constant in the pinned commit.

Pinned by SHA rather than by tag, unlike this repo's other actions, because this
job holds `packages: write` + `id-token: write`: a moved tag could push and sign
under our genuine OIDC identity and `cosign verify` would pass, since the
certificate really would be this workflow's. No `cosign-release:`, so the pinned
commit fixes the binary too, with no trust in a release asset.

THE PART THAT IS NOT A VERSION BUMP. cosign v3 defaults `sign` to
`--new-bundle-format=true`, which writes an OCI 1.1 referring artifact; on a
registry with no Referrers API (ghcr — /referrers 404s, re-confirmed against
ghcr.io/bpalermo/aether/agent with a token that gets 200 from tags/list)
go-containerregistry lands it under the fallback tag `sha256-<hex>`, an index
with no `.sig` suffix. Measured on a local registry that 404s /referrers the
same way:

  cosign 3.0.6 sign (defaults)                -> tag sha256-2293b3…
  cosign 3.0.6 sign --new-bundle-format=false -> tag sha256-2293b3….sig

That would break scripts/verify-published-artifacts.sh (#880), which resolves
`sha256-<digest>.sig` — eight MISSING signatures per commit. Worse, a cosign v2
client reading a v3-format signature reports `Error: no signatures found`
(exit 10, measured), indistinguishable from unsigned, while this workflow's own
verify step stays green because it runs the same v3 binary and v3 reads both
formats. So: upgrade the binary, hold the layout. Every artifact published to
date is the legacy layout and stays byte-compatible with it.

The same flag is added to `cosign verify` as an assertion, not for
compatibility: v3 verify auto-detects the layout and so passes against either
one, which would make the step blind to the signer changing where signatures
land. Pinned, it fails closed — exit 10 against a v3-format signature, measured,
versus exit 0 for the auto-detecting default.

`--new-bundle-format` is deprecated upstream, so this is a stay of execution.
scripts/ghcr-lib.sh records the coupling: when the flag goes, the signer and
ghcr_signature_tag() move in the same commit or the verifier goes blind.

Evidence, all read-only against the registry:
- cosign 3.0.6 verifies the existing v2.4.1-produced signatures with the exact
  flags this workflow uses (exit 0 against agent@sha256:c8a2dd3a…).
- `scripts/verify-published-artifacts.sh 7de67d2 b680a00` -> PASS: 40, unchanged
  before and after.
- No bare `sha256-<hex>` tag exists in any of the eight repositories today
  (78 `.sig` tags each), so nothing else is writing referrers here.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
@bpalermo
bpalermo merged commit 1e31e3a into main Sep 23, 2026
23 checks passed
@bpalermo
bpalermo deleted the build/cosign-v3-upgrade branch September 23, 2026 23:47
@bpalermo

Copy link
Copy Markdown
Owner Author

Follow-up measurement: the two flag values are NOT symmetric

A peer session ran the control I suggested and it disproved a symmetry I had asserted. Recording it here because the PR's own comment could otherwise be generalised wrongly.

Measured with a v3.0.6 binary against two real ghcr artifacts — one signed by cosign 2.4.1, one by 3.0.6:

default flags              vs v3-format sig   exit 0
default flags              vs v2-format sig   exit 0    <- auto-detection
--new-bundle-format=true   vs v3-format sig   exit 0
--new-bundle-format=true   vs v2-format sig   exit 0    <- should have failed; did not
--new-bundle-format=false  vs v3-format sig   exit 10   <- this PR's measurement, reproduced

--new-bundle-format=bogus is rejected with a ParseBool error, so the flag is genuinely parsed and not silently ignored in the true case.

false excludes the bundle layout and fails closed against it. true excludes nothing — it still finds and accepts a legacy .sig. So the assertion this PR adds on verify works because we chose false, not because pinning the flag asserts a layout in general.

That matters for whoever migrates later: flipping to the new format and pinning --new-bundle-format=true would silently lose the gate while looking like it kept it. Nothing in this repo would catch that — it is the #853/#882/#906 shape one level up, in the fix for it.

What actually gates in both directions

The registry, not the binary. Per digest the two layouts are mutually exclusive:

new-format digest:  sha256-<digest> 200    sha256-<digest>.sig 404
old-format digest:  sha256-<digest> 404    sha256-<digest>.sig 200

aether already has half of this, arrived at from an unrelated direction: ghcr_signature_tag() (scripts/ghcr-lib.sh:89) plus publish-verify.yaml (workflow_run: [publish]) asks the registry after every publish whether the .sig tags exist — built for #880, nothing to do with signature formats. If cosign silently switched layout, those tags would stop existing and it would go red.

The half we lack is the negative: we assert .sig is present and never that the bare sha256-<digest> tag is absent, so a double-write or half-migrated state reads as healthy. Worth adding.

As the peer put it, the value is in checking the registry rather than asking the same binary that just wrote the signature whether it likes it — which is a better statement of the original problem than the one in this PR's description.

No change requested to this PR: false is the correct choice and its gate is real. This is a note for the next person to touch it.

bpalermo added a commit that referenced this pull request Sep 23, 2026
…t while doing it (#924)" (#926)

This reverts commit 1e31e3a.

The publish for 1e31e3a FAILED at the signing step:

  Error: must provide --new-bundle-format or --bundle where applicable
         with --signing-config or --use-signing-config

cosign v3.0.6's keyless path rejects --new-bundle-format=false. So "upgrade
the binary, hold the layout" — the entire premise of #924 — is not available
with v3 keyless signing. v3 requires the new bundle format here.

This could only be found by running it. #924 said so plainly: the signing step
was never executed because keyless signing needs the workflow's OIDC token, and
everything about aether's own signing path was source-derived plus a local
rehearsal with a throwaway key. The rehearsal used a key, and the key path does
not carry this constraint. That gap was disclosed, and it is exactly where the
defect was.

Reverting restores a working publish rather than leaving main in a state where
every publish fails and every image ships unsigned.

Note on blast radius: the sign step runs AFTER the pushes, deliberately, so a
signing failure never leaves images unpublished. The consequence is narrower and
must be recorded rather than glossed: **1e31e3a's images are published and
UNSIGNED.** No deployed artifact is affected — talos runs rev237 (b680a00) —
and publish-verify.yaml (#913) will report the missing signatures rather than
staying quiet, which is the gate working as designed.

The upgrade is still worth doing. It needs the layout migration done properly:
accept v3's fallback-index layout and teach ghcr_signature_tag() and
verify-published-artifacts.sh to resolve `sha256-<digest>` as well as
`sha256-<digest>.sig`, so already-published artifacts stay verifiable across the
change. Tracked separately.

Refs #924


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

Co-authored-by: Bruno Palermo <[email protected]>
Co-authored-by: Claude Opus 5 <[email protected]>
bpalermo added a commit that referenced this pull request Sep 24, 2026
Second attempt. #924 tried to upgrade the binary while HOLDING the legacy
`sha256-<digest>.sig` layout, and its publish failed:

  Error: must provide --new-bundle-format or --bundle where applicable
         with --signing-config or --use-signing-config

cosign 3's keyless path rejects --new-bundle-format=false outright, so holding
the layout is not a reachable state. Migrating is the only way forward, and the
migration has to carry the verifier with it in the same commit — otherwise
everything published before today becomes unverifiable the moment the signer
changes shape.

So:

  * installer -> v4.1.2 pinned BY SHA (bootstraps cosign v3.0.6). We were two
    majors behind, not one: v3.7.0 sets no cosign-release and defaults to
    v2.4.1. The installer version is not the cosign version.
  * `cosign sign --recursive` with no format flag — v3's default is the new
    layout, and the flag that would pin the old one is what broke #924.
  * ghcr-lib.sh grows ghcr_signature_tag_legacy/_bundle and, more importantly,
    ghcr_signature_layout(), which reports legacy|bundle|none|BOTH.

The `both` case is the point. "Accept either layout" is one grep away from
"accept anything", and a double-write or half-finished migration is exactly the
state that presence-only checking reports as a healthy signature. It is now a
distinct, named failure.

NOT pinning --new-bundle-format on verify, deliberately, and the workflow says
why: measured, `=false` fails closed against a v3 signature (exit 10) but
`=true` still ACCEPTS a legacy .sig (exit 0). It asserts nothing. Pinning it
there would be decoration. The layout assertion belongs in publish-verify.yaml,
which asks the REGISTRY rather than asking the same binary that just wrote the
signature whether it likes it.

scripts/check-signature-layout.sh covers all four states plus the subtlety that
`sha256-<d>.sig` must not satisfy the bare-tag check — `grep -qxF` matches whole
lines, and relaxing it to `grep -qF` would silently report `both` for every
legacy signature. Negative control: that exact relaxation turns the suite red on
two cases and green again on restore.

Also corrected the rules_img note, which stated inference in the same register
as measurement: the docstring saying signatures are pushed as an OCI referrer is
SOURCED; "with no fallback" is not, because that push lives in a prebuilt Go
binary absent from the archive.

Regression, against the live registry:

  7de67d2 (cosign 2)  PASS: 20 artifact(s)
  5325a57 (cosign 2)  PASS: 20 artifact(s)
  1e31e3a (unsigned)  FAIL: 8 of 20 missing, exit 1

Refs #924


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

Co-authored-by: Bruno Palermo <[email protected]>
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