Repository navigation
Give the workflows read-only tokens and drop the unused PAT from the release draft - #384
Closed
Totara-thib wants to merge 4 commits into
Closed
Totara-thib wants to merge 4 commits into
Totara-thib wants to merge 4 commits into
Conversation
None of the five workflows declared permissions, so every job ran with the repository default, which grants write on everything (see the "GITHUB_TOKEN Permissions" block of any run log). Each workflow now starts from contents: read. Three jobs of the release draft keep contents: write: checks, srpm and windows-build call softprops/action-gh-release, and since its 2.5.3 release that action reads its token input first, which defaults to the job token. So at v3 the draft release is created and filled with the job token. The docs, PyPI, AUR, OBS, COPR and Homebrew jobs do their writes with their own secrets, never with the job token, and the lint jobs only read.
softprops/action-gh-release v1 read GITHUB_TOKEN from the environment
first. Since its 2.5.3 release ("prefer token input over GITHUB_TOKEN")
the token input wins, and that input defaults to the job token. So at
v3 the PYMPRESS_ACTION_PAT passed in env is not read anymore: the draft
release is already created with the job token.
Removing the three env blocks changes nothing in what runs, and it keeps
the token that publish_release.yml uses to push to pympress-pkgbuild and
to the homebrew-core fork out of the jobs that build the release.
To have the draft created with the personal token again, pass it as
"with: token:" on the three steps and the jobs can go back to
contents: read.
actions/checkout keeps the token it used configured for git until the job ends, so every later step of the job can use it. Eight of the nine checkouts never push, so they now pass persist-credentials: false and the token is removed as soon as the checkout step is done. The lint job on pull requests fetches the base branch afterwards. That fetch needs no credentials on a public repository. The ninth checkout is left as it is: the docs deploy checks out pympress.github.io with PYMPRESSDOCS_ACTION_PAT and pushes with it.
The workflows call six actions by a version tag, and a tag can be moved to other code. .github/workflows/actions.lock is GitHub's workflow dependency lockfile, generated with `gh actions-lock`: it records the commit each reference resolves to, and that commit is what runs. The tool also narrows each reference to the exact release it locked: actions/checkout@v7 becomes v7.0.1, softprops/action-gh-release@v3 becomes v3.0.4, msys2/setup-msys2@v2 becomes v2.34.0, and so on. The six commits are the ones the major tags point to today, so nothing that runs changes. There is no update bot in this repository, so after changing a uses: line, run `gh actions-lock` again and commit the result. The file is never edited by hand. The two container images (fedora:latest and opensuse/tumbleweed) are not covered: the lockfile records actions, not images.
Owner
|
There's enough PRs I'm behind on reviewing to avoid nitpicking the CI for now, especially if the main goal is some internet points as opposed to mitigating current threats. You can pester softprops and msys2 to provide immutable releases if that feels useful. |
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.
Hi Cimbali team, here's some CI hardening contribution:
None of the five workflows declares permissions, so jobs get the write-all default token, including the release draft jobs that run
softprops/action-gh-releaseandmsys2/setup-msys2on movable tags (tj-actions, CVE-2025-30066).Four commits:
contents: read, the three draft-release jobs keepcontents: write.PYMPRESS_ACTION_PATleaves the release steps: since 2.5.3 action-gh-release reads itstokeninput first (default: job token), so v3 already ignoresenv. I can pass it astoken:instead.actions.lock, GitHub's workflow dependency lockfile fromgh actions-lock, records the commit behind each tag. Tags become exact versions, same commits. Without an update bot, a changeduses:line needs a rerun. Say so and I drop it.Lint passed on my fork. Release, publish and docs workflows only run on your side. A tag-based allowed-actions policy needs
owner/action@*.Protecting
main(unprotected, a repository setting) is worth 13 points.Found and fixed with Plumber (D 31/100 before, up to B 89/100 after), reviewed and submitted by me.