github-actions-hardening

Reviews GitHub Actions workflows for script injection, privilege escalation, and supply-chain risks.

38.5k|4.9k|Updated Jun 11, 2025
One-click install
npx skills add https://github.com/github/awesome-copilot --skill github-actions-hardening
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: github-actions-hardening
Source: https://github.com/github/awesome-copilot/tree/main/skills/github-actions-hardening
Command: npx skills add https://github.com/github/awesome-copilot --skill github-actions-hardening

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

GitHub Actions workflows contain security risks that general code linters miss: ${{ }} expressions paste attacker-controlled text directly into shell commands, privileged triggers like pull_request_target can hand write tokens and secrets to outside contributors, and mutable action tags expose pipelines to supply-chain compromise. This Skill audits workflow files against the Actions-specific threat model and produces concrete fixes.

Core Features & Use Cases

  • Script Injection Detection: Identifies attacker-controllable ${{ }} contexts (issue titles, PR bodies, branch names) interpolated into run: steps and github-script blocks, with the safe env:-variable rewrite pattern.
  • Privilege and Trigger Analysis: Classifies triggers by trust level, flags pull_request_target/workflow_run workflows that execute fork code, and audits permissions: blocks for least-privilege GITHUB_TOKEN scoping.
  • Supply-Chain Hardening: Enforces SHA-pinning of third-party actions, Dependabot configuration for action updates, OIDC instead of long-lived cloud secrets, and safe artifact/cache handling.
  • Use Case: A maintainer asks "is this workflow safe?" before merging a contributor's CI change. The Skill maps triggers, hunts injection sinks, checks action pinning, and returns a severity-ranked report with before/after YAML fixes.

Quick Start

Ask the assistant to review the workflow file at .github/workflows/ci.yml for security issues and produce a hardening report.

Frequently Asked Questions about github-actions-hardening

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I secure a GitHub Actions workflow from script injection?

Script injection happens when attacker-controlled `${{ }}` expressions like github.event.issue.title are interpolated into run: steps. Pass the value through an env: variable and reference the quoted shell variable instead, so the data is never re-parsed as shell commands.

Why is pull_request_target dangerous in GitHub Actions?

pull_request_target runs with a read/write token and full secrets access, yet any fork author can trigger it. If the workflow checks out and executes the fork's code, that is remote code execution with a privileged token. Split into an unprivileged pull_request workflow and a privileged workflow_run consumer instead.

Should I pin GitHub Actions to a commit SHA or a version tag?

Third-party actions should be pinned to a full 40-character commit SHA because tags and branches are mutable and can be repointed to malicious code. Add a trailing comment with the version number and enable Dependabot for the github-actions ecosystem to keep pins updated.

What permissions should a GitHub Actions workflow have?

Set a top-level permissions: {} deny-all or contents: read default, then grant only the scopes each job needs, such as pull-requests: write on a commenting job. Missing permissions blocks inherit potentially broad repository defaults, and write-all should always be flagged.

Can I use OIDC instead of AWS secrets in GitHub Actions?

Yes, GitHub Actions supports OIDC to request short-lived cloud tokens instead of storing long-lived keys like AWS_ACCESS_KEY_ID. Grant id-token: write permission, configure the provider action such as aws-actions/configure-aws-credentials, and scope the cloud trust policy to the specific repo and branch.

Is a fork pull_request workflow dangerous if it runs untrusted code?

No, fork pull_request runs are safe by design because GitHub gives them a read-only token and no secrets. The danger arises when maintainers switch to pull_request_target to restore secrets, which then exposes everything to arbitrary contributors.