actions / actions/cache

Cache/save should not run automatically from a pull_request_trigger

Open
#1,756 6 comments 9 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
5.6k
Forks
1.6k
PR merge metrics
No merged PRs in 30d

Description

The current behavior of actions/cache is to always do both a restore and a save step. Even though its documented to never run save from an untrusted source.

Cache poisoning attacks were used against an nom package yesterday, the attack used a pull_request_target workflow to accomplish it.

In order to be secure by default, I propose to update actions/cache to take its own recommended practices in account and to make the save step conditional on the trigger not being prt.

I understand there are probably still other ways to accomplish cache poinsening, but this would go a long way in reducing yet another angle of the pull_request_target triggers dangers.

Alternatively, cache/save or cache could use pick another branch to cache against, not the target branch, main in this case, but the source branch, pulls/123.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the actions/cache restore and save behavior for pull_request_target workflows, along with the security concerns described in the issue. Clarify whether the intended outcome is to skip saving entirely or cache against the source branch, then define tests showing that untrusted pull request workflows cannot overwrite the target branch cache.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions, typescript
Domain
ci-cd, security
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.