Repository navigation
build(ci): upgrade cosign to v3 by migrating the signature layout - #928
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Second attempt at the cosign upgrade. Refs #924.
Why the first one failed
#924 upgraded the binary while holding the legacy
sha256-<digest>.siglayout. Its publish failed:cosign 3's keyless path rejects
--new-bundle-format=falseoutright. 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
v3.7.0sets nocosign-releaseand defaults to v2.4.1. The installer version is not the cosign version.cosign sign --recursivewith 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.shgrowsghcr_signature_tag_legacy/_bundleand, more importantly,ghcr_signature_layout()→legacy | bundle | none | both.The
bothcase is the point"Accept either layout" is one
grepaway 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
.sigwas present and never that the bare tag was absent.Not pinning
--new-bundle-formaton verify, deliberatelyMeasured:
=falsefails closed against a v3 signature (exit 10), but=truestill 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.shcovers all four states plus the subtlety thatsha256-<d>.sigmust not satisfy the bare-tag check.grep -qxFmatches whole lines; relaxing it togrep -qFwould silently reportbothfor every legacy signature.Negative control — that exact relaxation:
and green on restore. Wired into the
shellCI job;check-shell-lint.shconfirms it is covered (23 scripts).Regression against the live registry
7de67d2PASS: 20 artifact(s)5325a57PASS: 20 artifact(s)1e31e3aFAIL: 8 of 20 missing, exit 1Also 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.yamlreports it the way it did for1e31e3a.Rollback remains one line.
🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr