Skip to content

Explicitly disable caches in sensitive publish workflows#1549

Open
slorber wants to merge 1 commit into
actions:mainfrom
slorber:patch-1
Open

Explicitly disable caches in sensitive publish workflows#1549
slorber wants to merge 1 commit into
actions:mainfrom
slorber:patch-1

Conversation

@slorber
Copy link
Copy Markdown

@slorber slorber commented May 14, 2026

Description:

Sensitive workflows like the Trusted Publishing workflow should explicitly disable cache to reduce supply chain risk due to cache poisoning. See recent hack: https://tanstack.com/blog/npm-supply-chain-compromise-postmortem

It would be better if that default was applied automatically, and not depending on various conditions that are not so easy to understand, so explicitly disabling this in the documentation is safer for now.

Automatic caching was afaik turned on by default in v5 in certain conditions. I think it's worth considering reverting that change and making caching opt-in, to have a more secure action by default, even if it's less performant.

Note that many people upgrade actions without looking at the changelog, using Dependabot. Default value changes like this can introduce vulnerabilities, so whatever the default is, explicitly disabling the cache for sensitive workflows remains a good idea IMHO.

Note that on README.md, there's already a disclaimer giving similar advice. However it's not easy to find and your Trusted Publishing docs don't even follow that recommendation:

CleanShot 2026-05-14 at 11 10 25@2x

https://github.com/actions/setup-node#breaking-changes-in-v5

I believe all your documented examples should follow that recommendation, explicitly disable caching with package-manager-cache: false, and link to a canonical doc page explaining the security problem.

This PR is just to kickstart the discussion; there are probably other sensitive workflows you document that do not have package-manager-cache: false, and probably other official GitHub Actions whose docs show insecure examples.

Related issue:

See my comment here: #1445 (comment)

Check list:

  • Mark if documentation changes are required.
  • Mark if tests were added or updated to cover the changes.

Copilot AI review requested due to automatic review settings May 14, 2026 09:14
@slorber slorber requested a review from a team as a code owner May 14, 2026 09:14
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates published workflow documentation to explicitly disable automatic dependency caching in sensitive publish scenarios (including npm Trusted Publisher/OIDC) to reduce cache-poisoning supply-chain risk.

Changes:

  • Added package-manager-cache: false to npm publish examples (npmjs + GitHub Packages).
  • Added package-manager-cache: false to yarn publish examples.
  • Added package-manager-cache: false to the Trusted Publisher (OIDC) publish example.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/advanced-usage.md
Comment on lines 402 to 406
node-version: '24.x'
registry-url: 'https://registry.npmjs.org'
package-manager-cache: false # Prevent cache poisoning issues
- run: npm ci
- run: npm publish
Comment thread docs/advanced-usage.md
Comment on lines 507 to 512
- uses: actions/setup-node@v6
with:
node-version: '24'
registry-url: 'https://registry.npmjs.org'
package-manager-cache: false # Prevent cache poisoning issues

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.

2 participants