SKY-D299 · CI/CD pipelines
Secret in a job outsiders can start, without an environment
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
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
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
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
- Reads workflow files under
.github/workflows, not composite actions. - 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, andworkflow_runwhen the upstream workflow can be started from a fork or cannot be found. Atypes:list with none of those types drops the trigger.push,schedule,workflow_dispatch,releaseandpull_requestnever count. With none left, the rule stops. - 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 asauthor_association == 'MEMBER'orgithub.actor == 'name'keeps outsiders out. So does a job listed inneeds: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. - Skips jobs that have an
environment:key, whatever its value, and jobs that call a reusable workflow (uses:). - Reports every
${{ … secrets.NAME … }}written anywhere in the job (run scripts,env:,with:), exceptGITHUB_TOKEN. Secrets in the workflow-levelenv:and thesecrets['NAME']form are not read. - 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,MODELorPORTand has no credential word (KEY,TOKEN,SECRET,PASSWORD,AUTHand 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.
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 throughneeds:. 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.