Technical guide
Secure a GitHub Actions workflow
A workflow runs code with your secrets and a token that can write to the repository. Five settings decide what an outside pull request can do with them.
Discuss your projectpull_request_target and the code of a pull request
A workflow triggered by pull_request_target runs in the context of the base repository: it has the secrets and a write token, even when the pull request comes from a fork. If it checks out the pull request’s code and then installs, builds or tests it, the author of the pull request runs their code with those rights. Build outside code under pull_request, without secrets. If pull_request_target is needed (labelling, commenting), do not check out the proposed code, or split the work into two workflows and treat the output of the first as data.
Values the author controls inside a command
The title of a pull request or an issue, its body, a branch name, a commit message: the author chooses these values. Written directly in a run step with the ${{ … }} syntax, they are substituted before the shell starts, and a well-chosen title becomes a command. Pass them through an environment variable declared under env, then read that variable in quotes in the script.
The rights of the token
Declare permissions at the top of the file, at the lowest level (contents: read), then widen per job what needs more. Without a declaration, the token takes the default of the repository or the organisation, which can be write access to everything. permissions: write-all gives that same full access to every step, third-party actions included.
Pin third-party actions
A tag such as v4 can be moved by the owner of the action, or by someone who took over their account. Reference a third-party action by the full hash of its commit, with the version in a comment, and let an update tool propose the new hashes.
Secrets in logs
GitHub masks the exact value of a secret in logs, not its transformations: a secret that is encoded, cut or placed in a JSON object comes out in clear. Never print a secret, and do not turn on shell tracing in a step that receives one.
What Brunel checks, and its limit
Brunel reads the files of .github/workflows without running anything. It reports a checkout of pull request code under pull_request_target, an untrusted value written in a shell step, permissions: write-all, a secret printed by a step, third-party actions pinned by tag and missing permissions. It reads GitHub Actions only, and does not follow a reusable workflow or an action hosted in another repository.