Description
An external GitHub action’s tag or branch can move to another commit. A full-length commit SHA fixes the version of the action’s repository code that runs.
Potential impact
A workflow can run unreviewed code with its CI permissions even though the workflow file has not changed. Earlier runs can also be harder to audit.
Remediation
Pin external uses: references to the full SHA of a commit you reviewed in the action’s original repository. Check workflow permissions and any dependencies the action downloads at run time. To apply a security update, review and test the change, then replace the SHA.
Examples
These excerpts use a historical pull-request comment action. For deployment, choose a supported version and configure its message input and token permissions.
Before
name: ci
on:
pull_request:
jobs:
comment:
runs-on: ubuntu-latest
steps:
- name: Add comment
uses: thollander/actions-comment-pull-request@v2
After
name: ci
on:
pull_request:
jobs:
comment:
runs-on: ubuntu-latest
steps:
- name: Add comment
uses: thollander/actions-comment-pull-request@b07c7f86be67002023e6cb13f57df3f21cdd3411
The second workflow selects a specific commit in place of the v2 tag.