MR
Mayur Rathi
@github
⭐ 34.1k GitHub stars

Github-Actions-Hardening

Github-Actions-Hardening is an code AI skill with a core value of Security hardening reviewer for GitHub Actions workflow files (. It helps developers solve real-world problems in the code domain, boosting efficiency, automating repetitive tasks, and optimizing workflows.

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 sc

Last verified on: 2026-06-28
mkdir -p ./skills/github-actions-hardening && curl -sfL https://raw.githubusercontent.com/github/awesome-copilot/main/skills/github-actions-hardening/SKILL.md -o ./skills/github-actions-hardening/SKILL.md

Run in terminal / PowerShell. Requires curl (Unix) or PowerShell 5+ (Windows).

Skill Content

# 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:


* Reviewing, auditing, or hardening any file under `.github/workflows/`

* Authoring a new workflow and wanting it secure by default

* A workflow that uses `pull_request_target`, `workflow_run`, or `issue_comment` triggers

* Questions about `GITHUB_TOKEN` permissions or the `permissions:` key

* Pinning actions to commit SHAs vs tags vs branches

* Handling untrusted input (issue titles, PR bodies, branch names, commit messages) in `run:` steps

* OIDC / cloud authentication from Actions, or secret handling in CI

* Self-hosted runners on public repositories

* Any request like "is this workflow safe?", "secure my CI", or "review this GitHub Action"


The Core Insight


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

executes it.** So a step like:


yaml
- 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:


* `push`, `pull_request` (from same repo) → runs with the contributor's own trust

* `pull_request` from a **fork** → runs with a **read-only** token, **no secrets** (safe by design)

* `pull_request_target`, `workflow_run`, `issue_comment`, `issues` → run in the context of the

**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:


* `github.event.issue.title`, `github.event.issue.body`

* `github.event.pull_request.title`, `github.event.pull_request.body`, `.head.ref`, `.head.label`

* `github.event.comment.body`, `github.event.review.body`

* `github.event.pages.*.page_name`, `github.event.commits.*.message`, `github.event.head_commit.*`

* `github.head_ref` and any `github.event.*` field a fork author can set


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:`


* If there is **no** `permissions:` block, the workflow inherits the repository default, which may

be read/

🎯 Best For

  • Engineering teams doing code reviews
  • Open source maintainers
  • Security auditors
  • DevSecOps teams
  • Compliance officers

💡 Use Cases

  • Reviewing pull requests for security vulnerabilities
  • Checking code style consistency
  • Auditing dependencies for known CVEs
  • Scanning API endpoints for auth gaps

📖 How to Use This Skill

  1. 1

    Install the Skill

    Copy the install command from the Terminal tab and run it. The SKILL.md file downloads to your local skills directory.

  2. 2

    Load into Your AI Assistant

    Open GitHub Copilot or Claude and reference the skill. Paste the SKILL.md content or use the system prompt tab.

  3. 3

    Apply Github-Actions-Hardening to Your Work

    Open your project in the AI assistant and ask it to apply the skill. Start with a small module to verify the output quality.

  4. 4

    Review and Refine

    Review AI suggestions before committing. Run tests, check for regressions, and iterate on the skill output.

❓ Frequently Asked Questions

Does this skill check for OWASP Top 10?

Security-focused review skills often include OWASP checks. Check the skill content for specific vulnerability categories covered.

Can this replace a dedicated SAST tool?

AI-based security review is complementary to SAST tools. Use it as a first-pass filter, not a replacement.

Is Github-Actions-Hardening compatible with Cursor and VS Code?

Yes — this skill works with any AI coding assistant including Cursor, VS Code with Copilot, and JetBrains IDEs.

Do I need specific dependencies for Github-Actions-Hardening?

Check the install command and Works With section. Most code skills only require the AI assistant and your codebase.

How do I install Github-Actions-Hardening?

Copy the install command from the Terminal tab and run it. The skill downloads to ./skills/github-actions-hardening/SKILL.md, ready to use.

⚠️ Common Mistakes to Avoid

Blindly accepting AI suggestions

Always verify AI-generated review comments. Some suggestions may not apply to your specific codebase conventions.

Only scanning surface-level issues

Deep security review requires understanding your app architecture, not just regex patterns.

Skipping validation

Always test AI-generated code changes, even for simple refactors.

Missing dependency updates

Check if the skill requires updated dependencies or new packages.

🔗 Related Skills