Skip to content

feat(release): sign staged metadata.json with cosign - #9087

Merged
cert-manager-prow[bot] merged 2 commits into
cert-manager:masterfrom
FelixPhipps:sign-metadata-cosign
Aug 5, 2026
Merged

cert-manager-prow[bot] merged 2 commits into
cert-manager:masterfrom
FelixPhipps:sign-metadata-cosign

Conversation

@FelixPhipps

Copy link
Copy Markdown
Member

Description

Problem

cmrel gcb publish now verifies a cosign signature over the staged metadata.json and, once enforcement is switched on, fails closed if there's no valid metadata.json.sig next to it in gs://cert-manager-release. metadata.json lists every release artifact and its checksum, and it's read back from the same bucket it was uploaded to — so signing it with the release KMS key (which random bucket writers don't hold) is what makes it trustworthy.

The staging job — make upload-release — never produced that signature:

  • Broken publish: upload-release is a plain rclone copyto of the release dir; it never installed cosign or signed anything, so no .sig was ever staged. With the enforcing default shipped, cmrel gcb publish refuses every release (this broke the v1.21.1 patch release).
  • Untrustworthy metadata: without a signature over metadata.json, anyone who can write to the staging bucket could alter the artifact list or checksums and the publish step had no way to detect it.

Solution

Sign $(bin_dir)/release/metadata.json with cosign (sign-blob) in make/release.mk, producing metadata.json.sig. The key is derived from the existing CMREL_KEY — rewritten to the gcpkms://…/versions/N form cosign expects — so callers still set only one key. --tlog-upload=false keeps this private staging artifact out of the public Rekor log and keeps verification offline. upload-release already copies the whole release dir, so the .sig ships alongside metadata.json with no rclone change, and cosign is already a make tool, so no cloudbuild change is needed. Local make release-artifacts is unaffected — signing only runs in the paths that already require CMREL_KEY.

Test plan

  • make --dry-run … metadata.json.sig expands to cosign sign-blob --yes --tlog-upload=false --key gcpkms://…/versions/1 --output-signature … metadata.json and the Makefile parses clean (recipe lines tab-indented, no missing separator).
  • KMS key derivation verified: CMREL_KEY ending …/cryptoKeyVersions/1 becomes gcpkms://…/versions/1, matching what cosign verify-blob --key gcpkms://… uses on the publish side.
  • Dependency wiring confirmed: the .sig target builds metadata.json first and pulls in $(NEEDS_COSIGN) (pinned cosign=v2.6.3).
  • Cross-version check to run before enforcement is flipped on: one cmrel publish --nomock against a freshly-signed staged release, confirming publish-side cosign v1.13.6 verify-blob accepts the v2.6.3-produced detached signature.

Release note

The release staging process now signs metadata.json with cosign so the publish step can verify its authenticity.

cmrel gcb publish now verifies a cosign signature over the staged
metadata.json and (once enforced) fails closed without one. The staging
job (make upload-release) never produced that signature, which broke
publishing (see the v1.21.1 incident).

Sign $(bin_dir)/release/metadata.json with cosign (sign-blob, keyed off
the existing CMREL_KEY, no tlog upload) in make/release.mk. upload-release
already copies the whole release dir, so metadata.json.sig ships alongside
it, and cosign is already a make tool, so no cloudbuild change is needed.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Felix Phipps <[email protected]>
@cert-manager-prow cert-manager-prow Bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 30, 2026
@wallrj
wallrj requested a lite review from Copilot August 4, 2026 16:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the release Makefile to generate and stage a detached cosign signature for metadata.json, enabling the publish pipeline to verify the staged metadata’s authenticity using the release KMS key.

Changes:

  • Derive a gcpkms://.../versions/N cosign-compatible KMS URI from CMREL_KEY (COSIGN_KMS_KEY).
  • Add a Make target to sign $(bin_dir)/release/metadata.json with cosign sign-blob, producing metadata.json.sig.
  • Ensure make release builds metadata.json.sig alongside metadata.json.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread make/release.mk Resolved
Guard the metadata.json.sig target with an explicit CMREL_KEY empty
check, consistent with the helm-chart signing target in manifests.mk.
Without it, an unset CMREL_KEY expands COSIGN_KMS_KEY to a bare
"gcpkms://" and cosign fails with an opaque KMS error; this gives an
actionable message, notably when the target is invoked directly rather
than via the release chain.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Felix Phipps <[email protected]>
@FelixPhipps

Copy link
Copy Markdown
Member Author

/kind feature

@cert-manager-prow cert-manager-prow Bot added kind/feature Categorizes issue or PR as related to a new feature. and removed needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Aug 5, 2026

@wallrj wallrj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change is minimal and correct: a single new make rule signs the staged metadata.json with cosign (--tlog-upload=false, KMS key derived from the existing CMREL_KEY), and upload-release already ships the whole release dir so the .sig lands next to it with no rclone or cloudbuild changes.

The one Copilot review comment (fail fast when CMREL_KEY is empty) was addressed in e21fd92 with an explicit guard consistent with the other signing targets, and the thread is resolved. All presubmits are green.

/lgtm
/approve

with claude fable-5

@cert-manager-prow cert-manager-prow Bot added the lgtm Indicates that a PR is ready to be merged. label Aug 5, 2026
@cert-manager-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: wallrj

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@cert-manager-prow cert-manager-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 5, 2026
@cert-manager-prow
cert-manager-prow Bot merged commit 90ca1b2 into cert-manager:master Aug 5, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants