Skip to content

fix(ci): drop persisted checkout tokens and pin npm in the publish job - #464

Open
wjsoj wants to merge 1 commit into
hypit-ai:mainfrom
wjsoj:fix/workflow-hardening
Open

wjsoj wants to merge 1 commit into
hypit-ai:mainfrom
wjsoj:fix/workflow-hardening

Conversation

@wjsoj

@wjsoj wjsoj commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Closes #482

Problem

Two small hardening gaps are left in workflows that are otherwise least-privilege and SHA-pinned:

  1. ci.yml (check job) and sync-hypihub-docs.yml (notify job) use actions/checkout with the default persist-credentials: true. That writes the job's GITHUB_TOKEN into .git/config, where every later step (dependency install scripts, the test suite, the curl dispatch step) can read it. npm-package.yml, publish-npm.yml and the automation workflows already set persist-credentials: false. These two jobs are the only ones that don't.
  2. publish-npm.yml runs npm install --global npm@11. That resolves to whichever npm 11 release is newest on the day a release is cut. It runs in the one job that holds id-token: write (npm trusted publishing) and contents: write.

Impact / severity

Low. This is defence in depth, and nothing here can be exploited today:

  • Both persisted tokens are limited to contents: read, the check job's token is read-only for fork PRs, and neither job uploads artifacts. Persisting the token only gives code that already runs in the job one more credential.
  • The npm pin guards against a bad or compromised npm 11.x release running with the OIDC publishing token. That is unlikely but costly if it happens.

Fix

  • Add persist-credentials: false to the two checkouts. Neither job uses git against a remote after checkout. sync-hypihub-docs only runs a local git ls-tree, and the CI tests never fetch or push.
  • Pin the trusted-publishing npm to [email protected], which was released on 2026-10-15. Trusted publishing needs npm >= 11.5.1, so behaviour is unchanged. A comment explains why the version is exact.

Validation

  • actionlint reports no new findings. The only one left is an existing shellcheck info note in npm-package.yml.
  • zizmor --offline no longer reports artipacked for ci.yml or sync-hypihub-docs.yml. Its remaining cache-poisoning hit on publish-npm.yml is a false positive: actions/[email protected] does not cache unless cache: is set, and the job installs no dependencies.
  • I re-read the release path (select-release-run.mjs, publish-release-candidate.mjs): the publish job's candidate selection, artifact download and publish commands are untouched.

The CI check job and the HypiHub docs notification checked out with the
default persist-credentials, leaving GITHUB_TOKEN in .git/config for every
later step. Neither job talks to a remote with git, so the token is not
needed after checkout.

The publish job installed npm@11, which resolves to whatever npm 11
release is newest when a release is cut, inside a job that holds the npm
OIDC token and contents: write. Pin it to an exact version.
SanHsien added a commit to SanHsien/hypit that referenced this pull request Nov 7, 2026
…i#460-hypit-ai#474; advance watermarks

No PR was merged upstream, so nothing was cherry-picked: 11 PRs = 5 defer
(hypit-ai#464 hypit-ai#466 hypit-ai#467 hypit-ai#469 hypit-ai#471, pinned in monitored) + 6 not applicable; 5 issues =
1 defer (hypit-ai#473) + 4 not applicable. hypit-ai#464 npm pin is moot because the fork gates
publish jobs to upstream (b641cce). ROADMAP row updated with the deferred items.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
SanHsien added a commit to SanHsien/hypit that referenced this pull request Nov 22, 2026
Measured over 30 days (10-23..11-21): 239 runs, ~896 weighted minutes
(~215/week; Windows x2, no macOS). Top consumers: CI 414 (Windows, 37 push
+ 18 PR), npm package execution 219 (PR only, Windows + Linux), CodeQL 177
(40 push runs), plus 25 always-skipped HypiHub sync runs.

- ci.yml: pushes skip changes that only touch fork notes and records
  (ROADMAP, AGENTS, FORK, NOTICE, CONTRIBUTING, upstream report, baseline,
  dependabot.yml, skills/, design/, docs/); tools/ and workflows stay in
  because the suite runs tools/tests. Drop the pull_request path filter so
  the required "Windows CI" check can never be stuck pending. Add
  persist-credentials: false to checkout (upstream PR hypit-ai#464).
- codeql.yml: push scans only on JS/TS/HTML source changes; PR and weekly
  schedule stay unfiltered.
- npm-package.yml (not required): skip PRs touching only fork maintenance
  files.
- Delete sync-hypihub-docs.yml: needs an upstream-only secret, always
  skipped on the fork.
- dependabot.yml: group npm security updates into one PR.
- Record measurements, estimate (~896 -> ~686 weighted min / 30 days,
  runs 239 -> ~155), revert steps and the re-enable watch in DECISIONS,
  FORK and ROADMAP.

Actions are suspended, so nothing ran on GitHub; verified with YAML
parsing and tools/dev_check.ps1 (full).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

This branch has not been deployed

No deployments
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: drop persisted checkout tokens and pin npm in the publish job

1 participant