Skip to content

Security: pin GitHub Actions to SHA hashes#281

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

Security: pin GitHub Actions to SHA hashes#281
DMarinhoCodacy merged 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

Codacy analysis indicates this PR is not up to standards, primarily due to a high-severity security vulnerability. While the PR successfully pins most GitHub Actions to SHA hashes as intended, it misses one specific action in the auto-merge.yml workflow, leaving a gap in the supply chain security hardening.

More critically, the auto-merge.yml workflow uses a high-risk combination of pull_request_target and manual checkout of untrusted PR code, which exposes the repository to potential secret exfiltration or unauthorized changes. Additionally, the comment_issue.yml workflow uses a deprecated Node 12 runtime and contains script injection vulnerabilities. These security and compliance issues should be resolved before merging.

About this PR

  • The implementation is incomplete. While the PR title and description aim to pin GitHub Actions to SHA hashes, ahmadnassri/action-dependabot-auto-merge@v2 in .github/workflows/auto-merge.yml was overlooked. To achieve the security benefits of immutable references, all external actions must be pinned.

Test suggestions

  • Verify 'actions/checkout' is pinned to a SHA hash with version comment in auto-merge.yml
  • Verify 'actions/github-script' is pinned to a SHA hash with version comment across all workflows
  • Verify 'atlassian/gajira-login' is pinned to a SHA hash with version comment across all workflows
  • Verify 'atlassian/gajira-create' is pinned to a SHA hash with version comment in creation workflows
  • Verify 'atlassian/gajira-comment' is pinned to a SHA hash with version comment in comment_issue.yml
  • Verify 'ahmadnassri/action-dependabot-auto-merge' is pinned to a SHA hash in auto-merge.yml
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Verify 'ahmadnassri/action-dependabot-auto-merge' is pinned to a SHA hash in auto-merge.yml

🗒️ 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

The combination of pull_request_target and checking out the PR head is a security risk. It allows potentially untrusted code to run with the permissions of the base repository (privileged GITHUB_TOKEN). Since this is for auto-merging, consider using GitHub's native auto-merge feature which can be triggered via a standard pull_request event and doesn't require checking out the PR code manually.

Try running the following prompt in your IDE agent:

Refactor the auto-merge workflow to use the native GitHub CLI gh pr merge --auto command within a standard pull_request trigger to eliminate the security risks associated with pull_request_target and head checkout.

See Issue in Codacy

if: env.JIRA_CREATE_COMMENT_AUTO == 'true'
id: github_issue_type
uses: actions/github-script@v2.0.0
uses: actions/github-script@6e5ee1dc1cb3740e5e5e76ad668e3f526edbfe45 # v2.0.0
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

This action is pinned to an old version (v2.0.0) that uses the deprecated Node 12 runtime. Upgrade to v7 to ensure compatibility with modern GitHub runners. Additionally, avoid using ${{ ... }} interpolation inside the script block as it creates a risk of script injection; use environment variables and process.env instead.

Try running the following prompt in your coding agent:

Refactor the actions/github-script steps in .github/workflows/comment_issue.yml to use environment variables for accessing GitHub context data instead of using inline interpolation.

- 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

Suggestion: The action ahmadnassri/action-dependabot-auto-merge@v2 is still using a mutable tag. To satisfy the security hardening requirements and maintain consistency with the rest of this PR, please pin it to a specific SHA hash.

Try running the following prompt in your IDE agent:

Find the specific SHA hash for ahmadnassri/action-dependabot-auto-merge@v2 and update line 14 in .github/workflows/auto-merge.yml to use it instead of the version tag.

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 7e8c70f to f5c14b5 Compare March 24, 2026 18:04
@DMarinhoCodacy DMarinhoCodacy merged commit 51fad06 into master Apr 8, 2026
7 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