Repository navigation
ci(release): scope the token per job and pin every action by SHA - #2783
Merged
Merged
Conversation
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]>
Code coverage overviewLanguages: Rust, Solidity Rust / code-coverage/cargo-llvm-cov
Solidity / code-coverage/forge
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
Gas snapshotNo gas changes vs base. |
There was a problem hiding this comment.
🟡 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
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]>
7 of 8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What
Hardens the release pipeline against a hijacked action tag or a malicious build script, per #2771.
Token scope.
release.ymlgrantscontents: readat the workflow level. Write access sits on four small jobs:draft(new)contentsactions/download-artifact,ghupload-assetscontentsactions/download-artifact,sha256sum,gh(no checkout)attach(new)contentsactions/download-artifact,ghdockerpackagescontents: readonlyRelease notes move to the read-only
tagjob. They pass todraftas an artifact. SBOM generation moves to a newsbomjob withpackages: read, so syft never runs next to a write token.verify,build-binariesandtagkeep a read-only token, and those are the jobs that runbuild.rs,cargo publish --dry-run, semver-checks and the tool installs.Pinning and credentials. Every checkout in
release.ymlandsecurity.ymlsetspersist-credentials: false. Every action in both workflows, and in thedashboard-buildcomposite action, is pinned by commit SHA with a# vX.Y.Zcomment. That includesactions/*andaquasecurity/trivy-action.anchore/sbom-action@v0was 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, withfallback: noneso a version missing from its manifest fails instead of installing unchecked.check-image-name.shalso holds thesbomandattachimage 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 thepackagingjob and in pre-commit. It requires every remoteuses:to be pinned by SHA, including those in referenced local actions. It requirespersist-credentials: falseunder every checkout'swith:and nowriteat the workflow level, reads block and{ scope: level }permissions, and fails on any shape it cannot read (an alias, a line underjobs:that is not a job, auseskey it cannot parse, a step with no dash) rather than skipping it. It does not readrun:steps. Job write grants must match itsWRITE_JOBStable exactly, and acontents: writejob may use onlyactions/*. Againstmain, 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.shnow refuses a signature whose signed trusted comment, asminisign -Qreports it, is not exactly afile:<archive>field. SECURITY.md §cargo binstallexplains that binstall prints this comment but does not check it, and names the GPG-signedSHA256SUMSanddecdn self-updateas the rollback-proof paths.Closes #2771
Reviewer notes
release.ymlruns only on av*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-toolchainstays, pinned to itsmasterSHA with an explicittoolchain: 1.99.1input.check_toolchain_pin.pyalready reads that input. Replacing the action with barerustupwould drop theCARGO_*variables it exports, andrust-cachehashes those intoverify's restore key, soverifywould miss ci.yml's clippy cache.cargo-semver-checks-actionis SHA-pinned but still downloads the newest cargo-semver-checks andstableon each run, so it always reads the current rustdoc format. That was a deliberate choice: the residual risk runs underverify's read-only token.binaries-*by exact name instead of by pattern would close that, and would be a separate follow-up.code-qualitypermission 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-credentialsoutsidewith:), the unchecked nextest fallback, a stalesign-release.sherror namingdockerinstead ofattach, a draft step that took anygh release viewerror for "not found" (GitHub allows two drafts per tag), and doc wording that hiddocker'spackages: writeand claimed the guard readsrun:steps. All fixed in 263e562.Second review pass (edb88a8). The SHA-pinned
setup-qemu-actionandsetup-buildx-actionstill pulledtonistiigi/binfmt:latest(run--privileged) andmoby/buildkit:buildx-stable-1. BuildKit performs the push withdocker'spackages: writecredential, 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 localbuildx create --bootstrap. binfmt is pulled rather than restored from the Actions cache. The guard has a rule 5: an action inIMAGE_INPUTSmust name its image by digest, and a jobcontainer:/services:is an error.upload-assetsandattachrefuse to--clobbera 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 underjobs:; 88e92a2 drops the redundantgit fetch origin main.Verification
pre-commit runon 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 newsign-release.shtest for a signature that does not name its archive; the minisign shim now writes the default trusted comment.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 anyfile:) fails at least one test.check-release-hardening.sh,check-toolchain-pin.shandcheck-image-name.shpass.actionlinton release.yml and security.yml passes.gh api repos/O/R/commits/<ref>. The floating majors match their newest exact tag, exceptanchore/sbom-action(see above)..minisig: accepts it, and rejects it renamed to 0.2.0, afile:…tar.gz.oldprefix match, and a custom comment.ci, lowercase subject.🤖 Generated with Claude Code