HackyJS CoursesMerge Gates: Hardening a GitHub Org for AI-Written Code

// module 06 · Hardening GitHub Actions

Dangerous triggers and script injection

Two lines in the lab let anyone who can comment or name a PR run shell commands in CI. We prove it with a harmless payload in an issue comment and a PR title, and read the real output in the run logs. Then we fix the fleet: untrusted text goes through environment variables, `ci` moves from `pull_request_target` to `pull_request`, and a repo-level Actions event policy blocks `pull_request_target` and `workflow_run` on every repo. We also cover GitHub's new default policy for `pull_request_target`, enforced on 2026-12-02, and what `actions/checkout` v7 changed.

  • Lesson 20 of 34

Learning Objectives

  • Explain why `${{ }}` inside `run:` is code injection, and show it running in a real job
  • Fix injection by passing untrusted values through `env:` and quoting them in the shell
  • Explain what `pull_request_target`, `workflow_run` and `issue_comment` run with, and when each is a "pwn request"
  • Move a workflow from `pull_request_target` to `pull_request`, or split it into an unprivileged and a privileged part
  • Block risky events with an Actions event policy, and know the 2026-12-02 default policy

This lesson is for enrolled learners

Log in, then enroll to read the full lesson, run its lab and take the quiz.