fix: harden GitHub Actions workflows#4553
Merged
Merged
Conversation
…on attacks - pin all third-party actions to commit SHAs instead of mutable tags - add explicit minimal permissions blocks to all workflows - move user-controlled GitHub context values to env vars to prevent script injection
Contributor
|
📊 Quantitative test results for language: |
M4tteoP
approved these changes
Mar 16, 2026
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.
what
permissionsblocks to all workflows missing themgithub.base_ref,github.head_ref,github.event.head_commit.message) from inline${{ }}interpolation toenv:blocks to prevent script injection inlint.yamlwhy
several workflows had security gaps that could be exploited by bots or malicious contributors:
gregsdennis/dependencies-action@main,thollander/actions-comment-pull-request@v3, andactions/cache@v4were pinned to mutable refs (branches/tags) instead of immutable commit SHAs. a compromised upstream could inject arbitrary code into CI runstest.yml,lint.yaml, andstale.ymlrelied on defaultGITHUB_TOKENpermissions (which can be broad depending on org settings) instead of declaring the minimum requiredlint.yamlinterpolated user-controlled values (github.head_ref,github.event.head_commit.message) directly intorun:shell scripts via${{ }}, which expands before the shell sees the value — a crafted branch name or commit message could break out of quoting and execute arbitrary commandsrefs