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

// module 06 · Hardening GitHub Actions

The GITHUB_TOKEN and least privilege

Every job gets a GITHUB_TOKEN, and anything that runs in the job can use it: your steps, every action, and any code an attacker gets into the job. The org default of `read` is not a ceiling, because a workflow can ask for more in `permissions:`. This lesson runs a demo PR where two jobs try the same seven things with a write token and a read token, shows what the write token really could and couldn't do on our fleet, and then gives every fleet workflow `permissions: {}` with per-job grants and no persisted checkout credentials.

  • Lesson 19 of 34

Learning Objectives

  • Read a job's real token permissions from the "GITHUB_TOKEN Permissions" section of its run log
  • Explain why the org default token setting doesn't limit a workflow that asks for more
  • Show what a write token can and can't do: branches, releases, comments, approvals, workflow files, `main`
  • Set `permissions: {}` at the top of a workflow and grant each job only what it uses
  • Turn off persisted checkout credentials, and explain who gets secrets on fork PRs and with `secrets: inherit`

This lesson is for enrolled learners

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