Skip to content

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
Cimbali:mainfrom
Totara-thib:release-workflow-tokens
Closed

Totara-thib wants to merge 4 commits into
Cimbali:mainfrom
Totara-thib:release-workflow-tokens

Conversation

@Totara-thib

Copy link
Copy Markdown

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-release and msys2/setup-msys2 on movable tags (tj-actions, CVE-2025-30066).

Four commits:

  • Every workflow starts from contents: read, the three draft-release jobs keep contents: write.
  • PYMPRESS_ACTION_PAT leaves the release steps: since 2.5.3 action-gh-release reads its token input first (default: job token), so v3 already ignores env. I can pass it as token: instead.
  • Eight checkouts stop keeping the job token. The docs deploy keeps it to push. The PR lint's base-branch fetch needs no credentials.
  • actions.lock, GitHub's workflow dependency lockfile from gh actions-lock, records the commit behind each tag. Tags become exact versions, same commits. Without an update bot, a changed uses: 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.

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

Cimbali commented Nov 25, 2026

Copy link
Copy Markdown
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.

@Cimbali Cimbali closed this Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants