Skip to content

ci(release): scope the token per job and pin every action by SHA - #2783

Merged
thiras merged 5 commits into
mainfrom
ci/release-token-scope
Oct 30, 2026
Merged

thiras merged 5 commits into
mainfrom
ci/release-token-scope

Conversation

@thiras

@thiras thiras commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

What

Hardens the release pipeline against a hijacked action tag or a malicious build script, per #2771.

Token scope. release.yml grants contents: read at the workflow level. Write access sits on four small jobs:

Job Writes Runs
draft (new) contents actions/download-artifact, gh
upload-assets contents actions/download-artifact, sha256sum, gh (no checkout)
attach (new) contents actions/download-artifact, gh
docker packages the docker/* actions, with contents: read only

Release notes move to the read-only tag job. They pass to draft as an artifact. SBOM generation moves to a new sbom job with packages: read, so syft never runs next to a write token. verify, build-binaries and tag keep a read-only token, and those are the jobs that run build.rs, cargo publish --dry-run, semver-checks and the tool installs.

Pinning and credentials. Every checkout in release.yml and security.yml sets persist-credentials: false. Every action in both workflows, and in the dashboard-build composite action, is pinned by commit SHA with a # vX.Y.Z comment. That includes actions/* and aquasecurity/trivy-action. anchore/sbom-action@v0 was a stale tag, 91 commits behind its newest release, so it is pinned to v0.24.3. [email protected], [email protected] and [email protected] install at fixed versions the pinned install-action checksums, with fallback: none so a version missing from its manifest fails instead of installing unchecked. check-image-name.sh also holds the sbom and attach image lists to the docker matrix. Dependabot's github-actions entry now also covers .github/actions/*.

Guard. .github/scripts/check-release-hardening.sh (stdlib Python, 68 tests) runs in the packaging job and in pre-commit. It requires every remote uses: to be pinned by SHA, including those in referenced local actions. It requires persist-credentials: false under every checkout's with: and no write at the workflow level, reads block and { scope: level } permissions, and fails on any shape it cannot read (an alias, a line under jobs: that is not a job, a uses key it cannot parse, a step with no dash) rather than skipping it. It does not read run: steps. Job write grants must match its WRITE_JOBS table exactly, and a contents: write job may use only actions/*. Against main, it reports 46 violations.

binstall signatures (item 2). minisign 0.11's default trusted comment already names the archive. v0.3.0's signatures carry file:decdn-0.3.0-x86_64-unknown-linux-gnu.tar.gz, and that name includes the binary, version and target. sign-release.sh now refuses a signature whose signed trusted comment, as minisign -Q reports it, is not exactly a file:<archive> field. SECURITY.md § cargo binstall explains that binstall prints this comment but does not check it, and names the GPG-signed SHA256SUMS and decdn self-update as the rollback-proof paths.

Closes #2771

Reviewer notes

  • The new release job graph has not run yet. release.yml runs only on a v* tag. actionlint passes, but the draft → upload-assets → docker → sbom → attach chain first runs on the next release. Watch that run, or try a throwaway pre-release tag on a fork first.
  • dtolnay/rust-toolchain stays, pinned to its master SHA with an explicit toolchain: 1.99.1 input. check_toolchain_pin.py already reads that input. Replacing the action with bare rustup would drop the CARGO_* variables it exports, and rust-cache hashes those into verify's restore key, so verify would miss ci.yml's clippy cache.
  • cargo-semver-checks-action is SHA-pinned but still downloads the newest cargo-semver-checks and stable on each run, so it always reads the current rustdoc format. That was a deliberate choice: the residual risk runs under verify's read-only token.
  • Not in scope: ci.yml, codeql.yml and sdk-contract.yml keep tag refs. Any job in a run can still upload artifacts through the runtime token. Downloading binaries-* by exact name instead of by pattern would close that, and would be a separate follow-up.
  • The actionlint findings in ci.yml (the code-quality permission scope, SC2012) were already there.

Review fixes (second commit)

A four-agent review found guard false passes (flow-mapping permissions, 4-space job indent, quoted/spaced uses, dash-offset steps, persist-credentials outside with:), the unchecked nextest fallback, a stale sign-release.sh error naming docker instead of attach, a draft step that took any gh release view error for "not found" (GitHub allows two drafts per tag), and doc wording that hid docker's packages: write and claimed the guard reads run: steps. All fixed in 263e562.

Second review pass (edb88a8). The SHA-pinned setup-qemu-action and setup-buildx-action still pulled tonistiigi/binfmt:latest (run --privileged) and moby/buildkit:buildx-stable-1. BuildKit performs the push with docker's packages: write credential, so a moved tag there reopened the exact #2771 scenario. Both are now pinned by index digest at the versions those tags resolve to today: qemu-v10.2.3, and BuildKit v0.33.1, checked with skopeo and a local buildx create --bootstrap. binfmt is pulled rather than restored from the Actions cache. The guard has a rule 5: an action in IMAGE_INPUTS must name its image by digest, and a job container:/services: is an error. upload-assets and attach refuse to --clobber a release that is no longer a draft. The guard's docstring now says it catches drift, not a hostile author: escaped or ? keys and cross-job aliases can hide from a text reader, and whoever can write them can delete the CI step. The docs stop claiming every download is pinned; cargo-semver-checks floats under a read-only token. Commit 3b04d33 is a simplifier pass on the guard, plus rejecting - name: list items under jobs:; 88e92a2 drops the redundant git fetch origin main.

Verification

  • pre-commit run on every changed file: passes. cargo-deny reports RUSTSEC-2026-0387 (crypto-bigint), which was already there and is warn-only.
  • uvx --python 3.12 --with pyyaml pytest .github/scripts/tests scripts/tests: 464 passed. This includes a new sign-release.sh test for a signature that does not name its archive; the minisign shim now writes the default trusted comment.
  • Guard mutation check: weakening the step-boundary, actions-only, grant-table, with:-scope, dash-search and job-key rules one at a time each fails at least one test. The 25 new guard tests: 17 fail against the first commit's guard. Weakening the trusted-comment match (dropping either tab, or matching any file:) fails at least one test.
  • check-release-hardening.sh, check-toolchain-pin.sh and check-image-name.sh pass. actionlint on release.yml and security.yml passes.
  • Every pinned SHA resolved with gh api repos/O/R/commits/<ref>. The floating majors match their newest exact tag, except anchore/sbom-action (see above).
  • Trusted-comment check against the real v0.3.0 .minisig: accepts it, and rejects it renamed to 0.2.0, a file:…tar.gz.old prefix match, and a custom comment.
  • clippy and nextest: not run, because no Rust changed.
  • PR title type ci, lowercase subject.
  • CHANGELOG entry under Security.

🤖 Generated with Claude Code

release.yml granted contents:write and packages:write to every job,
persisted the token in every checkout, and ran tag-pinned actions and
unversioned tools under it. The workflow now grants contents:read; only
draft, upload-assets and attach write release contents, and they run
nothing but actions/* and gh. Only docker writes packages. Release notes
move to the read-only tag job and SBOMs to a packages:read sbom job.

Every checkout in release.yml and security.yml sets
persist-credentials: false, every action there and in dashboard-build is
pinned by commit SHA, and cross, git-cliff and cargo-nextest install at
fixed versions. check-release-hardening.sh holds these rules in the
packaging job and pre-commit.

sign-release.sh refuses a binstall signature whose trusted comment does
not name its archive, and SECURITY.md says binstall does not check it,
so SHA256SUMS and decdn self-update are the rollback-proof paths.

Closes #2771

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 30, 2026 21:55
@thiras thiras self-assigned this Oct 30, 2026
@github-code-quality

github-code-quality Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Code coverage overview

Languages: Rust, Solidity

Rust / code-coverage/cargo-llvm-cov

main 991871e ci/release-token-sco... edb88a8 +/-
77% 77% 0%

Solidity / code-coverage/forge

main 3d95315 ci/release-token-sco... edb88a8 +/-
92% 92% 0%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated October 30, 2026 22:43 UTC

@github-actions

Copy link
Copy Markdown

Gas snapshot

No gas changes vs base.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

An unauthenticated fetch blocks private-repository releases, while inline permission mappings bypass write-grant checks and the actions-only restriction.

2 open issues
What changed in this PR

This PR hardens deCDN’s release pipeline by separating write-enabled publishing jobs from builds and scans, pinning actions, and checking archive signature metadata.

Changes:

  • Scopes tokens per job and separates draft creation, SBOM generation, and asset attachment.
  • Pins release/security actions and tool versions, with a CI and pre-commit guard.
  • Validates archive names in minisign trusted comments and documents binstall’s rollback limitations.
File Description
SECURITY.md Explains binstall signature limitations and verification options.
scripts/​tests/​test_sign_release_publish.py Tests rejection of signatures missing the archive name.
scripts/​sign-release.sh Checks archive names in verified trusted comments.
RELEASING.md Documents job permissions and the revised release flow.
CHANGELOG.md Records release-pipeline security changes.
.pre-commit-config.yaml Adds the release-hardening hook.
.github/​workflows/​security.yml Pins actions and disables persisted checkout credentials.
.github/​workflows/​release.yml Separates publishing jobs, narrows permissions, and pins dependencies.
.github/​workflows/​ci.yml Runs the hardening guard in packaging CI.
.github/​scripts/​tests/​test_check_release_hardening.py Adds regression coverage for hardening rules.
.github/​scripts/​check-release-hardening.sh Provides the guard’s shell entry point.
.github/​scripts/​check_release_hardening.py Checks action pins, checkout credentials, and write grants.
.github/​dependabot.yml Extends action updates to composite actions.
.github/​actions/​dashboard-build/​action.yml Pins dashboard setup actions by SHA.

Review effort: Balanced

Comment thread .github/workflows/release.yml Resolved
thiras and others added 4 commits October 31, 2026 01:11
check_release_hardening.py read `permissions: { contents: write }` as no
grant, skipped jobs not indented by two spaces, missed a quoted or spaced
`uses` key, let an earlier step's persist-credentials cover a dash-offset
checkout, and counted persist-credentials outside `with:`. It now parses
flow mappings, finds the job indent, and fails closed on any shape it
cannot read.

cargo-nextest 0.9.150 is not in the pinned install-action's manifest, so
it fell back to an unchecked cargo-binstall install; pin 0.9.149 and set
`fallback: none` on every pinned tool. sign-release.sh reads the trusted
comment from `minisign -Q` and names `attach` when an image file is
missing. The draft step stops on any `gh release view` error but "release
not found", upload-assets refuses a file that is not an archive, and
check-image-name.sh holds the sbom and attach image lists to the docker
matrix. Stale ordering comments and overclaiming docs are corrected.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
actions/checkout with fetch-depth: 0 fetches every branch as
refs/remotes/origin/*, so the signature step's `git fetch origin main`
was redundant. Dropping it leaves that step needing no credentials,
which persist-credentials: false no longer provides.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
One find_key helper replaces three hand-written key walks, step_block and
block_grants each lose a duplicated loop, and the draft step's
not-found branch reads positively. A dash line under `jobs:` was taken
for a job; the guard now names it as not a job key.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The SHA-pinned setup-qemu and setup-buildx actions still pulled
tonistiigi/binfmt:latest (run --privileged) and
moby/buildkit:buildx-stable-1, which pushes with the docker job's
packages: write credential. Pin both by index digest at the versions
those tags resolve to today (qemu-v10.2.3, BuildKit v0.33.1), and pull
binfmt rather than restore it from the Actions cache. The guard's new
rule 5 requires that digest, and rejects a job container: or services:
it does not read.

upload-assets and attach refuse to --clobber a release that is no longer
a draft, so re-running a job after publishing cannot replace signed
files. Truncated release notes raise a warning. The guard docstring says
it catches drift, not a hostile author, and the docs stop claiming every
tool download is pinned: cargo-semver-checks is the one that floats.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thiras
thiras merged commit a92727a into main Oct 30, 2026
38 checks passed
@thiras
thiras deleted the ci/release-token-scope branch October 30, 2026 22:45
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.

ci(release): workflow-wide write token with floating third-party actions; binstall signatures not bound to name/version

2 participants