Skip to content

Security: pin GitHub Actions to SHA hashes#29

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

Security: pin GitHub Actions to SHA hashes#29
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 PR successfully addresses the security requirement of pinning GitHub Actions to immutable commit SHAs across all workflows. However, the review identified several critical issues within the modified files that should be addressed before merging to ensure reliability and full security hardening.

Major concerns include asynchronous API calls that are not awaited, which will cause non-deterministic behavior in issue syncing, and a regex implementation lacking null-safety. Additionally, while the PR improves security by pinning actions, the workflows continue to use direct expression interpolation in github-script blocks, which remains a vector for injection attacks. Addressing these logic and security gaps is recommended to complement the pinning of actions.

About this PR

  • A recurring pattern of missing await keywords on asynchronous Octokit calls was found across all three workflow files. This will lead to race conditions where actions terminate before API requests complete.
  • While pinning actions to SHAs is a significant security improvement, several workflows continue to use direct expression interpolation (${{ ... }}) inside github-script blocks. This pattern is vulnerable to script injection if the context values are manipulated. It is highly recommended to transition these to environment variables as part of this security-focused PR.

Test suggestions

  • Verify all instances of 'actions/github-script' are pinned to SHA 6e5ee1dc1cb3740e5e5e76ad668e3f526edbfe45
  • Verify all instances of 'atlassian/gajira-login' are pinned to SHA 90a599561baaf8c05b080645ed73db7391c246ed
  • Verify 'atlassian/gajira-comment' is pinned to SHA 8ec356b5df49f1325653db7ee2da2b59a1d78203
  • Verify all instances of 'atlassian/gajira-create' are pinned to SHA c0a9c69ac9d6aa063fed57201e55336ada860183

🗒️ Improve review quality by adding custom instructions

- name: Change Title
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

Asynchronous API calls should be awaited to ensure the action does not terminate prematurely. Add await to the github.issues.update and github.issues.createComment calls.

Try running the following prompt in your coding agent:

Add await to all asynchronous GitHub API calls in .github/workflows/create_issue_on_label.yml.

- name: Update GitHub issue
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 asynchronous calls to github.issues.update and github.issues.addLabels are not awaited. This can cause the action to finish before the API requests are completed. Add the await keyword to all asynchronous Octokit calls.

Try running the following prompt in your coding agent:

Update the github-script blocks in .github/workflows/create_issue.yml to await all github.issues API calls.

if: env.JIRA_CREATE_COMMENT_AUTO == 'true' && env.GITHUB_ISSUE_TYPE == 'issue' && env.GITHUB_ISSUE_HAS_JIRA_ISSUE_LABEL == 'true'
id: extract_jira_number
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 regex match result is accessed directly without a null check. This will cause the workflow to fail if the issue title doesn't match the Jira pattern (e.g. for bot comments or unrelated issues). Consider adding a check for the match result before accessing index 1.

Try running the following prompt in your coding agent:

In .github/workflows/comment_issue.yml, update the Extract Jira number script to safely handle cases where the regex match might be null.

- 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

Suggestion: Avoid direct interpolation in the script at line 81. Use environment variables to pass steps.create_jira_issue.outputs.issue and secrets.JIRA_BASE_URL into the script context.

Try running the following prompt in your IDE agent:

In .github/workflows/create_issue_on_label.yml, update the Add comment after sync step to pass steps.create_jira_issue.outputs.issue and secrets.JIRA_BASE_URL as environment variables.

- 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

Suggestion: Directly interpolating values into the script string (line 89) is less secure than using environment variables. To follow best practices and maintain consistency with other parts of the workflow, pass these values via the env block.

Try running the following prompt in your IDE agent:

In .github/workflows/create_issue.yml, update the Add comment after sync step to pass steps.create_jira_issue.outputs.issue and secrets.JIRA_BASE_URL as environment variables.

if: env.JIRA_CREATE_COMMENT_AUTO == 'true'
id: github_issue_has_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

Suggestion: Accessing github.event.issue.labels via direct interpolation is risky. It should be passed via env to avoid potential code injection.

Try running the following prompt in your IDE agent:

In .github/workflows/comment_issue.yml, update the Check if GitHub Issue has JIRA_ISSUE_LABEL step to pass github.event.issue.labels as a JSON string in an environment variable, then parse it using JSON.parse(process.env.LABELS) inside the script.

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: While pinning actions to SHAs is a great security improvement, the script on line 26 still uses direct interpolation of the GitHub context. This can be vulnerable to injection attacks if the context values (like issue data) are manipulated. Use environment variables instead.

Try running the following prompt in your IDE agent:

In .github/workflows/comment_issue.yml, update the Check GitHub Issue type step to pass github.event.issue.pull_request as an environment variable and use process.env in the script to check for its existence.

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