Skip to content

Security: pin GitHub Actions to SHA hashes#85

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

Security: pin GitHub Actions to SHA hashes#85
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.

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

Actions left as tags: 0
@codacy-production
Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Alerts:

"

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 review identifies critical security risks and implementation gaps. Specifically, the workflows contain script injection vulnerabilities where GitHub expressions are interpolated directly into JavaScript, which should be refactored to use environment variables. Furthermore, while the PR intends to pin actions to SHAs, the implementation appears incomplete across the specified workflows. There is also a maintenance concern regarding the use of the deprecated Node 12 runtime for several actions, which will eventually lead to workflow failures. These issues should be addressed to ensure the security and longevity of the CI/CD pipeline.

About this PR

  • The primary objective of pinning all GitHub Actions to immutable SHA hashes appears to be missing or incomplete for the targeted workflow files (.github/workflows/comment_issue.yml, .github/workflows/create_issue.yml, and .github/workflows/create_issue_on_label.yml).
  • A recurring security pattern was identified: several workflows are directly interpolating GitHub expressions into JavaScript strings. This creates a risk of code injection. Please ensure all workflow scripts access dynamic data through the env block and process.env rather than direct interpolation.

Test suggestions

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

🗒️ Improve review quality by adding custom instructions

- name: Add comment after sync
if: github.event.label.name == env.JIRA_ISSUE_LABEL
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 step directly interpolates variables into the script, creating a potential injection vulnerability. Move ${{ steps.create_jira_issue.outputs.issue }} and ${{ secrets.JIRA_BASE_URL }} to the step's env block and access them via process.env in the script.

Try running the following prompt in your coding agent:

In .github/workflows/create_issue_on_label.yml, refactor the 'Add comment after sync' step to pass steps.create_jira_issue.outputs.issue and secrets.JIRA_BASE_URL via the env block, then update the script to access them using process.env.

- name: Add comment after sync
if: env.JIRA_CREATE_ISSUE_AUTO == 'true'
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 script in this step directly interpolates ${{ steps.create_jira_issue.outputs.issue }} and ${{ secrets.JIRA_BASE_URL }} into the code. This is a security risk. These values should be passed via the env block and accessed using process.env in the script.

Try running the following prompt in your coding agent:

In .github/workflows/create_issue.yml, refactor the 'Add comment after sync' step to pass steps.create_jira_issue.outputs.issue and secrets.JIRA_BASE_URL via the env block, then update the script to access them using process.env.

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

Suggestion: These actions are pinned to versions that run on Node 12, which is deprecated and scheduled for removal from GitHub Actions runners. To ensure long-term maintenance and security, consider upgrading to the latest major versions (e.g., actions/github-script@v7, atlassian/gajira-login@v3) while pinning to their respective SHAs.

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