SKY-D320 · CI/CD pipelines
GitLab CI release job restores a cache
A GitLab cache: keeps files such as downloaded packages between jobs and pipelines. SKY-D320 reports a job that releases or deploys and still restores a cache, its own or one it inherits from default: or the top of the file.
- Languages
- GitLab CI
- Quality gate
- counted toward the gate limits (full and diff scans)
- Finding type
- review
- Catalog name
- GitLab CI release cache poisoning risk
Why it matters
Other jobs and pipelines write the same cache, and GitLab keeps a separate one only for protected branches and tags. A job on a less trusted ref that uses the same key can leave a tampered package in .npm/, and the release job then installs it and ships it to your users.
What Skylos flags
stages: [test, release] default: image: node:22-bookworm cache: key: files: [package-lock.json] paths: [.npm/] test: stage: test script: - npm ci --cache .npm --prefer-offline - npm test publish: stage: release timeout: 15 minutes rules: - if: $CI_COMMIT_TAG script: - npm ci --cache .npm --prefer-offline - npm publishWhat Skylos leaves alone
stages: [test, release] default: image: node:22-bookworm test: stage: test cache: key: files: [package-lock.json] paths: [.npm/] script: - npm ci --cache .npm --prefer-offline - npm test publish: stage: release timeout: 15 minutes rules: - if: $CI_COMMIT_TAG script: - npm ci - npm publishWhy Skylos leaves it alone
Only the test job uses the cache. The publish job sets no cache and inherits none, so it installs every package fresh from the registry.
How Skylos decides
- Runs with
--danger(and-a). Reads every file named exactly.gitlab-ci.ymlin the scanned folder, skipping.git,node_modules,.venv,venv,build,distand cache folders. Files pulled in withinclude:are not read, and a file PyYAML's safe loader cannot read (for example one that uses!reference) is skipped. - Picks release-like jobs, hidden
.templatejobs excluded: the job name containsdeploy,releaseorpublish; itsstageisdeploy,deployment,release,publishorproduction; itsenvironmentisprodorproduction; it hasrelease,id_tokensoridentity; or a command starts with a publish or deploy tool such asdocker push,npm publish,twine upload,cargo publish,helm upgrade,kubectl applyorterraform apply. - Takes the job's
cache(its own, else fromdefault:, else top-level). Any value exceptfalse,[],{}or none counts as on. - One MEDIUM finding per job, on the first line that contains the job name followed by
:.
How to fix it
Turn the cache off in release and deploy jobs with cache: [], or give them a key no other job writes. Pass build output to them as artifacts from a job in the same pipeline.
stages: [test, release] default: image: node:22-bookworm cache: key: files: [package-lock.json] paths: [.npm/] test: stage: test script: - npm ci --cache .npm --prefer-offline - npm test publish: stage: release timeout: 15 minutesAdded: cache: [] rules: - if: $CI_COMMIT_TAG script:Removed: - npm ci --cache .npm --prefer-offlineAdded: - npm ci - npm publishWhen it can be wrong
- A cache with its own key that only release jobs write is reported the same as a shared one.
- A job is release-like by name alone, so
release-notes-previewwith a cache is reported. - The flagged example also gets SKY-D340 for
npm publish; that rule is separate.
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-D320]and a reason on the reported line, or on the line directly above it. Skylos looks for that exact text, so write one rule per marker, with the ID in upper case.YAML # skylos: ignore[SKY-D320] cache key is written only by release jobspublish:[tool.skylos] ignore = ["SKY-D320"]turns the rule off for the whole project.