→ Back to Home
CI/CD

Hardening CI/CD: GitHub Actions Enforces Least Privilege Caching with cache-mode

GitHub has made `cache-mode` generally available across all GitHub Actions plans, providing native syntax to restrict cache permissions at both workflow and individual job levels. The new parameter accepts four discrete operational modes: `read` (permitting cache restoration while denying writes), `write` (allowing standard bidirectional read/write behavior), `write-only` (enabling cache population while bypassing restores), and `none` (completely disabling cache interactions). The setting is enforced directly by the GitHub Actions cache service via scoped tokens and automatically propagates down through reusable workflows, guaranteeing that downstream child pipelines cannot elevate cache privileges beyond what their caller allows. This enhancement directly tackles a persistent vulnerability vector in modern CI/CD security: cache poisoning. In shared build environments, untrusted external contributions—particularly those triggered via `pull_request_target` or fork-based pipelines—can overwrite or corrupt cached binaries and dependencies if write access is left unrestricted. Once a compromised cache entry is saved, subsequent runs on trusted branches (such as release builds or main branch deployments) may unknowingly restore the contaminated artifact, executing adversary-controlled code within a privileged execution context. By giving platform engineers explicit levers to limit pull requests to `read` mode, GitHub allows developers to maintain rapid build times without exposing downstream pipelines to integrity risks. This release reflects a broader shift across DevOps and cloud-native ecosystems toward securing the software supply chain through zero-trust, least-privilege pipeline primitives. Over recent years, CI/CD engines have systematically eliminated broad default permissions—such as default write access on repository tokens—in favor of explicit declaration models. Treating build artifacts and ephemeral caches with the same rigor as access tokens and cloud secrets recognizes that pipeline storage can be weaponized as an indirect code execution channel. In practice, DevOps teams should audit existing workflow configurations and establish standard caching tiers across their repositories. Unprivileged jobs, like linting and unit testing on incoming pull requests, should be explicitly set to `cache-mode: read`. Dedicated cache-warming or matrix compilation jobs on protected branches can leverage `write-only` or `write` to maintain fresh dependencies. Engineering leads should note that blocked cache operations intentionally degrade silently as cache misses or skipped saves rather than failing builds, which requires teams to monitor pipeline durations and GitHub workflow warning annotations to verify that cache access policies are properly configured.
#github actions#security#devops#supply chain
Read original source