SKY-D298 · CI/CD pipelines
Workflow reads the whole secrets context
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
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
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
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
- Reads workflow files under
.github/workflowsandaction.yml/action.yamlfiles. - Looks at every text value in the file:
run:scripts,env:,with:inputs,if:conditions and the rest. Keys are not read. - Reports a
${{ … }}expression that containstoJSON(secrets), orsecrets[…]whose index is not a quoted name, in any letter case.secrets['EU_TOKEN']andsecrets.EU_TOKENare not reported. - 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.
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.