Skip to content

Security: pin GitHub Actions to SHA hashes#4960

Open
jorgebraz wants to merge 1 commit intomasterfrom
security/pin-actions-to-sha
Open

Security: pin GitHub Actions to SHA hashes#4960
jorgebraz wants to merge 1 commit intomasterfrom
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

While this PR moves toward better security by pinning most actions to SHA hashes, it is currently incomplete and contains a high-severity security risk. The ahmadnassri/action-dependabot-auto-merge action was missed in the conversion, contradicting the PR's stated intent. More importantly, the auto-merge.yml workflow uses the pull_request_target trigger combined with a checkout of the head branch; this pattern allows untrusted code from forks to execute in a privileged environment with repository secrets. These security gaps should be resolved before merging.

About this PR

  • The PR does not fully satisfy its security objective because 'ahmadnassri/action-dependabot-auto-merge@v2' in '.github/workflows/auto-merge.yml' remains pinned to a mutable tag rather than a SHA hash.

Test suggestions

  • Verify that all actions in .github/workflows/auto-merge.yml are pinned to commit SHAs.
  • Verify that all actions in .github/workflows/comment_issue.yml are pinned to commit SHAs.
  • Verify that all actions in .github/workflows/create_issue.yml are pinned to commit SHAs.
  • Verify that all actions in .github/workflows/create_issue_on_label.yml are pinned to commit SHAs.
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Verify that all actions in .github/workflows/auto-merge.yml are pinned to commit SHAs.
2. Verify that all actions in .github/workflows/comment_issue.yml are pinned to commit SHAs.
3. Verify that all actions in .github/workflows/create_issue.yml are pinned to commit SHAs.
4. Verify that all actions in .github/workflows/create_issue_on_label.yml are pinned to commit SHAs.

🗒️ Improve review quality by adding custom instructions

Comment on lines +11 to 13
- uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2
with:
ref: ${{ github.event.pull_request.head.sha }}
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

This workflow block presents two significant security issues:

  1. Incomplete SHA Pinning: The action ahmadnassri/action-dependabot-auto-merge@v2 (line 14) is still using a mutable version tag, which contradicts the security goals of this PR. It should be updated to a specific commit SHA.
  2. Privileged Execution Risk: Using pull_request_target while checking out the pull request's head branch (lines 11-13) is a high-severity vulnerability. It allows potentially untrusted code from a fork to run with write permissions and access to repository secrets.

Actionable Suggestions:

  • Update the auto-merge action to a SHA hash. Prompt for coding agent: Find the latest commit SHA for ahmadnassri/action-dependabot-auto-merge@v2 and update the uses statement in .github/workflows/auto-merge.yml to use that SHA, including the version as a comment (e.g., # v2).
  • Verify if actions/checkout is necessary. If the action only needs GITHUB_TOKEN for API calls, remove the checkout step and the ref parameter to eliminate the risk of executing untrusted code.

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 de3603c to 08611ff Compare March 24, 2026 18:02
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.

1 participant