SKY-D309 · CI/CD pipelines
Secret in a workflow-wide or job-wide environment
Variables under a workflow's or job's env: are passed to every step below them. SKY-D309 reports a secret placed there, because every command and action in that scope receives it, not only the step that needs it.
- Languages
- GitHub Actions workflows
- Quality gate
- counted toward the gate limits (full and diff scans)
- Finding type
- review
- Catalog name
- GitHub Actions broad secret environment
Why it matters
Each extra step is another chance to leak the secret. A compromised dependency's install script in the test job, or a third-party action that sends its environment home, can read a deploy key that only the upload step needed.
What Skylos flags
name: Deployon: push: branches: [main]permissions: contents: readenv: AWS_REGION: eu-west-1 SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}jobs: test: name: Test runs-on: ubuntu-latest timeout-minutes: 15 steps: - uses: actions/checkout@v4 with: persist-credentials: false - run: npm ci - run: npm test sourcemaps: name: Upload source maps needs: test runs-on: ubuntu-latest timeout-minutes: 15 steps: - uses: actions/checkout@v4 with: persist-credentials: false - run: ./scripts/upload-sourcemaps.sh dist/What Skylos leaves alone
name: Deployon: push: branches: [main]permissions: contents: readenv: AWS_REGION: eu-west-1jobs: test: name: Test runs-on: ubuntu-latest timeout-minutes: 15 env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v4 with: persist-credentials: false - run: npm ci - run: npm test sourcemaps: name: Upload source maps needs: test runs-on: ubuntu-latest timeout-minutes: 15 steps: - uses: actions/checkout@v4 with: persist-credentials: false - name: Upload to Sentry env: SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} run: ./scripts/upload-sourcemaps.sh dist/Why Skylos leaves it alone
The Sentry token is set on the one step that uploads, so npm ci in the test job never sees it. The job-wide GH_TOKEN holds the job's own GITHUB_TOKEN, a short-lived token limited by permissions:; the rule leaves that name out. Plain values such as AWS_REGION are not secrets.
How Skylos decides
- Reads workflow files under
.github/workflows. Composite actions are not checked. - Looks at the workflow's top-level
env:and each job'senv:. Jobs that call a reusable workflow (jobs.<id>.uses) are skipped. Stepenv:, container and service environments are not read. - Reports a variable whose string value contains a
${{ … }}expression that namessecrets.<NAME>, for any name exceptGITHUB_TOKEN.toJSON(secrets)andsecrets[...]are not matched here. - Gives HIGH for the workflow
env:and MEDIUM for a jobenv:. One finding per variable, on the first line of the file that contains its value.
How to fix it
Move the secret to the env: of the step that uses it. A step-level variable reaches only that step's command or action.
name: Deployon: push: branches: [main]permissions: contents: readenv: AWS_REGION: eu-west-1Removed: SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}jobs: test: name: Test runs-on: ubuntu-latest timeout-minutes: 15 steps: - uses: actions/checkout@v4 with: persist-credentials: false - run: npm ci - run: npm test sourcemaps: name: Upload source maps needs: test runs-on: ubuntu-latest timeout-minutes: 15 steps: - uses: actions/checkout@v4 with: persist-credentials: falseRemoved: - run: ./scripts/upload-sourcemaps.sh dist/Added: - name: Upload to SentryAdded: env:Added: SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}Added: run: ./scripts/upload-sourcemaps.sh dist/When it can be wrong
- A job whose only step needs the secret is still reported for its job-level
env:, although moving the variable changes nothing. - Any secret counts, including values that are not credentials, such as a secret that holds a URL.
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-D309] <reason>on the reported line or on the line directly above it, one rule per marker.YAML env: # skylos: ignore[SKY-D309] every step in this job signs artifacts SIGNING_KEY: ${{ secrets.SIGNING_KEY }}[tool.skylos] ignore = ["SKY-D309"]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.