Skip to content

ci: read-only top-level permissions in every workflow, writes per job (#1599) - #1624

Merged
scttfrdmn merged 1 commit into
mainfrom
hardening/ci-supply
Nov 14, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
hardening/ci-supply

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes #1599

What changes

  • ci.yml had no permissions: at all. It now has contents: read at the top, and the Test job adds pull-requests: read, which the Changelog gate's gh api repos/.../pulls/N/files needs. No job in it writes.
  • release.yaml granted contents: write, id-token: write and attestations: write to the whole workflow. The top level is now contents: read, and those three grants sit on the goreleaser job, which uses all of them: the GitHub release, cosign keyless signing plus the release-role OIDC plus provenance, and the attestation. deploy-checklist (pull-requests: write) and the deploy-lambdas call (id-token: write, which the called workflow's deploy job needs) already had their own blocks.
  • security.yml (contents: read), and awscli-pin.yml, efa-pin.yml and deploy-lambdas.yaml ({} plus per-job grants), already complied. They are unchanged.

The gate

workflow_permissions_test.go discovers every file under .github/workflows and fails when discovery finds nothing. It enforces four rules:

  1. Every workflow has a top-level permissions: key.
  2. That key grants no write.
  3. A workflow triggered by pull_request or pull_request_target grants no write anywhere.
  4. id-token: write appears only on a job that uses an OIDC token: configure-aws-credentials with role-to-assume, cosign, attest-build-provenance, or a call to a local reusable workflow whose own jobs hold it.

It runs under go test ./... and also as a named "Workflow permissions gate" step in CI.

I watched each rule fail against a revert that compiles:

  • rules 1 and 2: main's ci.yml and release.yaml;
  • rule 3: pull-requests: write on the Test job;
  • rule 4: id-token: write on deploy-checklist.

Deployed state

The org and repo default_workflow_permissions are both read today, per gh api .../actions/permissions/workflow. So this change is defence in depth, and it does not change how any job runs now.

Checks

  • make check: the root tests and lint pass locally. The only failures are path-with-a-space failures in lambda/dashboard-api, from the worktree's location. They are unrelated to this change.
  • actionlint: the one finding is SC2001 in the Changelog gate's existing script.
  • semgrep on the changed files is clean.

@scttfrdmn
scttfrdmn marked this pull request as ready for review November 14, 2026 20:06
@scttfrdmn
scttfrdmn merged commit 8d5963f into main Nov 14, 2026
9 checks passed
@scttfrdmn
scttfrdmn deleted the hardening/ci-supply branch November 14, 2026 20:06
@scttfrdmn scttfrdmn mentioned this pull request Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

security: Twelve workflows have no permissions block, so GITHUB_TOKEN gets the repo/org default

1 participant