--- title: "GitHub Actions Cache Can Expose Secrets to PRs: Fix It" url: https://playciso.com/blog/github-actions-cache-pull-request-credential-exposure updated: 2026-11-19 section: Blog publisher: PlayCISO --- # GitHub Actions Cache Can Expose Secrets to PRs: Fix It > Pull request workflows, forks included, can restore caches from the base branch. If a credential was cached, a PR author can read it. What to fix. Source: https://playciso.com/blog/github-actions-cache-pull-request-credential-exposure · Published: 2026-11-19 · Publisher: PlayCISO (https://playciso.com) Primary source: https://hackread.com/what-github-actions-cache-expose-to-pull-request/ --- 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 | When | What | Source | | --- | --- | --- | | 5 Sep 2025 | GitGuardian discloses GhostAction: malicious workflows pushed from compromised accounts, 3,325 secrets stolen from 817 repositories | GitGuardian | | Ongoing | GitHub's dependency caching reference warns against credentials in cache paths and documents base-branch cache access for pull requests and forks | GitHub Docs | | 18 Nov 2026 | Hackread publishes "What a GitHub Actions Cache Can Expose to Anyone Who Opens a Pull Request" | Hackread | | 19 Nov 2026 | PlayCISO checks each claim against GitHub's current documentation | GitHub Docs | ## What happens, and why GitHub scopes caches by branch. Per its [dependency caching reference](https://docs.github.com/en/actions/reference/workflows-and-actions/dependency-caching#restrictions-for-accessing-a-cache), "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 | Control | What it does | Does 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 requests | The fork run cannot push, merge or change the repository with the token | No. Reading a restored cache needs no write access. | | Pull request caches scoped to the merge ref | A 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 triggers | Only 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 file | Lets a job opt down to read or none | Not against a malicious pull request: a pull_request run uses the workflow file from the pull request itself. | | Approval for outside contributors | Fork workflows wait for a maintainer before they run | Partly. 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." ## 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](/blog/wfx-loot-github-accounts-ci-secrets-stealer). ## 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](/tools/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](/tools/key-rotation-planner) to sequence it. - Cut the token's reach too: set least-privilege permissions: on every workflow; the [GitHub token scope analyzer](/tools/github-token-scope-analyzer) shows what each scope allows. ## How to check your repositories - 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. - 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. - Run gh cache list on each repository and note caches on the default branch: those are the ones pull requests can restore. - Check the repository and organisation setting for fork pull request approvals. - Run the workflow through the [GitHub Actions security auditor](/tools/github-actions-security-auditor), and see the [GitHub supply chain attack anatomy](/tools/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 - [GitHub Docs: Dependency caching reference](https://docs.github.com/en/actions/reference/workflows-and-actions/dependency-caching) (cache warning, restrictions for accessing a cache, low-trust triggers, cache-mode, 7-day eviction; read 19 Nov 2026) - [GitHub Docs: Events that trigger workflows](https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows) (workflows in forked repositories: no secrets, read-only GITHUB_TOKEN) - [GitHub Docs: Controlling changes from forks to workflows in public repositories](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#controlling-changes-from-forks-to-workflows-in-public-repositories) (approval options and the first-time-contributor warning) - [GitHub Docs: Approving workflow runs from forks](https://docs.github.com/en/actions/how-tos/manage-workflow-runs/approve-runs-from-forks) - [GitHub Docs: Managing caches](https://docs.github.com/en/actions/how-tos/manage-workflow-runs/manage-caches) (gh cache, REST API) - [Hackread: What a GitHub Actions Cache Can Expose to Anyone Who Opens a Pull Request](https://hackread.com/what-github-actions-cache-expose-to-pull-request/) (Owais Sultan, 18 Nov 2026; read) - [GitGuardian: The GhostAction Campaign: 3,325 Secrets Stolen Through Compromised GitHub Workflows](https://blog.gitguardian.com/ghostaction-campaign-3-325-secrets-stolen/) (5 Sep 2025; primary; read) **Share:** #GitHubActions #CICD #DevSecOps #SecretsManagement #SupplyChainSecurity #Cybersecurity *This article is general information, not legal or security advice.*