Skip to content

Security: pin GitHub Actions to SHA hashes#353

Merged
DMarinhoCodacy merged 1 commit into
masterfrom
security/pin-actions-to-sha
Apr 8, 2026
Merged

Security: pin GitHub Actions to SHA hashes#353
DMarinhoCodacy merged 1 commit into
masterfrom
security/pin-actions-to-sha

Conversation

@jorgebraz
Copy link
Copy Markdown

Pins all GitHub Actions from mutable tags/branches to immutable SHA hashes.

This prevents supply chain attacks like the TeamPCP/Trivy incident (March 2026), where attackers force-pushed tags to point at malicious commits.

Auto-generated by the Codacy security audit script.

@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented Mar 24, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes. Give us feedback

Copy link
Copy Markdown

@codacy-production codacy-production Bot 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

This pull request is currently not up to standards. While the objective is to enhance security by pinning GitHub Actions to immutable SHA hashes, the current implementation introduces a critical security vulnerability in the auto-merge.yml workflow by combining pull_request_target with a checkout of the PR head. This pattern can allow untrusted code to access repository secrets. Additionally, the implementation is incomplete: the actions/checkout pinning uses an outdated SHA (v2.0.0 instead of v2.7.0), and the ahmadnassri/action-dependabot-auto-merge action remains unpinned. These issues must be addressed to fulfill the security goals of the PR.

About this PR

  • The objective to pin all GitHub Actions to SHA hashes has not been fully met. One action in .github/workflows/auto-merge.yml remains unpinned, and another has been pinned to an older version than previously used, potentially introducing regressions.

Test suggestions

  • Verify the 'auto-merge' workflow still triggers and executes successfully with pinned actions.
  • Verify the 'comment_issue' workflow still triggers and executes successfully with pinned actions.
  • Verify the 'create_issue' workflow still triggers and executes successfully with pinned actions.
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Verify the 'auto-merge' workflow still triggers and executes successfully with pinned actions.
2. Verify the 'comment_issue' workflow still triggers and executes successfully with pinned actions.
3. Verify the 'create_issue' workflow still triggers and executes successfully with pinned actions.

🗒️ Improve review quality by adding custom instructions

if: github.actor == 'dependabot[bot]'
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 HIGH RISK

Critical Security Risk: This workflow uses pull_request_target while checking out the head of the incoming pull request, which allows untrusted code to run with access to repository secrets.

Additionally, the SHA ee0669bd1cc54295c223e0bb666b733df41de1c5 pins the action to v2.0.0, but the rolling v2 tag previously used resolves to v2.7.0. This downgrade may re-introduce bugs. Suggest pinning to the latest SHA:

Suggested change
- uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2
- uses: actions/checkout@f404e92900e2632f5255d1d573f51ba6f2a06a2e # v2.7.0

See Issue in Codacy

Comment thread .github/workflows/auto-merge.yml Outdated
- uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: ahmadnassri/action-dependabot-auto-merge@v2
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 MEDIUM RISK

The action ahmadnassri/action-dependabot-auto-merge@v2 is still using a mutable tag. It must be updated to an immutable SHA hash to satisfy the security requirements of this pull request.

Replaces mutable tag/branch references with immutable SHA hashes
to prevent supply chain attacks (ref: TeamPCP/Trivy March 2026).

Actions left as tags: 0
@jorgebraz jorgebraz force-pushed the security/pin-actions-to-sha branch from 5861172 to c018abd Compare March 24, 2026 18:03
@DMarinhoCodacy DMarinhoCodacy merged commit 8fa4ec5 into master Apr 8, 2026
5 checks passed
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