Skip to main content

SKY-D299 · CI/CD pipelines

Secret in a job outsiders can start, without an environment

Medium

A GitHub environment with required reviewers makes a job wait for a person to approve it before it gets the environment's secrets. SKY-D299 reports a repository secret used in a job that someone without write access can start, such as by commenting on an issue, when the job has no environment:.

Languages
GitHub Actions workflows
Quality gate
counted toward the gate limits (full and diff scans). A finding for a secret named after a location or setting, such as NETLIFY_SITE_URL, is hidden from the default list, but the gate still counts it.
Finding type
review
Catalog name
GitHub Actions secret outside environment
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

Anyone with a GitHub account can open an issue or write a comment. If that starts a job holding a deploy token, a bug in the job's checks or scripts is enough to leak the token or misuse it, and nobody has to approve the run first.

What Skylos flags

.github/workflows/preview.yml · YAMLReported on line 19
name: Preview deployon:  issue_comment:    types: [created]permissions:  contents: readjobs:  deploy-preview:    if: github.event.issue.pull_request && github.event.comment.body == '/preview'    runs-on: ubuntu-latest    steps:      - uses: actions/checkout@v4        with:          persist-credentials: false      - name: Deploy the preview        run: ./scripts/deploy-preview.sh "$PR_NUMBER"        env:          PR_NUMBER: ${{ github.event.issue.number }}          NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}

What Skylos leaves alone

.github/workflows/preview.yml · YAML
name: Preview deployon:  issue_comment:    types: [created]permissions:  contents: readjobs:  deploy-preview:    if: >-      github.event.issue.pull_request &&      github.event.comment.body == '/preview' &&      github.event.comment.author_association == 'MEMBER'    runs-on: ubuntu-latest    steps:      - uses: actions/checkout@v4        with:          persist-credentials: false      - name: Deploy the preview        run: ./scripts/deploy-preview.sh "$PR_NUMBER"        env:          PR_NUMBER: ${{ github.event.issue.number }}          NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}

Why Skylos leaves it alone

The job's if: only lets a comment through when its author is a member of the organisation. Skylos evaluates the condition for an account without write access, finds that it is false, and so treats the job as one only trusted people can start.

How Skylos decides

  1. Reads workflow files under .github/workflows, not composite actions.
  2. Lists the workflow's triggers that an account without write access can cause: issues (opened, edited, closed, reopened), issue_comment, pull_request_target (opened, edited, closed, reopened, synchronize, ready_for_review, converted_to_draft), pull_request_review (submitted, edited), pull_request_review_comment, discussion, discussion_comment, and workflow_run when the upstream workflow can be started from a fork or cannot be found. A types: list with none of those types drops the trigger. push, schedule, workflow_dispatch, release and pull_request never count. With none left, the rule stops.
  3. For each job, asks whether one of those events can still run it. The job's if: is evaluated for an outsider: a check such as author_association == 'MEMBER' or github.actor == 'name' keeps outsiders out. So does a job listed in needs: that checks the actor's permission (a permission or membership action, or a script that calls the collaborator-permission API). A check inside the same job does not count.
  4. Skips jobs that have an environment: key, whatever its value, and jobs that call a reusable workflow (uses:).
  5. Reports every ${{ … secrets.NAME … }} written anywhere in the job (run scripts, env:, with:), except GITHUB_TOKEN. Secrets in the workflow-level env: and the secrets['NAME'] form are not read.
  6. One MEDIUM finding per job and secret, on the first line of the file that holds that text. A secret whose name ends in URL, URI, HOST, HOSTNAME, ENDPOINT, DOMAIN, REGION, MODEL or PORT and has no credential word (KEY, TOKEN, SECRET, PASSWORD, AUTH and others) is marked low risk and hidden from the default list.

How to fix it

Give the job an environment and move the secret into it. In the repository settings, add required reviewers to the preview environment, so a person approves each run before the job gets NETLIFY_AUTH_TOKEN.

.github/workflows/preview.yml · YAML · the fix, against the flagged file
name: Preview deployon:  issue_comment:    types: [created]permissions:  contents: readjobs:  deploy-preview:    if: github.event.issue.pull_request && github.event.comment.body == '/preview'    runs-on: ubuntu-latestAdded:     environment: preview    steps:      - uses: actions/checkout@v4        with:          persist-credentials: false      - name: Deploy the preview        run: ./scripts/deploy-preview.sh "$PR_NUMBER"        env:          PR_NUMBER: ${{ github.event.issue.number }}          NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}

When it can be wrong

  • Any environment: clears the finding, even one without required reviewers in the repository settings, which Skylos cannot see.
  • The job's if: must keep outsiders out on its own or through needs:. A step that checks the commenter's permission and exits early does not clear the finding.
  • Settings stored as secrets, such as NETLIFY_SITE_URL, are reported too, but hidden from the default list.

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

    YAML
    # skylos: ignore[SKY-D299] token can only create preview deploysNETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
  • [tool.skylos] ignore = ["SKY-D299"] turns the rule off for the whole project.

  • A baseline works, but it records the absolute file path and the line, so it stops matching when the checkout moves or lines above shift.

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