Skip to main content

SKY-D298 · CI/CD pipelines

Workflow reads the whole secrets context

High

The catalog lists HIGH, but the detector reports every finding as MEDIUM.

GitHub normally sends a job only the secrets its expressions name, such as secrets.EU_TOKEN. When an expression picks a secret by a computed name (secrets[format(...)]) or turns all of them into JSON (toJSON(secrets)), GitHub cannot tell which ones are needed and sends every secret the workflow can read. SKY-D298 reports those expressions.

Languages
GitHub Actions workflows, composite actions
Quality gate
counted toward the gate limits (full and diff scans)
Finding type
review
Catalog name
GitHub Actions overprovisioned secrets
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

Every step and action in the job then runs on a machine that holds all of the repository's and organization's secrets, not just the deploy token it needed. A compromised dependency or action in that job can read the publish token, cloud keys and the rest.

What Skylos flags

.github/workflows/deploy.yml · YAMLReported on line 20
name: Deployon:  push:    branches: [main]permissions:  contents: readjobs:  deploy:    runs-on: ubuntu-latest    strategy:      matrix:        region: [eu, us]    steps:      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683        with:          persist-credentials: false      - run: ./scripts/deploy.sh "$REGION"        env:          REGION: ${{ matrix.region }}          TOKEN: ${{ secrets[format('{0}_TOKEN', matrix.region)] }}

What Skylos leaves alone

.github/workflows/deploy.yml · YAML
name: Deployon:  push:    branches: [main]permissions:  contents: readjobs:  deploy:    runs-on: ubuntu-latest    strategy:      matrix:        region: [eu, us]    steps:      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683        with:          persist-credentials: false      - run: ./scripts/deploy.sh "$REGION"        env:          REGION: ${{ matrix.region }}          TOKEN: ${{ matrix.region == 'eu' && secrets.EU_TOKEN || secrets.US_TOKEN }}

Why Skylos leaves it alone

The token still depends on the region, but both possible secrets are named in full. GitHub sends just those two, and Skylos only reports a computed name or the whole context.

How Skylos decides

  1. Reads workflow files under .github/workflows and action.yml / action.yaml files.
  2. Looks at every text value in the file: run: scripts, env:, with: inputs, if: conditions and the rest. Keys are not read.
  3. Reports a ${{ … }} expression that contains toJSON(secrets), or secrets[…] whose index is not a quoted name, in any letter case. secrets['EU_TOKEN'] and secrets.EU_TOKEN are not reported.
  4. One MEDIUM finding per value, on the first line of the file that contains the value's first line.

How to fix it

Give each region a GitHub environment that holds its own TOKEN secret, and let the job pick the environment. The step then names one secret, and each environment can also require an approval.

.github/workflows/deploy.yml · YAML · the fix, against the flagged file
name: Deployon:  push:    branches: [main]permissions:  contents: readjobs:  deploy:    runs-on: ubuntu-latest    strategy:      matrix:        region: [eu, us]Added:     environment: production-${{ matrix.region }}    steps:      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683        with:          persist-credentials: false      - run: ./scripts/deploy.sh "$REGION"        env:          REGION: ${{ matrix.region }}Removed:           TOKEN: ${{ secrets[format('{0}_TOKEN', matrix.region)] }}Added:           TOKEN: ${{ secrets.TOKEN }}

When it can be wrong

  • A computed index whose possible names are all listed nearby, such as a matrix of two regions, is reported the same as one fed from outside input.
  • The finding sits on the first line of the file that contains the same text, which can be an earlier copy of the expression.

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-D298] on the reported line or on the line directly above it, one rule per marker.

    YAML
    env:  # skylos: ignore[SKY-D298] repo holds only these two deploy tokens  TOKEN: ${{ secrets[format('{0}_TOKEN', matrix.region)] }}
  • [tool.skylos] ignore = ["SKY-D298"] turns the rule off for the whole project.

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