Repository navigation
Description
Design note, follow-up to #281 / #282.
Problem
In .github/workflows/release-cli.yml, the publish job has id-token: write (and contents: write) for the whole job. While a job has id-token: write, every step in it gets ACTIONS_ID_TOKEN_REQUEST_URL and ACTIONS_ID_TOKEN_REQUEST_TOKEN in its environment. Any code running in that job can use them to request a GitHub OIDC token for this workflow, and that token is what npm trusted publishing accepts for @diffci.com/diffci.
The same job then runs third-party code before it publishes:
npm ci --no-audit --fund=falseinpackages/diffci-cli, with install scripts enabled. That covers the dependencies'preinstall/install/postinstallscripts, and thepreparebuild of the@diffci.com/coregit dependency together with its own dependencies.npm install --global npm@11, which is an unpinned version range.npm run typecheck,build,package:check,package:smoke, and thennpm publish, which runs the package'sprepacklifecycle.
A compromised dependency could therefore publish a version of @diffci.com/diffci that carries a valid provenance attestation for this repository. #282 keeps the contents: write token out of .git/config, but it cannot help with the OIDC credential: that one comes from the job's permissions, not the checkout.
Proposal: split the job
buildjob (permissions: contents: read, noid-token). It holds every step that installs or runs code: tag check,npm ci,check-agent-packaging, typecheck, build,package:check,package:smoke. It then runsnpm packand uploads the tarball (and its sha512/integrity) withactions/upload-artifact.publishjob (needs: build,permissions: id-token: writeonly,environment:optional). It does not runnpm cior any install or lifecycle scripts. It sets up Node and npm (ideally with a pinned npm version) and downloads the artifact. It checks the tarball against the recorded digest, then runs the existing "already published from this commit" check andnpm publish <tarball> --access public --provenance --ignore-scripts.- Release job(s) for the steps that need
contents: write: wait for propagation, observer Action smoke, GitHub Release, provenance assets,action-vtag,verify-release. These run afterpublishwithoutid-token: write. They can keepcontents: writewithpersist-credentials: falseas in fix(ci): do not persist write-scoped checkout tokens in publish and merge-gate #282.
The downstream jobs (publish-gitlab-component, publish-mcp-registry, notify-hosted-mcp) would need needs: updated to the new final job.
Things to check while doing it
- gitHead: the existing re-run check compares the published
gitHeadwithGITHUB_SHA. When publishing from a folder in a git checkout, npm fillsgitHeadin itself. That field needs confirming fornpm publish <tarball>, or the check needs to be kept another way, for example by recording the commit in the artifact. - Provenance subject: the attestation names the tarball's sha512.
scripts/attach-release-provenance.mjsalready checks that subject against what npm serves, so it should keep passing unchanged. - Tarball contents:
npm packin the build job runsprepack(build:client) without the OIDC credential, so the tarball contents stay the same as today'snpm publish.
Activity
adityankale190895 commentedon Nov 19, 2026
Thanks @FredApps, this is a real gap, and the write-up makes it easy to act on. You're right that #282 can't cover it: the OIDC request token comes from the job's
id-token: write, and every step inpublishsees it, includingnpm ciinstall scripts, thepreparebuild of the Core git dependency, and the unpinnednpm@11install.I'll do the split as you describe it:
contents: read, noid-token, which runs everything that installs or executes code and ends withnpm pack, uploading the tarball and its sha512;id-token: writeonly, which runs nonpm ciand no lifecycle scripts, pins the npm version, checks the digest, and runsnpm publish <tarball> --provenance --ignore-scripts;contents: writesteps after it, withoutid-token.I'll check your three points while doing it. On
gitHead, ifnpm publish <tarball>doesn't fill it in, I'll record the commit in the artifact and have the re-run check read it from there. I'll also confirm that the provenance subject still matches inattach-release-provenance.mjs, and diff the tarball against the one from the current flow.I'm taking this one myself rather than asking for a PR, because it can only really be tested by cutting a release with trusted publishing, and that can't run from a fork. I'll link the commit here, and the next release will be the test.
adityankale190895 commentedon Nov 19, 2026
Done in b620a06, following your three-job plan:
contents: read, noid-token): tag check,npm ci, packaging checks, typecheck, build,package:check/package:smoke, thennpm pack, uploading the tarball and recording its sha512 as a job output.id-token: writeonly): no checkout and no npm cache, with npm pinned to11.21.2and installed with--ignore-scripts. It checks the tarball's sha512, its name, its version against the tag and itsgitHeadagainst the commit, then runsnpm publish <tarball> --access public --provenance --ignore-scriptsand waits for propagation.contents: write, noid-token): observer smoke, GitHub Release, provenance assets,action-vtag,verify-release. The GitLab and MCP Registry jobs now wait on it.On your three points:
package.jsonbefore packing, and npm keeps agitHeadthat's already in the tarball. I checked that against npm 11's pacote and libnpmpublish with a test tarball, so the re-run check still works.attach-release-provenance.mjschecks it against what npm serves.npm packstill runsprepack(build:client), now without the OIDC credential. The only addition is thegitHeadfield.tests/workflow-credentials.test.tsnow fails if any job that can mint an OIDC token runs an install, or runsnpm publishwithout--ignore-scripts, and it checks the job permissions above. Both tests fail on the old workflow.The next
cli-release-v*run is the real test. I'll note here how it goes. Thanks again for the clear write-up.