chore(ci): scope NODE_AUTH_TOKEN to npm publish and add --provenance#369
Merged
Conversation
Move NODE_AUTH_TOKEN out of the actions/setup-node step so it is no longer exposed to install-time dependency lifecycle scripts (e.g. postinstall during `pnpm install`, build, lint, and test). The token is now only set on the `npm publish` step, which is the only place it is required. Also add `--provenance` to `npm publish` so released artifacts include npm package provenance attestations, leveraging the existing `id-token: write` permission. This reduces the blast radius of any future install-time supply-chain compromise without changing release behavior. Made-with: Cursor
barbmarcio
approved these changes
Apr 30, 2026
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.
Summary
Hardens
.github/workflows/publish-to-npm.ymlto reduce blast radius in case of an install-time supply-chain compromise:NODE_AUTH_TOKENfrom theactions/setup-nodestep. It was previously exposed for the entire job, includingpnpm install(which runs lifecycle scripts), lint, test, and build. Any compromised dependency executing during install could read the npm publish token fromprocess.env.NODE_AUTH_TOKENonly on thenpm publishstep, which is the sole step that needs it.--provenancetonpm publishso released artifacts get npm package provenance attestations. The job already haspermissions: id-token: write, so no additional config is needed.Context
This is preventive hardening prompted by recent supply-chain incidents (e.g. install-time compromises in transitively-pulled packages). I found no evidence of compromise in this repo — this is purely about reducing future blast radius. The same pattern is being rolled out to
Topsort/banners.jsandTopsort/topsort.js.Test plan
Releaseworkflow runs successfully andnpm publishauthenticates correctly.Risk
Low. Behavioral diff vs. before:
pnpm install/ lint / test / build (intended).npm publishitself still receives the token viaenv:and the.npmrcwritten bysetup-node(registry-urlis unchanged), so authentication still works.--provenancerequiresid-token: write(already set) and a public package on a supported runner (GitHub-hostedubuntu-24.04, OK).Made with Cursor