Skip to content
All posts

GitHub Actions Cache Can Expose Secrets to PRs: Fix It

November 19, 2026 · Team PlayCISO
TL;DR · the short version

On 18 November 2026 Hackread (Owais Sultan) warned that a GitHub Actions cache can hand credentials to anyone who opens a pull request. This is documented GitHub behaviour, not a new vulnerability: GitHub's dependency caching reference says a workflow run triggered by a pull request can restore caches created in the base branch, that anyone with read access can create a pull request and access the contents of a cache, and that forks can do the same against the base branch. Fork pull request workflows get no repository secrets and a read-only GITHUB_TOKEN, and GitHub's cache-poisoning protections limit who can write caches, but none of that stops a cache being read. So a docker login file, a package-manager token, cloud CLI credentials or a .env file inside a broad cached path on main is readable by a pull request author. GitHub deletes caches not accessed for 7 days, which does not revoke a credential already copied. Fix: narrow cache paths, keep credentials out of them, use OIDC, require approval for outside contributors, audit caches and rotate anything that was cached.

Put it into practice
Audit a workflow for secrets exposure
Paste a workflow and check it for broad permissions, unpinned actions and risky secret handling.
Open the GitHub Actions Security Auditor

On 18 November 2026, Hackread (Owais Sultan) warned that a GitHub Actions cache can hand credentials to anyone who can open a pull request, including contributors working from a fork. This is not a new vulnerability. It is documented GitHub behaviour: a pull request workflow can restore caches created on the base branch, and GitHub's own docs say "anyone with read access can create a pull request on a repository and access the contents of a cache". If a trusted run on main ever wrote a registry login, a package token, cloud CLI credentials or a .env file into a cached path, a pull request can read it, even though it never sees a single repository secret.

Who this is for: anyone who maintains GitHub repositories that use Actions caching, especially public repositories that accept outside pull requests, and the security leaders who own CI secrets.

Independent analysis. PlayCISO is not affiliated with GitHub, Hackread or GitGuardian. Facts are as published by 19 November 2026.

Confirmed vs not yet known

Confirmed by GitHub's documentation: pull request runs can restore caches from the base branch, forks included; anyone with read access can open a pull request and access cache contents; fork workflows get no secrets and a read-only GITHUB_TOKEN; a pull request's own cache is scoped to its merge ref; unaccessed caches are removed after 7 days; by default only first-time contributors need approval before their fork workflows run.

Reported by Hackread, not independently checked: that 64% of valid secrets from 2022 were still not revoked in 2026 (Hackread cites a GitGuardian report).

Not known: any specific repository, incident or victim. Hackread names none, describes no new research, and we found no GitHub statement about the article.

Timeline

WhenWhatSource
5 Sep 2025GitGuardian discloses GhostAction: malicious workflows pushed from compromised accounts, 3,325 secrets stolen from 817 repositoriesGitGuardian
OngoingGitHub's dependency caching reference warns against credentials in cache paths and documents base-branch cache access for pull requests and forksGitHub Docs
18 Nov 2026Hackread publishes "What a GitHub Actions Cache Can Expose to Anyone Who Opens a Pull Request"Hackread
19 Nov 2026PlayCISO checks each claim against GitHub's current documentationGitHub Docs

What happens, and why

GitHub scopes caches by branch. Per its dependency caching reference, "workflow runs can restore caches created in either the current branch or the default branch", and "if a workflow run is triggered for a pull request, it can also restore caches created in the base branch, including base branches of forked repositories". The actions/cache lookup tries the pull request's branch first and then falls back to the default branch.

That fallback is what makes caches fast for contributors, and it is also the exposure. A pull_request run executes the code in the pull request, so whatever a cache restores onto the runner is readable by that code. GitHub's note on the cache action says it plainly: "We recommend that you don't store any sensitive information, such as access tokens or login credentials, in files in the cache path. Anyone with read access can create a pull request on a repository and access the contents of a cache. Additionally, forks of a repository can create pull requests on the base branch and access caches on the base branch."

