Skip to content

[FIX] pin all GitHub Actions to commit SHAs (CVE-2026-31976)#4

Open
dbollini wants to merge 1 commit intomainfrom
ta-66741-security-dib
Open

[FIX] pin all GitHub Actions to commit SHAs (CVE-2026-31976)#4
dbollini wants to merge 1 commit intomainfrom
ta-66741-security-dib

Conversation

@dbollini
Copy link
Copy Markdown

Pin remaining mutable action tags to exact commit SHAs to prevent supply
chain attacks via tag poisoning (CVE-2026-31976).

Previously pre-commit/action and actions/github-script were pinned,
but three actions still used mutable tags:

Action Before After
actions/checkout @v4 @34e114876b0b11c390a56381ad16ebd13914f8d5
actions/setup-python @v5 @a26af69be951a213d495a4c3e4e4022e16d87065
actions/cache @v4 @0057852bfaa89a56745cba8c7296529d2fc39830

All actions in the workflow are now pinned to a commit SHA. A compromised
or force-pushed tag can no longer silently inject malicious code into the
runner.

References:

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Pins previously mutable GitHub Actions references to commit SHAs and restructures the workflow to run unprivileged checks on pull_request while keeping privileged status reporting in pull_request_target.

Changes:

  • Pin actions/checkout, actions/setup-python, and actions/cache from version tags to commit SHAs.
  • Add a pull_request trigger and ensure pre-commit runs only in non-privileged contexts.
  • Replace the curl-based status creation with a github-script step that waits for the pre-commit check result, then creates a commit status.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +50 to +60
report-status:
# Solo corre en pull_request_target para crear el commit status
# NO hace checkout — no ejecuta código del PR
if: github.event_name == 'pull_request_target'
runs-on: ubuntu-latest
steps:
-
name: Create commit status
if: github.event_name == 'pull_request_target'
run: |
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.event.pull_request.head.sha }} \
-d '{"state":"${{ steps.precommit.outcome }}","context":"mergebot/pre-commit"}' \
--fail
name: Wait for pre-commit check
uses: actions/github-script@00f12e3e20659f42342b1c0226afda7f7c042325 # v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

report-status uses the Checks and Statuses APIs via GITHUB_TOKEN, but the workflow/job doesn't declare explicit permissions. If the repo/org default token permissions are read-only, this job will 403 when listing checks and/or creating commit statuses. Consider adding least-privilege permissions (e.g., checks: read and statuses: write) at the workflow or job level.

Copilot uses AI. Check for mistakes.
Comment on lines +12 to +15
pull_request:
branches:
- "1[8-9].0*"
- "[2-9][0-9].0*"
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This workflow file is marked as generated by Copier (DO NOT EDIT... Changes here will be lost). To avoid the SHA pinning and logic split being overwritten on the next template update, the corresponding change should also be applied in the upstream template source (or whichever generator inputs produce this file).

Copilot uses AI. Check for mistakes.
-
name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR title/description says all remaining GitHub Actions are pinned to SHAs, but this repo still has workflows using mutable tags (e.g., src/.github/workflows/cleaner.yml uses actions/github-script@v6). Either broaden the changes to cover the remaining workflows or narrow the PR title/description to reflect that only pre-commit.yml was fully pinned.

Copilot uses AI. Check for mistakes.
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.ref }}
ref: ${{ github.event.pull_request.head.sha || github.ref }}
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ref: ${{ github.event.pull_request.head.sha || github.ref }} will be evaluated on push events too, where github.event.pull_request is undefined, which can cause the workflow to fail during expression evaluation. Use the same short-circuit pattern as before (guard with github.event_name), or use github.sha for push and github.event.pull_request.head.sha for pull_request.

Suggested change
ref: ${{ github.event.pull_request.head.sha || github.ref }}
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}

Copilot uses AI. Check for mistakes.
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