Security for GitHub Actionss
Workflow security is hardening pipelines against abuse. Key measures include setting minimal permissions for GITHUB_TOKEN, pinning third-party actions to commit SHAs, avoiding script injection from untrusted input such as pull request titles, handling fork pull requests carefully, and scanning dependencies and code.
Stage: Security and Operations · Part of the GitHub Actions roadmap · Last reviewed 19 November 2026
What to learn in Security
- Restrict GITHUB_TOKEN permissions at the workflow level
- Pin third-party actions to a full commit SHA
- Spot a script injection through unsanitised github.event input
- Explain why pull_request_target needs extra care
- Enable Dependabot and code scanning for a repository
Security interview questions
How can script injection happen in a workflow?
If a run step interpolates untrusted data like a pull request title directly with the expression syntax, an attacker can craft text that breaks out and runs commands. Pass the value through an environment variable and reference that in the shell instead.
Why pin actions to a commit SHA?
Tags and branches can be moved or compromised, so a workflow using a tag could suddenly run malicious code. A full commit SHA is immutable, guaranteeing that the exact reviewed code runs, and Dependabot can update the pin.
Where Security fits in the GitHub Actions roadmap
Security belongs to the Security and Operations stage (intermediate level). Keep it safe.
Other units in this stage
Back to the full GitHub Actions roadmap