Skip to main content

SKY-D309 · CI/CD pipelines

Secret in a workflow-wide or job-wide environment

High

HIGH when the secret is in the workflow's top-level env:, which every job and step inherits. MEDIUM when it is in one job's env:.

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
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

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

.github/workflows/deploy.yml · YAMLReported on line 9
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

.github/workflows/deploy.yml · YAML
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

  1. Reads workflow files under .github/workflows. Composite actions are not checked.
  2. Looks at the workflow's top-level env: and each job's env:. Jobs that call a reusable workflow (jobs.<id>.uses) are skipped. Step env:, container and service environments are not read.
  3. Reports a variable whose string value contains a ${{ … }} expression that names secrets.<NAME>, for any name except GITHUB_TOKEN. toJSON(secrets) and secrets[...] are not matched here.
  4. Gives HIGH for the workflow env: and MEDIUM for a job env:. 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.

.github/workflows/deploy.yml · YAML · the fix, against the flagged file
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.

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.