Repository navigation
Admin: scope the secrets and the token of the CI workflows, lock the actions - #10551
Open
Totara-thib wants to merge 4 commits into
Open
Totara-thib wants to merge 4 commits into
Totara-thib wants to merge 4 commits into
Conversation
build.yml called tests_decoratormode.yml and tests_servermode.yml with secrets: inherit, so every job of the test matrix could read all the repository secrets, the Docker Hub credentials included, while running the test suite. The only secret those two workflows use is CODECOV_TOKEN. They now declare that secret and build.yml passes it by name. It is marked optional, so runs from forks behave as before.
Nineteen workflows declared no permissions, so their 41 jobs ran with whatever the repository default grants. None of them writes anything with the job token: they check out, build, run the tests and upload artifacts. Each of them now declares contents: read. The release, data update, CodeQL and real AWS workflows already scope their jobs and are left alone.
actions/checkout leaves the job token in .git/config, where every later step can read it, and the test jobs then run the whole test suite next to it. Thirty-nine checkouts now set persist-credentials: false. That includes the eight data update workflows: create-pull-request sets up its own credentials for the push and does not use the stored ones. The release workflow keeps the default, it commits and pushes with git directly.
.github/workflows/actions.lock is GitHub's workflow dependency lockfile, generated with gh actions-lock v0.4.1. It records the commit each action resolves to, the ones an action calls in turn included, and the runner refuses a commit that is not the recorded one. Until now the actions were referenced by major tag, which the publisher can move, in the jobs that publish to PyPI, Docker Hub and GHCR and in the ones that assume the AWS role. The references become the exact release each tag points at today (actions/checkout@v7.0.1 and so on), so Dependabot keeps bumping them. pypa/gh-action-pypi-publish moves from the release/v1 branch to v1.14.3, the same commit. The run_moto_server action is referenced as $/ instead of ./ so the lockfile can cover the download-artifact it calls. After adding an action or changing a version, run gh actions-lock and commit the regenerated file.
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.
Hello, four commits, workflows hardening only:
build.ymlcalled the two unit test workflows withsecrets: inherit, so every test job could read all the repository secrets, Docker Hub credentials included. They read one,CODECOV_TOKEN, now passed by name.permissionsblock. None of their jobs writes with it, so they getcontents: read.create-pull-requestbrings its own credentials.release.ymlkeeps it, it pushes with git..github/workflows/actions.lock, GitHub's workflow dependency lockfile fromgh actions-lock, records the commit every action resolves to. The major tags become the exact releases they point at, and Dependabot updates both.pypa/gh-action-pypi-publishmoves fromrelease/v1tov1.14.3, the same commit, andrun_moto_serverbecomes$/so the lockfile covers it.Why: a moved tag reaches whatever its job holds (the tj-actions incident, CVE-2025-30066), here the PyPI, Docker Hub and GHCR publishing rights and the AWS role.
Found and fixed with Plumber (D 31/100 before, B 88/100 after), reviewed and submitted by me.