For a public repository, "anyone with read access" is everyone. For a private repository it is everyone you have given read access, which is often more people than hold its secrets.

What is protected, and what is not

ControlWhat it doesDoes it stop a cache read?
No secrets for fork workflows"With the exception of GITHUB_TOKEN, secrets are not passed to the runner when a workflow is triggered from a forked repository" (GitHub)No. A cached file is not a secret.
Read-only GITHUB_TOKEN on fork pull requestsThe fork run cannot push, merge or change the repository with the tokenNo. Reading a restored cache needs no write access.
Pull request caches scoped to the merge refA cache a pull request creates "can only be restored by re-runs of the pull request", not by the base branch (GitHub)No. It stops poisoning main, not reading main.
Read-only cache access for low-trust triggersOnly trusted triggers such as push, schedule and workflow_dispatch can write the default branch's caches; pull_request_target, issue_comment and workflow_run get read-only access (GitHub)No. Read-only still means read.
cache-mode in the workflow fileLets a job opt down to read or noneNot against a malicious pull request: a pull_request run uses the workflow file from the pull request itself.
Approval for outside contributorsFork workflows wait for a maintainer before they runPartly. It works only if the reviewer reads the change before approving, and by default it covers first-time contributors only.

Hackread sums it up in one line: "The cache is shared more widely than the secrets are."

Useful next, if this was relevant to you

Showing 1 of 3: Breach Cost Calculator

What commonly ends up in a cache

Hackread says the usual cause is a cache path that is too broad, such as the whole home directory or the whole workspace, chosen to raise the hit rate. Files that then come along:

  • ~/.docker/config.json: docker login stores registry credentials there by default.
  • ~/.npmrc, ~/.pypirc, ~/.m2/settings.xml, ~/.gradle/gradle.properties, ~/.nuget/NuGet/NuGet.Config: package-manager configs that can hold publish or private-registry tokens.
  • ~/.aws, ~/.azure, ~/.config/gcloud, ~/.kube: cloud CLI and cluster credentials.
  • .env files, generated config, and build outputs with keys embedded at build time.
  • SSH keys and Git credential helpers' stores, if a job wrote them under a cached directory.

The built-in caching in the setup-* actions (for example cache: npm) caches the package manager's download cache, which is normally narrow. The bigger risk is a hand-written actions/cache step with a wide path:.

Why the 7-day eviction does not help

GitHub "will remove any cache entries that have not been accessed in over 7 days". That removes the copy GitHub holds; it does nothing to a credential that a pull request run already restored and copied. And a cache that main keeps restoring is accessed every run, so it never ages out. Hackread cites a GitGuardian report that 64% of valid secrets from 2022 were still not revoked in 2026: a stolen token tends to stay valid for a long time. Rotation, not eviction, is the fix.

Where GhostAction fits

Hackread uses GhostAction as evidence that attackers go after CI credentials. In GitGuardian's account (5 September 2025), attackers using compromised GitHub accounts read each repository's legitimate workflow files to learn its secret names, then pushed a malicious "Github Actions Security" workflow with those names hardcoded that sent the values to a remote server, stealing 3,325 secrets from 817 repositories belonging to 327 users. GhostAction did not use caches: it needed write access. The point carries over anyway: CI credentials are a target, and a cache is one more place they can be found. For this month's account-takeover campaign, see our wfx-loot write-up.

