Skip to content

- Harden GitHub Actions workflows with minimum required permissions#56

Merged
mtracz merged 2 commits intomainfrom
copilot/validate-github-actions-workflows
Apr 1, 2026
Merged

- Harden GitHub Actions workflows with minimum required permissions#56
mtracz merged 2 commits intomainfrom
copilot/validate-github-actions-workflows

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 25, 2026

All workflows were missing explicit permissions declarations, meaning each job ran with the default broad GITHUB_TOKEN scopes. Additionally, test-bash-script.yml had a shell injection vector via direct ${{ github.head_ref }} interpolation in a run step.

Changes

Permissions (all workflows)

  • Set permissions: {} at workflow level (deny-all baseline)
  • Grant only the minimum required permission at job level:
    • pull-requests: readcheck-pr-title.yml (API read of PR title)
    • contents: read — all other workflows (actions/checkout)

This applies to workflows in both .github/workflows/ and src/.github/workflows/.

Shell injection fix (test-bash-script.yml)

A branch name like $(malicious) or ; cmd would execute in the runner shell:

# Before — unsafe: expression expands before shell sees it
run: ./init.sh "TestApp" "TestNamespace" "${{ github.head_ref }}" ...

# After — safe: value passed via env, expanded by shell as a variable
env:
  BRANCH_NAME: ${{ github.head_ref }}
run: ./init.sh "TestApp" "TestNamespace" "$BRANCH_NAME" ...

📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

@mtracz mtracz marked this pull request as ready for review March 25, 2026 19:25
@mtracz mtracz requested a review from a team as a code owner March 25, 2026 19:25
KarolZygadlo
KarolZygadlo previously approved these changes Mar 26, 2026
@mtracz
Copy link
Copy Markdown
Member

mtracz commented Mar 26, 2026

@copilot you forgot about workflows in src/.github/workflows dir. Fix it.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 26, 2026

@copilot you forgot about workflows in src/.github/workflows dir. Fix it.

Fixed in e9c346e — applied the same permissions: {} (deny-all) at workflow level and minimum job-level permissions to all three workflows in src/.github/workflows/:

  • check-pr-title.ymlpull-requests: read
  • test-and-lint-js.ymlcontents: read
  • test-and-lint-php.ymlcontents: read

@mtracz mtracz requested a review from KarolZygadlo March 26, 2026 11:11
Copilot AI requested a review from mtracz March 26, 2026 11:13
@mtracz mtracz requested review from a team, Blusia and kamilpiech97 March 26, 2026 11:17
@mtracz mtracz merged commit 0d29bdc into main Apr 1, 2026
4 checks passed
@mtracz mtracz deleted the copilot/validate-github-actions-workflows branch April 1, 2026 10:27
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.

4 participants