Skip to content

fix(ci): replace GITHUB_TOKEN by fine-grained one#284

Merged
niemeyer merged 2 commits into
canonical:mainfrom
cjdcordeiro:ci/change-release-token
Apr 20, 2026
Merged

fix(ci): replace GITHUB_TOKEN by fine-grained one#284
niemeyer merged 2 commits into
canonical:mainfrom
cjdcordeiro:ci/change-release-token

Conversation

@cjdcordeiro
Copy link
Copy Markdown
Collaborator

  • Have you signed the CLA?

After the recent changes to the GITHUB_TOKEN, the build.yml workflow can no longer push the release artifacts to the GitHub release: https://github.com/canonical/chisel/actions/runs/24026969346

This PR replaces the GITHUB_TOKEN with a new one, managed by us. This new token has contents: write permissions (similarly to the GITHUB_TOKEN), which are unfortunately broad, because GitHub does not offer fine-grained control for releases. The use of the secret is bound to a single step, which runs our own CI script, and always in the context of the base repo and on release events.

Copy link
Copy Markdown
Collaborator

@upils upils left a comment

Choose a reason for hiding this comment

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

Thanks @cjdcordeiro. I was a bit worried because this workflow is executed in PRs, but this step is only executed for releases and the secret is only loaded for this specific step so I understand this is fine.

I see that we now have a growing collection of fine-grained tokens and it makes me wonder how much of a burden that will be to maintain. Maybe we should revisit at some point and use the permissions keyword at steps/jobs level to give a bit more permissions to the GITHUB_TOKEN when needed.

@upils upils added Bug An undesired feature ;-) Simple Nice for a quick look on a minute or two labels Apr 8, 2026
@polarathene
Copy link
Copy Markdown

Thanks @cjdcordeiro. I was a bit worried because this workflow is executed in PRs, but this step is only executed for releases and the secret is only loaded for this specific step so I understand this is fine.

pull_request triggered workflows do not have access to secrets. No need to worry about that when GH understands it's a secret :)

pull_request_target however would be a trigger that has risk, as that runs a workflow within a trusted context, allowing access to secrets (however the PR author cannot manipulate that configuration to apply the changes to their PR, which they can for pull_request IIRC).

Copy link
Copy Markdown
Contributor

@niemeyer niemeyer left a comment

Choose a reason for hiding this comment

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

After the recent reports, Paul is right that this does feel suspect since it's basically having a secret on a workflow that looks like it's visible. Can we please at least have a comment in there outlining why this safe, so we keep these concerns in people's minds?

Comment thread .github/workflows/build.yml Outdated
@cjdcordeiro
Copy link
Copy Markdown
Collaborator Author

After the recent reports, Paul is right that this does feel suspect since it's basically having a secret on a workflow that looks like it's visible. Can we please at least have a comment in there outlining why this safe, so we keep these concerns in people's minds?

@niemeyer sure. Done in 0dd9027.

It's a bit lengthy, but given that it's security-related, I feel like the level of detail is justified.

@cjdcordeiro cjdcordeiro requested a review from niemeyer April 15, 2026 10:36
Copy link
Copy Markdown
Contributor

@niemeyer niemeyer left a comment

Choose a reason for hiding this comment

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

Thanks for the very detailed explanation.

@niemeyer niemeyer merged commit c85fc8a into canonical:main Apr 20, 2026
18 checks passed
@ROCKsBot
Copy link
Copy Markdown

ROCKsBot commented Apr 21, 2026

Command Mean [s] Min [s] Max [s] Relative
BASE 14.002 ± 0.156 13.740 14.338 1.00 ± 0.02
HEAD 13.997 ± 0.215 13.757 14.269 1.00

upils pushed a commit to upils/chisel that referenced this pull request Apr 23, 2026
After the recent changes to the `GITHUB_TOKEN`, the `build.yml` workflow can no longer push the release artifacts to the GitHub release: https://github.com/canonical/chisel/actions/runs/24026969346

This PR replaces the `GITHUB_TOKEN` with a new one, managed by us. This new token has `contents: write` permissions (similarly to the `GITHUB_TOKEN`), which are unfortunately broad, because GitHub does not offer fine-grained control for releases. The use of the secret is bound to a single step, which runs our own CI script, and always in the context of the base repo and on `release` events.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug An undesired feature ;-) Simple Nice for a quick look on a minute or two

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants