Skip to content

ISSUE-705 assumes caches are shared across branches, but GitHub isolates them by ref: fire only when an untrusted writer exists in the release scope #533

Closed
getplumber/getplumber.io
#477

Description

@Totara-thib

Describe the bug

releaseWorkflowsMustNotRestoreUntrustedCache (ISSUE-705) fires on every release or publish job that restores a cache whose key is not scoped to the release ref. Its premise, stated in the rule header and on the docs page, is that "GitHub Actions caches are shared across branches with a permissive prefix fallback, so a run on any feature branch, including an attacker's PR, can populate the same key that the release job later restores".

That is not how the cache service works. GitHub's documentation on cache access restrictions says:

Workflow runs can restore caches created in either the current branch or the default branch. If a workflow run is triggered for a pull request, it can also restore caches created in the base branch. Workflow runs cannot restore caches created for child branches or sibling branches. For example, a cache created for the child feature-b branch would not be accessible to a workflow run triggered on the parent main branch.

So a release job running on main (or on a tag) can only restore caches that were written by runs in its own scope or the default branch. A pull request run, from a fork or from a sibling branch, writes to its own scope (refs/pull/N/merge or the branch ref) and nothing on main ever reads it. The prefix fallback of restore-keys searches within the accessible scopes, it does not cross them. On top of that, GitHub now gives low-trust triggers read-only cache access by default (cache-mode), so even a pull_request_target job cannot write a cache unless the workflow sets cache-mode: write explicitly.

The real poisoning path therefore needs a writer inside the release ref's scope that runs attacker-influenced input: a pull_request_target, issue_comment or workflow_run job on the default branch that checks out or executes untrusted content and has cache write access, or a trusted-trigger job that consumes untrusted artifacts before saving the cache. A repository with none of those has no path from a pull request to the release cache, and the ref-scoped key the finding asks for changes nothing except making every release build start cold.

A maintainer pushed back on exactly this when the remediation was proposed, with the branch-isolation argument above, and was right.

To Reproduce

name: publish
on:
  push:
    branches: [main]
  release:
    types: [published]
jobs:
  build-push:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write
    steps:
      - uses: actions/checkout@v4
        with:
          persist-credentials: false
      - uses: actions/cache@v4
        with:
          path: ~/.cache/pip
          key: pip-${{ hashFiles('requirements.txt') }}
          restore-keys: pip-
      - uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - uses: docker/build-push-action@v6
        with:
          push: true
          tags: ghcr.io/example/app:latest
          cache-from: type=gha
          cache-to: type=gha,mode=max

This is the only workflow in the repository: no pull_request_target, no issue_comment, no workflow_run, no pull_request trigger at all, so nothing but a push to main or a release ever writes a cache in the scope this job restores from.

plumber analyze (0.6.0, built-in configuration) reports:

HIGH  ISSUE-705  Release/publish workflow may consume a poisoned build cache (2 findings)

and the repository fails the gate at 80/100.

Expected behavior

ISSUE-705 should fire only when a cache writer with attacker-influenced input exists in a scope the release job restores from (the release ref itself or the default branch), for example:

  • a job on a low-trust trigger (pull_request_target, issue_comment, workflow_run, discussion_comment) on the default branch that saves a cache, which after the cache-mode change means it sets cache-mode: write explicitly, or runs before that default applies;
  • a job on a trusted trigger that executes untrusted content (a checked-out pull request head, a downloaded artifact from an untrusted run) and then saves a cache in the default-branch scope.

ISSUE-802 and ISSUE-804 already identify those shapes, so the rule can reuse their facts. Without such a writer, the restore on the release path is not reachable from a pull request and the finding should stay silent, or at most report an informational "release job restores a cache, no untrusted writer found" line. The ref-scoped key remains a valid hardening recommendation, but it is not a High finding on its own.

The rule header, the finding message and the docs page should also drop the sentence about caches being shared across branches, since it contradicts GitHub's documented behavior and is the first thing a maintainer checks.

Screenshots

Not applicable.

Relevant versions and configuration files

  • OS: Windows 11 (binary plumber-windows-amd64)
  • Platform: GitHub (github.com)
  • Plumber version: 0.6.0 (the finding also fires identically on 0.5.20)
  • .plumber.yaml: none, built-in default configuration

Relevant logs

The finding line above is the whole output for this control.

Additional context

The 2026 cache-poisoning incidents the control cites went through a privileged workflow that executed pull request content on the default branch and then saved the cache, which is the writer condition described above, not through branch sharing. Keeping the control, but anchoring it on that writer, keeps the true positives and removes a finding that maintainers can disprove by reading one paragraph of GitHub's documentation.

Note: If you submit a PR for this bug, please keep "Allow edits from maintainers" enabled so we can collaborate on the fix more easily.

Activity

  1. self-assigned this
    on Oct 13, 2026
  2. added theissue type on Oct 13, 2026
  3. assigned and unassigned on Oct 14, 2026
  4. Exypte commented on Oct 16, 2026

    @Exypte
    Contributor

    I'm working on this one, a fix is on the way.

  5. added a commit that references this issue on Oct 16, 2026
    473d8dd
  6. added a commit that references this issue on Oct 19, 2026
    e8f9e5a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions