Skip to content
This repository was archived by the owner on Aug 31, 2026. It is now read-only.

Security: pin GitHub Actions to SHA hashes - #237

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

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

codacy-production Bot commented Mar 24, 2026 •

Copy link
Copy Markdown

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

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 f301426 to 517fb2f Compare March 24, 2026 18:04

@codacy-production codacy-production Bot left a comment

Copy link
Copy Markdown

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 correctly implements the security practice of pinning GitHub Actions to SHA hashes, there are critical issues that must be addressed before merging.

First, a high-severity security risk was identified in the auto-merge.yml workflow, where pull_request_target is used alongside a checkout of untrusted code. Second, the SHA pinned for actions/github-script in comment_issue.yml does not match the official release tag, which defeats the purpose of the security hardening. Finally, several actions use deprecated Node.js 12 runtimes that should be upgraded to maintain workflow stability.

About this PR

  • There are no automated tests or verification scripts provided to validate that the commit SHAs correspond correctly to the intended version tags. Incorrect SHAs can lead to workflow failures or the execution of unverified code.

Test suggestions

  • Verify that all GitHub Action steps in .github/workflows use commit SHAs instead of tags
  • Validate that the pinned SHAs correspond correctly to the version tags mentioned in comments
  • Verify that CI/CD workflows (auto-merge, issue creation/commenting) trigger and execute successfully with the new SHAs
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Verify that all GitHub Action steps in .github/workflows use commit SHAs instead of tags
2. Validate that the pinned SHAs correspond correctly to the version tags mentioned in comments
3. Verify that CI/CD workflows (auto-merge, issue creation/commenting) trigger and execute successfully with the new SHAs

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

Using pull_request_target while checking out the head branch of a pull request is a security risk as it grants untrusted code access to repository secrets. Furthermore, actions/checkout@v2 is deprecated (Node.js 12). It is recommended to upgrade to v4 and verify if the checkout step is strictly necessary for the auto-merge action to function.

Suggested change
- uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

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

The SHA 6e5ee1dc1cb3740e5e5e76ad668e3f526edbfe45 does not match the official v2.0.0 release tag (d125163f350c609fc22a912a20839e93b169b165). Additionally, actions/github-script@v2 is deprecated. Consider upgrading to v7 to ensure a supported runtime, though this will require minor script syntax updates (e.g., using github.rest.issues).

@DMarinhoCodacy
DMarinhoCodacy merged commit 5e8b196 into master Apr 8, 2026
5 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants