Skip to content

build(ci): upgrade cosign to v3 by migrating the signature layout - #928

Merged
bpalermo merged 1 commit into
mainfrom
build/cosign-v3-layout-migration
Sep 24, 2026
Merged

bpalermo merged 1 commit into
mainfrom
build/cosign-v3-layout-migration

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

Second attempt at the cosign upgrade. Refs #924.

Why the first one failed

#924 upgraded the binary while holding the legacy sha256-<digest>.sig layout. 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. Holding the layout is not a reachable state, so migrating is the only way forward — and the migration has to carry the verifier with it in the same commit, or everything published before today becomes unverifiable the moment the signer changes shape.

What changed

  • 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 exactly what broke build(ci): upgrade cosign to v3, and hold the signature layout while doing it #924.
  • ghcr-lib.sh grows ghcr_signature_tag_legacy / _bundle and, more importantly, ghcr_signature_layout() → legacy | bundle | none | both.

The both case is the point

"Accept either layout" is one grep away from "accept anything". A double-write or half-finished migration is precisely the state that presence-only checking reports as a healthy signature. It is now a distinct, named failure rather than a silent pass.

This is also the negative half we were missing: we asserted .sig was present and never that the bare tag was absent.

Not pinning --new-bundle-format on verify, deliberately

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 — and that reasoning is now a comment in the workflow, because it corrects a symmetry I asserted without checking.

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.

Proof the new logic can fail

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; relaxing it to grep -qF would silently report both for every legacy signature.

Negative control — that exact relaxation:

  FAIL  want=legacy got=both <- [sha256-abc123.sig other-tag]
  FAIL  want=legacy got=both <- [sha256-abc123.sig]
::error::signature layout resolution is wrong
exit=1

and green on restore. Wired into the shell CI job; check-shell-lint.sh confirms it is covered (23 scripts).

Regression against the live registry

commit signer result
7de67d2 cosign 2 PASS: 20 artifact(s)
5325a57 cosign 2 PASS: 20 artifact(s)
1e31e3a unsigned (the #924 failure) FAIL: 8 of 20 missing, exit 1

Also corrected

The rules_img note 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. Now marked as such.

What still cannot be proven before merge

The keyless signing path, again — it needs the workflow's OIDC token. That is what bit #924, and I am not going to imply otherwise. What is different this time is that the failure mode #924 hit is now impossible (the rejected flag is gone) rather than merely unexpected, and the verifier accepts both layouts, so a publish either signs in the new shape and passes, or fails to sign and publish-verify.yaml reports it the way it did for 1e31e3a.

Rollback remains one line.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

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

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
@bpalermo
bpalermo enabled auto-merge (squash) September 24, 2026 11:01
@bpalermo
bpalermo merged commit 96487a3 into main Sep 24, 2026
23 checks passed
@bpalermo
bpalermo deleted the build/cosign-v3-layout-migration branch September 24, 2026 11:12
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