Actions workflow security

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.

workflow.yml · least privilege
permissions:
  contents: read

jobs:
  deploy:
    permissions:
      contents: read
      packages: write

Pin 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.

pinning · tag vs SHA
# Mutable: whatever v4 points at today
- uses: actions/checkout@v4

# Pinned: exactly this commit
- uses: actions/checkout@8f4b7f8  # v4.2.1

Secrets 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.

workflow.yml · one deploy at a time
concurrency:
  group: deploy-production
  cancel-in-progress: false

Review 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.

Alvin K Sabu ›Actions workflow securityMade to be explored.

alvin — bash — 80 × 24

Welcome to Alvin’s desktop.

Type help to explore. This is a browser simulation.

esc to close

Search this desktop

↑ ↓ to navigate ↵ to openesc to close

A little desktop tour

Click an app in the dock or a folder in the sidebar. The window controls work, too.

Search everything
Ctrl / ⌘ K
Open terminal
`
Overview / Projects / About / Toolbox / Contact
1 — 5
Close a dialog or menu
Esc

Pipeline Lab and Terminal are local demos. They never connect to production infrastructure.