Skip to main content

SKY-D362 · CI/CD pipelines

GitHub Actions decoded secret printed unmasked

Medium

Some teams store several values in one secret as JSON and read a field with fromJSON(secrets.X).field. GitHub hides only the exact text it stored, so the decoded field is a new string the log does not mask. SKY-D362 reports such a value when it sits where GitHub prints it.

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

Why it matters

GitHub shows a step's env:, its with: inputs and its script in the job log. A decoded API key in one of them appears in plain text, and anyone who can read the logs, which for a public repository is anyone, can copy it.

What Skylos flags

.github/workflows/deploy.yml · YAMLReported on line 17
name: Deployon:  push:    branches: [main]permissions:  contents: readjobs:  deploy:    runs-on: ubuntu-latest    environment: production    steps:      - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955        with:          persist-credentials: false      - name: Upload the site        env:          DEPLOY_KEY: ${{ fromJSON(secrets.DEPLOY_CONFIG).api_key }}          DEPLOY_HOST: ${{ fromJSON(secrets.DEPLOY_CONFIG).host }}        run: ./scripts/deploy.sh

What Skylos leaves alone

.github/workflows/deploy.yml · YAML
name: Deployon:  push:    branches: [main]permissions:  contents: readjobs:  deploy:    runs-on: ubuntu-latest    environment: production    steps:      - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955        with:          persist-credentials: false      - name: Upload the site        if: fromJSON(secrets.DEPLOY_CONFIG).enabled        env:          DEPLOY_KEY: ${{ secrets.DEPLOY_API_KEY }}          DEPLOY_HOST: ${{ fromJSON(vars.DEPLOY_CONFIG).host }}        run: ./scripts/deploy.sh

Why Skylos leaves it alone

The key is its own secret, so GitHub masks it. The host is decoded from a configuration variable (vars), which is not secret. The one decoded secret sits in if:, which GitHub evaluates but never prints.

How Skylos decides

  1. Reads *.yml and *.yaml workflow files under .github/workflows. Composite actions are not checked for this rule.
  2. Looks at every ${{ … }} in values GitHub prints: a step's run, with, env, name and working-directory; a job's env, outputs, name, runs-on, environment and with; matrix values; container and service image, env, options, entrypoint and args; and the workflow's env, name and run-name. Conditions, timeouts and a reusable call's secrets: are skipped.
  3. Reports a fromJSON() call whose input is a secret, when the decoded value or one of its fields flows out of the expression. The input can be secrets.X itself or env.X where X is set from a secret in the step, job or workflow env: (followed up to four steps). secrets.GITHUB_TOKEN passed through a shell variable does not count.
  4. One MEDIUM finding per decoded value, on the line where the expression appears.

How to fix it

Store each value that must stay hidden as its own secret and read it directly. Values that are not secret, such as a host name, can move to a configuration variable (vars).

.github/workflows/deploy.yml · YAML · the fix, against the flagged file
name: Deployon:  push:    branches: [main]permissions:  contents: readjobs:  deploy:    runs-on: ubuntu-latest    environment: production    steps:      - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955        with:          persist-credentials: false      - name: Upload the site        env:Removed:           DEPLOY_KEY: ${{ fromJSON(secrets.DEPLOY_CONFIG).api_key }}Removed:           DEPLOY_HOST: ${{ fromJSON(secrets.DEPLOY_CONFIG).host }}Added:           DEPLOY_KEY: ${{ secrets.DEPLOY_API_KEY }}Added:           DEPLOY_HOST: ${{ vars.DEPLOY_HOST }}        run: ./scripts/deploy.sh

When it can be wrong

  • A field that is not sensitive, such as a host name, is reported the same as a key, because Skylos cannot see what the JSON holds.
  • A script that registers the decoded value with ::add-mask:: before it is printed is still reported.

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-D362] and a reason on the reported line or on the line directly above it, one rule per marker. A marker on one line also covers a finding on the line below it.

    YAML
    env:  # skylos: ignore[SKY-D362] field is a public host name  DEPLOY_HOST: ${{ fromJSON(secrets.DEPLOY_CONFIG).host }}
  • [tool.skylos] ignore = ["SKY-D362"] turns the rule off for the whole project.

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