Github actions hardening

From github/awesome-copilot · View interactive version

Github actions hardening is an AI agent skill from the GitHub repository github/awesome-copilot. Security hardening reviewer for GitHub Actions workflow files (.github/workflows/*.yml). Reasons about the Actions threat model that pattern matchers and general code linters miss — untrusted-input script injection, privileged triggers running fork code, mutable action references, and over-scoped to

How to use this skill

Skill file

GitHub Actions Hardening

A focused security reviewer for GitHub Actions workflows. It reasons about the Actions-specific

threat model — where trust boundaries live in trigger types, token scopes, and string

interpolation — rather than the application-code vulnerabilities a general security scanner looks

for. Most workflow risks are invisible to language linters because the dangerous code is the YAML

itself and the way GitHub expands ${{ }} expressions into a shell before your script runs.

When to Use This Skill

Use this skill when the request involves:

The Core Insight

In a workflow, *${{ <expr> }} is expanded by the runner into the script before* the shell

executes it.** So a step like:

- run: echo "Title: ${{ github.event.issue.title }}"

is not passing a variable — it is *pasting attacker-controlled text directly into your shell

command*. An issue titled "; <attacker-command> # is concatenated into the script and executed.

This single mechanism is the most common real-world Actions vulnerability, and models routinely

generate it. Treat every

${{ }} that contains data an outside contributor can influence as a code-injection sink.

Execution Workflow

Follow these steps in order for every workflow reviewed.

Step 1 — Map the Triggers and Trust Level

Read every on: trigger and classify the workflow's privilege:

base repository with a read/write token and full access to secrets, but can be

triggered by outside contributors. These are the dangerous triggers.

Read references/triggers-and-privilege.md for the full trust matrix.

Step 2 — Hunt for Script Injection

For every run: block, every script: in actions/github-script, and every input to a custom

action, list the ${{ }} expressions and check whether any resolve to attacker-controllable data.

High-risk contexts include:

Read references/injection.md for the complete sink list and the safe-pattern fixes.

Step 3 — Check Privileged Triggers Don't Execute Untrusted Code

If a pull_request_target or workflow_run workflow checks out PR/fork code

(ref: ${{ github.event.pull_request.head.sha }}) and then runs it (build, test, install

scripts, npm install with lifecycle scripts, etc.), that is remote code execution against a

privileged token. Flag it as CRITICAL. The safe pattern is to split into two workflows: an

unprivileged pull_request workflow that runs the untrusted code, and a privileged

workflow_run workflow that only consumes its results.

Step 4 — Audit `permissions:`

be read/write to everything. Flag it.

per job (e.g. pull-requests: write only on the job that comments).

Read references/permissions-and-tokens.md for the per-scope guidance and OIDC setup.

Step 5 — Audit Action References (Supply Chain)

For every uses::

commit SHA, not a tag or branch. Tags and branches are mutable; a compromised upstream action

can rewrite v1 to malicious code that runs with your token and secrets.

you at any time.

Read references/supply-chain.md for pinning, Dependabot for actions, and artifact/cache risks.

Step 6 — Check Secret and Output Handling

secrets.

variables or step outputs — use the random-delimiter heredoc form and never write raw user input.

job later runs untrusted code.

Step 7 — Produce the Report

Output findings using the format in references/report-format.md: a severity summary table first,

then grouped findings with file, the exact offending YAML, the risk in plain English, and a

concrete before/after fix. Never auto-apply changes — present them for review.

Severity Guide

| Severity | Meaning | Example |

| --- | --- | --- |

| 🔴 CRITICAL | Token/secret theft or RCE reachable by an outside contributor | pull_request_target checking out and running fork code; ${{ github.event.* }} in a run: on a privileged trigger |

| 🟠 HIGH | Exploitable supply-chain or scope problem | Third-party action on a mutable tag/branch; write-all permissions; injection sink on issue_comment |

| 🟡 MEDIUM | Risk under conditions or chaining | Missing permissions: block; secret reachable by a non-fork PR author |

| 🔵 LOW | Hardening gap, low direct risk | First-party action not SHA-pinned; persist-credentials left default on a non-privileged job |

| ⚪ INFO | Observation, not a vulnerability | Version comment missing next to a pinned SHA |

Output Rules

no secrets and a read-only token. Reserve CRITICAL for the privileged triggers.

Reference Files

Load these as needed:

and workflow_run are privileged, and the two-workflow safe pattern.

env:-variable safe pattern for each sink (run, github-script, action inputs).

recipes per job type, and OIDC for cloud auth instead of long-lived secrets.

artifact and cache poisoning across workflow_run, and self-hosted runner exposure.

remediation blocks.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.