Mitigate GitHub Actions cache poisoning
mainTo prevent cache poisoning in CI/CD pipelines, follow these security guidelines:
Workflow Permissions and Scopes
- Untrusted PR workflows must not receive secrets, publish permissions, or OIDC rights.
- Do not use
pull_request_targetto checkout and execute untrusted PR code. - Set
GITHUB_TOKENpermissions minimally per workflow or job.
Cache Management Best Practices
- Release, publish, and deploy workflows should not restore caches.
- If caches are used, keep them in unprivileged CI jobs.
- Avoid broad
restore-keys. - Do not cache executable or build-relevant artifacts such as
node_modules,dist,build,.angular/cache, or.nx/cachein sensitive workflows.
Dependency and Action Security
- Pin third-party GitHub Actions to full commit SHAs where possible.
- Prefer npm installs with
npm ci --ignore-scripts. - Do not run
npm installon production servers that have access to secrets.
Note for this repository: Existing workflow cache usage is intentionally not removed automatically. Review any cache used in release, publish, or deploy workflows before relying on it for sensitive jobs.