What security leaders should do this week

  • Narrow every path: in actions/cache steps to the dependency and build directories that are slow to rebuild (for example ~/.npm, ~/.cache/pip, ~/.gradle/caches). Never cache ~, the workspace root, or a directory a login command writes to.
  • Keep credentials out of files. Pass them through step-level env: from secrets, log out (docker logout) and delete credential files before any cache-save step, or write them under $RUNNER_TEMP, which you never cache.
  • Use OIDC for cloud access instead of long-lived keys, with roles scoped to one repository and branch, so there is no durable key to cache in the first place. Our GitHub CI secret hardening tool walks through it.
  • Require approval for all external contributors on public repositories (Settings, Actions, General, "Approval for running fork pull request workflows from contributors"). GitHub warns that the first-time-contributor options are bypassed once someone has had any change merged, and "a simple typo or other innocuous change" is enough.
  • Read fork changes before approving, especially anything under .github/workflows/ and build or test scripts, as GitHub's approval guide says.
  • Audit existing caches. List them with gh cache list or the REST API (GET /repos/{owner}/{repo}/actions/caches), match each key to the workflow that writes it, and check whether that path could contain credentials.
  • Rotate first, then delete. For any cache that may have held a credential, replace the credential, then remove the cache (gh cache delete). Deleting first only removes the evidence. Use our key rotation planner to sequence it.
  • Cut the token's reach too: set least-privilege permissions: on every workflow; the GitHub token scope analyzer shows what each scope allows.

How to check your repositories

  1. Search your workflows for every actions/cache (and actions/cache/save) step and print its path:. Flag ~, $HOME, ., ${{ github.workspace }} and any dot-directory that a CLI logs into.
  2. For each flagged step, check whether an earlier step in the same job runs docker login, writes an .npmrc or similar, configures a cloud CLI, or creates a .env.
  3. Run gh cache list on each repository and note caches on the default branch: those are the ones pull requests can restore.
  4. Check the repository and organisation setting for fork pull request approvals.
  5. Run the workflow through the GitHub Actions security auditor, and see the GitHub supply chain attack anatomy for how CI credentials get used once taken.

FAQ

Can a fork pull request read my GitHub Actions cache?

Yes, by design. GitHub's dependency caching reference says a workflow run triggered by a pull request can restore caches created in the base branch, and that forks of a repository can create pull requests on the base branch and access caches there. GitHub recommends never storing access tokens or login credentials in files in a cache path.

Is this a new GitHub vulnerability?

No. It is documented cache scoping, and GitHub's docs already warn about it. Hackread's 18 November 2026 article is a warning about how teams misuse the cache; it reports no new flaw, no incident and no victims, and we found no GitHub statement about it.

If fork workflows get no secrets, how can a credential leak?

Secrets are not passed to fork workflows and their GITHUB_TOKEN is read-only, but a cache is not a secret. If a trusted run on main wrote a credential into a cached path (for example ~/.docker/config.json after docker login), a pull request run can restore that cache and read the file without ever having access to the secret itself.

Does GitHub's cache-poisoning protection stop this?

No. Those protections control who can write caches: a pull request's cache is scoped to its merge ref, and low-trust triggers get read-only access to the default branch's caches. They limit writing, not reading. A pull request can still restore what main has cached.

Does the 7-day cache eviction fix it?

No. GitHub removes cache entries not accessed in over 7 days, but a credential copied out before that is still valid until you revoke it. Rotate any credential that was ever in a cached path, then delete the cache.

What should I never put in a GitHub Actions cache?

Credentials of any kind: ~/.docker/config.json, an .npmrc or other package-manager config holding a token, ~/.aws, ~/.azure, ~/.config/gcloud, ~/.kube, SSH keys, .env files and build outputs with embedded secrets. Never cache a whole home directory or the whole workspace.

How was GhostAction related to caches?

It was not a cache attack. GitGuardian reported in September 2025 that GhostAction used compromised accounts to push malicious workflows whose secret names were copied from the repositories' own workflow files, stealing 3,325 secrets from 817 repositories. Hackread cites it to show how much attackers want CI credentials.

Sources

Share: #GitHubActions #CICD #DevSecOps #SecretsManagement #SupplyChainSecurity #Cybersecurity

This article is general information, not legal or security advice.

Audit a workflow for secrets exposure
Paste a workflow and check it for broad permissions, unpinned actions and risky secret handling.
Open the GitHub Actions Security Auditor
Take this with you
Timeline · What happens, and why · What is protected, and what is not · What commonly ends up in a cache · Why the 7-day eviction does not help · Where GhostAction fits

Ready to practise the decisions these articles describe?

Run your first Cyber War Room free →

Pro