Aller au contenu
Skillpedia
Sécurité40k · #7225

github-actions-hardening

Ce qu’il fait

Cet outil examine la sécurité des fichiers d'automatisation GitHub Actions. Il vérifie des risques précis que les outils de sécurité courants ne détectent pas, comme l'injection de code et l'utilisation de permissions dangereuses.

Quand l’utiliser

  • ✓Lorsque vous demandez de vérifier la sécurité d'un fichier d'automatisation GitHub Actions.
  • ✓Lorsque vous créez une nouvelle automatisation et souhaitez qu'elle soit sécurisée dès le départ.
  • ✓Lorsqu'une automatisation utilise des déclencheurs pouvant être activés par du code externe.

Lien du skill

https://github.com/github/awesome-copilot/blob/main/skills/github-actions-hardening/SKILL.md

Copiez-le et collez-le dans votre IA (Claude, ChatGPT ou Cursor) en lui demandant de suivre les instructions.

Comment l’utiliser

Le plus simple : copiez le message et collez-le dans votre IA. Elle lit le skill et suit les instructions.

Message prêt à coller

Utilise ce skill pour m’aider : https://github.com/github/awesome-copilot/blob/main/skills/github-actions-hardening/SKILL.md Lis le fichier SKILL.md de ce lien et suis ses instructions pour ma tâche.
Envie que votre IA trouve seule des skills comme celui-ci ?Installez le MCP gratuit de Skillpedia : une ligne, et elle cherche parmi 15 000+ skills avant chaque tâche.Installer en 1 minute →

Exemple de demande à votre IA

“Vérifie la sécurité de ce fichier de workflow GitHub Actions : [collez le code ici]”

5 nouveaux skills par semaine. 1 minute de lecture.

Comment ça marche

L'outil analyse les déclencheurs de l'automatisation pour comprendre qui peut la lancer et avec quelles permissions. Il recherche ensuite les endroits où des données externes pourraient être insérées directement dans des commandes, ce qui peut être dangereux.

Contenu technique (SKILL.md original)

Texte original de l’auteur, en anglais, directement depuis GitHub.

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:

- 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/write to everything. Flag it.
  • Recommend a top-level permissions: {} (deny-all) or contents: read, then grant the minimum per job (e.g. pull-requests: write only on the job that comments).
  • Flag any permissions: write-all or broad write scopes that the steps don't actually need.

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

Step 5 — Audit Action References (Supply Chain)

For every uses::

…

Questions fréquentes

Que sont les « déclencheurs privilégiés » ?

Ce sont des événements qui lancent l'automatisation et qui peuvent être déclenchés par des personnes extérieures à votre projet, par exemple dans des « pull requests » provenant de projets que vous ne contrôlez pas. Ils peuvent avoir accès à des informations sensibles.

Qu'est-ce que l'« injection de script » dans ce contexte ?

Il s'agit de l'insertion de code malveillant dans un champ utilisé par l'automatisation, comme le titre d'une « pull request », et de l'exécution de ce code comme s'il faisait partie de votre automatisation.

Pourquoi utiliser un « SHA de commit » plutôt qu'un « tag » ou une « branche » pour référencer des actions ?

Les tags et les branches peuvent être modifiés après leur création. Utiliser un « SHA de commit » (un identifiant unique et figé) garantit que vous utilisez toujours la version exacte de l'action qui a été vérifiée, ce qui empêche son remplacement par une version malveillante.

Détails

Description originale de l’auteur

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 tokens. Use this skill when asked to review, audit, harden, or secure a GitHub Actions workflow, when

repo: github/awesome-copilot

Popularité

Étoiles GitHub
40k
Position au classement
#7225
Licence
MIT
Mis à jour
15/10/2026

Ce skill vous est-il utile ?

0

Connectez-vous pour voter.

Commentaires

  • …

Autres skills de ce dépôt

Skills similaires