Skip to content

fix(gcb): rotate the publish GITHUB_TOKEN - #372

Merged
cert-manager-prow[bot] merged 1 commit into
masterfrom
rotate-release-github-token
Sep 11, 2026
Merged

cert-manager-prow[bot] merged 1 commit into
masterfrom
rotate-release-github-token

Conversation

@wallrj-cyberark

@wallrj-cyberark wallrj-cyberark commented Sep 11, 2026 •

Copy link
Copy Markdown
Member

What this does

Rotates the KMS-encrypted GITHUB_TOKEN used by the publish job.

This is a stop-gap. It swaps one long-lived credential for another so that v1.21.2 can ship. It does not fix the underlying problem, which is that the privileged publish job depends on a static token that nobody notices has died until a release fails. Separately I am looking at octo-sts so that the job mints short-lived, federated credentials and we hold no long-lived access tokens at all. Treat this PR as buying time for that work, not as the answer.

Why now?

The v1.21.2 publish failed. The job got as far as the first publish action and stopped:

2026/09/10 16:44:54 !!! Publishing release artifacts to public repositories !!!
2026/09/10 16:44:54 Creating a draft GitHub release "v1.21.2" in repository cert-manager/cert-manager
failed to create GitHub release: POST https://api.github.com/repos/cert-manager/cert-manager/releases: 401 Bad credentials

Tracing the token line with git log -L shows the encrypted blob had not changed since 2020-01-31. It last worked for the v1.21.1 publish on 2026-07-29, so it was revoked at some point in the six weeks since. 401 means the credential is invalid, not that a scope is missing.

A token that sat untouched for five and a half years, and whose death we discovered through a failed release, is a good illustration of why the octo-sts work is worth doing.

The replacement is a fine-grained token for the cert-manager-bot account, encrypted with the same KMS key.

One thing reviewers should know

A fine-grained token has a single resource owner, so this one cannot reach jetstack/jetstack-charts. The publish job has three actions, and they run in this order:

Action Target Works with this token
githubrelease cert-manager/cert-manager Yes
helmchartpr jetstack/jetstack-charts No
pushcontainerimages quay.io/jetstack (uses DOCKER_CONFIG) Yes

So v1.21.2 will be published with --publish-actions '*,-helmchartpr' and the chart PR raised by hand. The cross-org problem is one of the things octo-sts should settle properly.

Test evidence

No release was published by the failed run, so this is a clean retry rather than a repair. Verified three ways:

Checks confirming nothing reached the public repositories
  • No v1.21.2 release on cert-manager/cert-manager
  • No v1.21.2 tag on quay.io/jetstack/cert-manager-controller (the same query returns v1.21.1, so it is not a false negative)
  • No new PR on jetstack/jetstack-charts; the newest is #559 from August

The container images in the build log were only docker loaded into the build's local daemon. They were never pushed.

The new ciphertext decodes as valid base64 (175 bytes) and carries the same KMS key handle prefix as the value it replaces. The file still parses as YAML with both GITHUB_TOKEN and DOCKER_CONFIG present. DOCKER_CONFIG is untouched.

Final proof is the publish itself, which I will run from this commit.

Left alone deliberately

gcb/test/helm/cloudbuild.yaml holds the same revoked blob. It targets jetstack/jetstack-charts, so it needs a credential this token cannot provide. Rotating it needs a separate decision and I did not want to hide that inside a release fix.

The v1.21.2 publish job failed with `401 Bad credentials` when creating
the draft GitHub release. The encrypted token in this file had not
changed since 2020-01-31, and was revoked some time after the v1.21.1
publish succeeded on 2026-07-29.

Replace it with a fine-grained token for the cert-manager-bot account,
encrypted with the same KMS key.

`gcb/test/helm/cloudbuild.yaml` still holds the old, revoked blob. It
targets jetstack/jetstack-charts, which a fine-grained token scoped to
the cert-manager organisation cannot reach, so it needs a separate
credential and is left alone here.

Signed-off-by: Richard Wall <[email protected]>
@cert-manager-prow cert-manager-prow Bot added dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Sep 11, 2026
@wallrj-cyberark

Copy link
Copy Markdown
Member Author

/hold

@cert-manager-prow cert-manager-prow Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 11, 2026

@erikgb erikgb 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.

/lgtm
/approve

We can always revert if this makes the situation worse. Thanks @wallrj!

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

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: erikgb

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 Sep 11, 2026
@wallrj-cyberark

Copy link
Copy Markdown
Member Author

Thanks for the review @erikgb.

This token is no longer theoretical — v1.21.2 was published with it: https://github.com/cert-manager/cert-manager/releases/tag/v1.21.2

The clearest evidence that the rotation took effect is the release author. Every release up to and including v1.21.1 was created by jetstack-release-bot; v1.21.2 is the first created by cert-manager-bot:

Release Author
v1.21.2 cert-manager-bot
v1.21.1 jetstack-release-bot
v1.21.0 jetstack-release-bot
v1.20.3 jetstack-release-bot

The publish ran with --publish-actions '*,-helmchartpr', so githubrelease and pushcontainerimages both used the new credential and succeeded. The chart was handled separately, as described above, because a fine-grained token cannot span two organisations.

Worth recording for whoever looks at this next: the account itself was never the problem. jetstack-release-bot is not suspended, and another of its tokens is still in active use on an hourly schedule elsewhere in the release tooling. Only this one token was revoked. That does mean the account holds at least one more long-lived token of unknown age, which is a good argument for the octo-sts work rather than another rotation.

/unhold

@cert-manager-prow cert-manager-prow Bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 11, 2026
@cert-manager-prow
cert-manager-prow Bot merged commit 0b00257 into master Sep 11, 2026
3 checks passed
@wallrj-cyberark
wallrj-cyberark deleted the rotate-release-github-token branch September 11, 2026 09:37
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. lgtm Indicates that a PR is ready to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants