Chuyển đến nội dung
Skillpedia
Bảo mật40k · #7225

github-actions-hardening

Skill này làm gì

Công cụ này rà soát bảo mật các file tự động hóa GitHub Actions. Nó kiểm tra các rủi ro cụ thể mà công cụ bảo mật thông thường bỏ qua, như chèn mã (code injection) và việc dùng quyền nguy hiểm.

Khi nào nên dùng

  • ✓Khi được yêu cầu rà soát bảo mật một file tự động hóa GitHub Actions.
  • ✓Khi tạo một tự động hóa mới và muốn bảo đảm nó an toàn từ đầu.
  • ✓Khi một tự động hóa dùng các trigger có thể được kích hoạt bởi code bên ngoài.

Liên kết skill

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

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/github/awesome-copilot/blob/main/skills/github-actions-hardening/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Hãy rà soát bảo mật file workflow GitHub Actions này: [dán code ở đây]”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Công cụ phân tích các trigger của tự động hóa để hiểu ai có thể khởi chạy nó và với quyền nào. Sau đó nó tìm những chỗ mà dữ liệu bên ngoài có thể được đưa trực tiếp vào lệnh, điều này có thể nguy hiểm.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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

…

Câu hỏi thường gặp

“Privileged triggers” là gì?

Đó là các sự kiện khởi chạy tự động hóa và có thể được kích hoạt bởi người ngoài dự án, như trong các “pull request” từ những dự án bạn không kiểm soát. Chúng có thể có quyền truy cập thông tin nhạy cảm.

“Script injection” trong ngữ cảnh này là gì?

Đó là khi mã độc được chèn vào một trường mà tự động hóa sử dụng, như tiêu đề một “pull request”, và đoạn mã đó được thực thi như thể là một phần của tự động hóa.

Tại sao nên dùng “commit SHA” thay vì “tag” hoặc “branch” để tham chiếu action?

Tag và branch có thể bị thay đổi sau khi tạo. Dùng “commit SHA” (một định danh duy nhất, cố định) bảo đảm bạn luôn dùng đúng phiên bản action đã được rà soát, tránh việc nó bị thay bằng một bản độc hại.

Chi tiết

Mô tả gốc của tác giả

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

Độ phổ biến

Sao GitHub
40k
Vị trí xếp hạng
#7225
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự