Skip to content
This repository was archived by the owner on Aug 5, 2026. It is now read-only.

ci: declare explicit workflow permissions and pin actions to commit SHAs - #52

Merged
paul-abb merged 4 commits into
mainfrom
security/workflow-permissions-and-sha-pinning
Aug 5, 2026
Merged

ci: declare explicit workflow permissions and pin actions to commit SHAs#52
paul-abb merged 4 commits into
mainfrom
security/workflow-permissions-and-sha-pinning

Conversation

@paul-abb

@paul-abb paul-abb commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Declares explicit permissions: on both workflows and pins every action to a
commit SHA.

Changes

Explicit permissions: — neither workflow declared one, so every job
inherited the repository default. Sized per workflow by reading what each
actually does rather than applied uniformly:

Workflow Granted Why
continuous_integration.yml contents: read on: [pull_request], read-only
publish.yml workflow-level contents: read, job-level contents: write quarto publish pushes the rendered site to gh-pages; the default stays read-only so any job added later starts least-privileged

All uses: refs pinned to commit SHAs, each with a trailing version comment
so readability and Renovate/Dependabot updates are preserved. A mutable tag can
be repointed by whoever controls the action repo; a SHA can't.

Action majors raised. Pinning checkout@v2 / setup-python@v2 at their
current commits would have frozen those majors permanently, with no upgrade path
— which is arguably worse than a floating tag that still receives patches. So
they're raised as part of the same change:

Action Was Now
actions/checkout (CI) v2 v4 (11d5960a, v4.4.0)
actions/setup-python (CI) v2 v5 (a26af69b, v5.6.0)
actions/checkout (publish) v3 v4 (11d5960a, v4.4.0)

python-version is 3.9, so the setup-python v5 YAML-float quoting issue
(which affects 3.10+) doesn't apply here.

Validation

  • Both files parse (yaml.safe_load).
  • Zero unpinned uses: refs remain — re-grepped for anything not @<40-hex>.
  • All 7 pins verified to resolve to the tag their comment claims, by querying
    each action repo's own tag list for the commit — not assumed from the tag name.
  • permissions: blocks confirmed parsed at the correct scope.

Note on CI status

This repo's CI is red for reasons that predate this PR — the projectq wheel
build fails against modern setuptools, and test_linq_basics_notebook needs
pennylane. Neither is touched here. The comparison that matters: the run
before the action-major bump and the run after it fail identically.

…_integration.yml

VULNMGMT-1068 / VULNMGMT-1069
The workflow-level default was contents: write, which inverts the goal of this
PR: any job added to this workflow later would silently inherit write.

The build-deploy job already declares contents: write at job level, and job-level
permissions override workflow-level, so quarto's gh-pages push is unaffected. Only
the inherited default changes.
@paul-abb
paul-abb force-pushed the security/workflow-permissions-and-sha-pinning branch from 66f6b7e to ea464e4 Compare August 5, 2026 01:00
@paul-abb paul-abb changed the title security: least-privilege workflow permissions + SHA-pin all actions ci: declare explicit workflow permissions and pin actions to commit SHAs Aug 5, 2026
The pins in this branch were taken at whatever major each workflow already
used: checkout v2 and setup-python v2 in continuous_integration.yml, and
checkout v3 in publish.yml. Pinning to a commit freezes that exact code
permanently, so pinning an old major is worse than the floating tag it
replaced -- a floating @v2 still picks up v2 patch and security releases,
whereas the pinned commit picks up nothing and has no upgrade path except a
manual edit. The runners already warn that the Node 20 runtime these actions
use is being deprecated, so the frozen pins would eventually fail closed.

checkout   -> 11d5960a326750d5838078e36cf38b85af677262 (v4, v4.4.0)
setup-python -> a26af69be951a213d495a4c3e4e4022e16d87065 (v5, v5.6.0)

Both SHAs were checked against the upstream tag refs rather than copied from
a comment. The setup-python bump is safe for this matrix specifically: the
YAML-float hazard where an unquoted 3.10 parses as 3.1 applies to 3.10 and
above, and this matrix is [3.9].
@paul-abb
paul-abb merged commit dd9c9a0 into main Aug 5, 2026
3 of 4 checks passed
@paul-abb
paul-abb deleted the security/workflow-permissions-and-sha-pinning branch August 5, 2026 01:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant