12 November 2026 · 6 MIN READ
GitHub Actions workflow security: permissions, pinning, and secrets
CI has write access to your registry and your cloud. Treat the workflow file like production configuration.
Default permissions are too generous
A workflow gets a token automatically, and the default scope is wider than almost any job needs. The single highest-value line in a workflow file is a top-level permissions block that grants read-only by default, then widens scope per job that genuinely needs it.
A job that builds and pushes an image needs packages: write — and nothing else.
permissions:
contents: read
jobs:
deploy:
permissions:
contents: read
packages: writePin third-party actions
Using an action by tag (checkout@v4) means trusting that tag to never move. Tags are mutable; supply-chain attacks have exploited exactly this. Pinning the full commit SHA turns a moving target into a fixed dependency.
It costs one extra line of comment, and Dependabot can still open PRs to move the pin deliberately.
# Mutable: whatever v4 points at today
- uses: actions/checkout@v4
# Pinned: exactly this commit
- uses: actions/checkout@8f4b7f8 # v4.2.1Secrets scoped by environment
Secrets pasted inline into a workflow YAML end up reviewed by everyone who reads the repo. GitHub Environments keep them in the platform: scoped per environment, with deployment protection rules for production.
The pattern that works: dev secrets available to CI freely, production secrets gated behind the production environment, so a branch building a pull request physically cannot reach them.
Concurrency: two deploys should not race
Two pushes arriving close together means two workflows deploying the same service concurrently — and the older one can finish last, quietly overwriting the newer release. A concurrency group on the deploy job makes the race impossible: the newer run cancels or queues the older one.
concurrency:
group: deploy-production
cancel-in-progress: falseReview the workflow like code
The workflow file runs with credentials. So it gets the same treatment as code that does: PRs required to touch it, CODEOWNERS watching it, and no trust in a workflow run that was not built from a reviewed commit.
Practical security is rarely dramatic. It is a short list, applied consistently, with the reasoning written down for the next person.