Skip to main content
ISSUE-705HighThird-party actions

Untrusted trigger granted cache write

Control:CTRL-705Untrusted triggers must not write the cache

📋 What is this?

A job runs on an event GitHub restricts to read-only cache access (pull_request_target, issue_comment, workflow_run and every other event that runs on the default branch, apart from push, workflow_dispatch, repository_dispatch, delete, registry_package, page_build and schedule), and its cache-mode, set on the job or on its workflow, is write or write-only.

⚠️ Impact

GitHub isolates caches by ref: a run restores caches saved for its own ref and for the default branch, and a low-trust event only reads the default branch's. The explicit grant lifts that restriction, so code running in the job (a comment body pasted into a shell, a pull request's head, an artifact from an upstream run) can create or overwrite caches every default-branch run restores, and inject compromised artefacts into a release or publish job while nothing changes in its commit. Pinning the cache action by SHA does not help: the poisoned bytes live in the cache.

🔧 How to fix

Set cache-mode: read on the job, or on the workflow, for these events: it is GitHub's default for them. Keep the cache maintained by a trusted workflow instead, for example one triggered by push on the default branch. If the job must write the cache and runs no untrusted code, exempt the workflow or the job to accept the risk: it is then listed in the output instead of raising a finding.

✗ BeforeAnyone who can comment runs this job, and the grant lets its run save the npm cache the release job restores.
# .github/workflows/triage.yml - ❌ An issue_comment job allowed to write the default branch's caches
on:
issue_comment:
types: [created]
jobs:
triage:
runs-on: ubuntu-latest
cache-mode: write
steps:
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
cache: npm
✓ AfterThe job still restores the cache, and only trusted runs write it.
# .github/workflows/triage.yml - ✅ Read-only, GitHub's default for this trigger
on:
issue_comment:
types: [created]
jobs:
triage:
runs-on: ubuntu-latest
cache-mode: read
steps:
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
cache: npm

💡 Tips

  • Safe triggers: push, workflow_dispatch, repository_dispatch, delete, registry_package, page_build and schedule, which GitHub lets write the default branch's caches, plus pull_request and its review events, release and merge_group, which run on their own ref and write only its scope.
  • A job-level cache-mode overrides the workflow-level one. A job in a reusable workflow (workflow_call) runs under its callers' events.
  • No cache-mode at all is silent: a low-trust event only reads the cache by default.
  • A constant expression such as ${{ 'write' }} counts as a write grant. An expression reading a context (github.event_name, vars, inputs) makes GitHub reject the workflow file, so it never runs.
  • The finding starts an attack path when another finding already gets code into the job, for example an untrusted expression in a run: script: the path then reaches every job that restores a cache.

⚙️ Configure this control

On the Plumber Platform: open the Policies page and set control CTRL-705 on the policy that governs the project.

With the CLI alone: set it in your configuration file. Every field and default is in the controls configuration reference, CTRL-705.