SKY-D308 · CI/CD pipelines
Release build restores a CI cache
Caching actions such as actions/cache or actions/setup-node with cache: npm restore files saved by earlier runs before the build starts. SKY-D308 reports a release workflow that builds from such a cache, and a job outsiders can start that is allowed to write the cache.
- Languages
- GitHub Actions workflows
- Quality gate
- counted toward the gate limits (full and diff scans)
- Finding type
- review
- Catalog name
- GitHub Actions cache poisoning risk
Why it matters
A cache entry is shared state. If an attacker can get one poisoned entry saved, for example a tampered node_modules from a workflow that runs pull request code, the next tagged release restores it and ships the attacker's code to every user of the package.
What Skylos flags
name: Releaseon: push: tags: ["v*"]permissions: contents: readjobs: build: name: Build runs-on: ubuntu-latest timeout-minutes: 20 steps: - uses: actions/checkout@v4 with: persist-credentials: false - uses: actions/setup-node@v4 with: node-version: 22 cache: npm - run: npm ci --ignore-scripts - run: npm run build - uses: actions/upload-artifact@v4 with: name: bundle path: dist/ if-no-files-found: errorWhat Skylos leaves alone
name: CIon: push: branches: [main] pull_request:permissions: contents: readjobs: test: name: Test runs-on: ubuntu-latest timeout-minutes: 20 steps: - uses: actions/checkout@v4 with: persist-credentials: false - uses: actions/setup-node@v4 with: node-version: 22 cache: npm - run: npm ci --ignore-scripts - run: npm testWhy Skylos leaves it alone
The same cached setup in an ordinary CI workflow is fine. It is not a release workflow (no release trigger and no tag push), and pull_request runs cannot save entries that runs on main restore. Caching speeds up tests; only the build you ship should start clean.
How Skylos decides
- Reads workflow files under
.github/workflows. Composite actions are not checked for this rule. - Release check: a workflow is release-like when its
on:includesrelease, or apushwith atagsfilter. In such a workflow every step is checked, whatever its job orif:.actions/cache,mozilla-actions/sccache-actionandnix-community/cache-nix-actionalways count. Setup actions from a fixed list (actions/setup-node,setup-python,setup-java,setup-go,astral-sh/setup-uv,ruby/setup-rubyand others) count when a cache input such ascache,enable-cache,use-cacheorbundler-cacheis present and is not a literal false (false,0,no,off). Reported as MEDIUM on the step'suses:line. - Default caches: in the same release-like workflows, a step that can run on the release or tag-push event (its job's and its own
if:allow it) and uses an action that caches without being asked:actions/setup-gov4 and later,jdx/mise-action,actions-rust-lang/setup-rust-toolchain,mlugg/setup-zig,Swatinem/rust-cache,oven-sh/setup-bun,gradle/actions/setup-gradle,ramsey/composer-install,astral-sh/setup-uvv5 to v9 on GitHub-hosted runners, andactions/setup-nodev5 and later after a checkout, when the rootpackage.jsonnames npm as its package manager. The input that turns each one off, or a jobcache-modeother thanreadorwrite, clears it. A version comes from the tag, or from a# v5comment after a commit pin. MEDIUM. - Cache writes: a job that an account without write access can start (
issues,issue_comment,pull_request_target, discussion events, orworkflow_runafter a fork-reachable workflow; notpull_request_review) withcache-mode: writeorwrite-onlyon the job or workflow, or passed down by a local workflow that calls it. It is reported only when a step those accounts reach checks out pull request code, expands event text into its script, or downloads the triggering run's artifacts. HIGH, on thecache-modeline. - In the release check, steps with the same
uses:text report once, on the first line that contains it.
How to fix it
Build releases from a clean state: drop the cache input in the release workflow and keep caching in CI. From actions/setup-node v5, also set package-manager-cache: false, because it caches npm by default. For a job outsiders can start, use cache-mode: read and save caches from a push-triggered workflow.
name: Releaseon: push: tags: ["v*"]permissions: contents: readjobs: build: name: Build runs-on: ubuntu-latest timeout-minutes: 20 steps: - uses: actions/checkout@v4 with: persist-credentials: false - uses: actions/setup-node@v4 with: node-version: 22Removed: cache: npm - run: npm ci --ignore-scripts - run: npm run build - uses: actions/upload-artifact@v4 with: name: bundle path: dist/ if-no-files-found: errorWhen it can be wrong
- Any cache input that is not a literal false counts as on, so
cache: ""andcache: ${{ inputs.cache }}are reported althoughactions/setup-nodetreats an empty value as no cache. - The release check covers every job in the workflow, including a test job that ships nothing.
- Some restores are missed:
actions/cache/restoreis not on the list, and a release started byworkflow_dispatchor a branch push is not release-like.
Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.
How to silence it
Put
# skylos: ignore[SKY-D308] <reason>on the reporteduses:line or on the line directly above it, one rule per marker. For the default-cache andcache-modefindings the marker must be a real YAML comment.YAML # skylos: ignore[SKY-D308] cache key includes the lockfile hash- uses: actions/setup-node@v4[tool.skylos] ignore = ["SKY-D308"]turns the rule off for the whole project. A baseline also works, but it records the absolute file path and line, so it stops matching when the checkout moves or lines above the finding change.