SKY-D372 · CI/CD pipelines
Unverified download reaching the publish step
A job that publishes a package first downloads a file, for example a prebuilt archive from a CDN, and nothing checks its checksum or signature before the publish step runs. Whatever the server returned that day ends up inside the package you ship.
- Languages
- GitHub Actions workflows, GitLab CI
- Quality gate
- Full scan: listed, not counted by the gate. Diff scan: counted toward the gate limits. A diff scan counts a finding whose rule, file and job name are not among the merge base's findings. A baseline scan counts it like a diff scan when the baseline's
rule_coveragelists it. - Finding type
- review
Why it matters
Whoever controls the download server, or the account that uploads to it, controls part of your release. The @subql 5.8.3 release swapped a package folder for such an archive, and users installed it from the official registry.
What Skylos flags
name: Publish SDKon: release: types: [published]permissions: contents: readjobs: npm: runs-on: ubuntu-latest steps: - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 with: persist-credentials: false - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 with: node-version: 22 registry-url: https://registry.npmjs.org - run: npm ci - name: Fetch prebuilt native binaries run: | curl -fsSL -o prebuilt.tar.gz https://dl.acme.example/sdk/prebuilt.tar.gz tar -xzf prebuilt.tar.gz -C packages/sdk/prebuilt - run: npm publish ./packages/sdk --access public env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}What Skylos leaves alone
name: Publish SDKon: release: types: [published]permissions: contents: readjobs: npm: runs-on: ubuntu-latest steps: - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 with: persist-credentials: false - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 with: node-version: 22 registry-url: https://registry.npmjs.org - run: npm ci - name: Fetch prebuilt native binaries run: | curl -fsSL -o prebuilt.tar.gz https://dl.acme.example/sdk/prebuilt.tar.gz gh attestation verify prebuilt.tar.gz --repo acme/sdk-native tar -xzf prebuilt.tar.gz -C packages/sdk/prebuilt env: GH_TOKEN: ${{ github.token }} - run: npm publish ./packages/sdk --access public env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}Why Skylos leaves it alone
The same archive is downloaded and published, but gh attestation verify checks GitHub's build attestation for it before it is unpacked, so a swapped file stops the job.
More languages
YAML
Flagged
stages: [publish] publish: stage: publish image: node:22-slim rules: - if: $CI_COMMIT_TAG script: - npm ci - curl -fsSL -o dist.tgz https://cdn.acme.example/web/dist.tgz - tar -xzf dist.tgz -C packages/web/dist - npm publish ./packages/webNot flagged
stages: [publish] publish: stage: publish image: node:22-slim rules: - if: $CI_COMMIT_TAG script: - npm ci - curl -fsSL -o dist.tgz https://cdn.acme.example/web/dist.tgz - sha256sum -c release/dist.tgz.sha256 - tar -xzf dist.tgz -C packages/web/dist - npm publish ./packages/web0000000000000000000000000000000000000000000000000000000000000000 dist.tgzWhy Skylos leaves it alone
sha256sum -c compares the archive with a checksum committed to the repository before it is unpacked, so a changed file fails the job.
How Skylos decides
- Runs with
--danger(and-a). Theca9library reads every*.ymland*.yamlfile directly in.github/workflows, the local composite actions they call, and.gitlab-ci.ymlwith its local includes. - Finds downloads in
run:steps and GitLab script lines:curlwith-o,-Oor a redirect to a file,wget,gh release download,Invoke-WebRequest -OutFile, andcurl … | tar -x. Uploads (curl --data,--form,-T) and downloads to standard output or/dev/are not downloads. - Follows the file: a later
tar -xorunzipof it says where it is unpacked,mvorcpwhere it moves. A download that is only run as a tool from abinfolder or outside the workspace is left to SKY-D371. - Reports the download when it lands in the workspace and the job publishes after it (a publish command later in the job, or a publish credential the job holds), unless a checksum check (
sha256sum -cand the other*sumprograms, or a comparison with a hash) or a signature check (gpg --verify,cosign verify-blob,slsa-verifier,minisign -V,gh attestation verify) comes after it and names the file or is in the same step. - Reports one HIGH finding per unverified download, on the download's line.
How to fix it
Do not publish files fetched at release time when you can build them in the job. If you must, download a fixed, versioned URL and check it against a checksum committed to the repository, or verify its signature or attestation, before it is unpacked.
name: Publish SDKon: release: types: [published]permissions: contents: readjobs: npm: runs-on: ubuntu-latest steps: - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 with: persist-credentials: false - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 with: node-version: 22 registry-url: https://registry.npmjs.org - run: npm ci - name: Fetch prebuilt native binaries run: |Removed: curl -fsSL -o prebuilt.tar.gz https://dl.acme.example/sdk/prebuilt.tar.gzAdded: curl -fsSL -o prebuilt.tar.gz \Added: https://dl.acme.example/sdk/v1.4.0/prebuilt.tar.gzAdded: sha256sum -c packages/sdk/prebuilt.sha256 tar -xzf prebuilt.tar.gz -C packages/sdk/prebuilt - run: npm publish ./packages/sdk --access public env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}When it can be wrong
- Any checksum or signature command in the same step counts as a check of the file, even one that checks a different file.
- A download in a job that only holds a publish credential is reported even when no step ever packs the file, because the credential is treated as a publish at the end of the job.
- The flagged example also gets SKY-D364 for the stored npm token. It is a separate finding about the same job.
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
Skylos reads no inline marker for this rule, neither as a YAML comment nor as a shell comment inside the
run:block.Accept a reviewed job with a baseline:
skylos baseline ., then--baseline. The entry matches the rule, file and job name, not the line. In pull-request CI (SKYLOS_POLICY_BASE), the entry must also be in the base commit's.skylos/baseline.json.[tool.skylos] ignore = ["SKY-D372"]turns the rule off for the whole project.