SKY-D290 · CI/CD pipelines
GitHub Actions dangerous trigger
A few GitHub Actions triggers run a workflow with the base repository's token and secrets even though someone outside the project started it: pull_request_target (a pull request from a fork), workflow_run (after another workflow, which a fork can start) and issue_comment (anyone who can comment). SKY-D290 reports these triggers when the workflow can hand that power to code or text from the pull request.
- Languages
- GitHub Actions workflows
- Quality gate
- counted toward the gate limits (full and diff scans)
- Finding type
- review
Why it matters
A pull_request_target job that checks out the pull request and runs npm ci runs the attacker's package.json scripts with your secrets and write token. Anyone with a GitHub account can open that pull request, so one workflow file can leak deploy keys or push a backdoor to a release branch.
What Skylos flags
name: Previewon: pull_request_target: types: [opened, synchronize]permissions: contents: read pull-requests: writejobs: preview: runs-on: ubuntu-latest steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: ref: ${{ github.event.pull_request.head.sha }} persist-credentials: false - run: npm ci && npm run build - run: npx netlify deploy --dir=dist --alias="pr-$PR_NUMBER" env: PR_NUMBER: ${{ github.event.pull_request.number }} NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}What Skylos leaves alone
name: Labelon: pull_request_target: types: [opened, synchronize]permissions: contents: read pull-requests: writejobs: label: runs-on: ubuntu-latest steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: persist-credentials: false - run: ./scripts/label-by-paths.sh "$PR_NUMBER" env: PR_NUMBER: ${{ github.event.pull_request.number }} GH_TOKEN: ${{ github.token }}Why Skylos leaves it alone
The job holds a write token, but it never fetches the pull request's code: actions/checkout without a ref checks out the base branch, so the script that runs is one a maintainer merged. The permissions are declared and no run: expands text from the pull request.
How Skylos decides
- Reads workflow files under
.github/workflows. Composite actions (action.yml) have no triggers and are not checked. pull_request_target: skips a workflow whose only job has one step that usesactions/labeler. Otherwise it looks at every job that can run on this event (a job whoseif:is onlygithub.event_name == '…'checks for other events is left out).- A job makes the trigger dangerous when it calls a reusable workflow, when neither it nor the workflow declares
permissions, or when arun:expands text the pull request author controls. A job that never fetches the pull request's code may hold any privilege, because it runs the base branch's files. - A job that fetches the pull request's code (a checkout whose
reforrepositorynamesgithub.event.pull_request.head…,merge_commit_sha,github.head_reforrefs/pull/…, or agh pr checkoutorgit fetch/checkout/pullofpull/…) is safe only when it has no write scope (and no permission string other thanread-all), mentions nosecrets.,github.tokenorGITHUB_TOKENanywhere, has no step with a cache turned on, and every checkout setspersist-credentials: false. workflow_run: always reported. Skylos does not look at what the workflow does with the run that triggered it.issue_comment: reported for a job that an account without write access can start (after the job'sif:andneeds), that checks out pull request code and then runs something (a later command,run:step or local action), while the job has an undeclared or write-scoped token, secrets, a runner that may be self-hosted, or a cache-mode that writes. Only a verified permission check stops it: a known check action or a script that looks the permission up and exits non-zero.- Reports HIGH on the trigger's line under
on:: one finding forpull_request_targetorworkflow_run, one per job forissue_comment.
How to fix it
Build pull requests with the pull_request trigger. A fork's run then gets a read-only token and no secrets, so its code cannot take them. Deploy previews only for branches in your own repository, as here, or from a separate workflow that never runs the pull request's code.
name: Previewon:Removed: pull_request_target:Added: pull_request: types: [opened, synchronize]permissions: contents: read pull-requests: writejobs: preview:Added: if: github.event.pull_request.head.repo.full_name == github.repository runs-on: ubuntu-latest steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with:Removed: ref: ${{ github.event.pull_request.head.sha }} persist-credentials: false - run: npm ci && npm run build - run: npx netlify deploy --dir=dist --alias="pr-$PR_NUMBER" env: PR_NUMBER: ${{ github.event.pull_request.number }} NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}When it can be wrong
- Every
workflow_runworkflow is reported, including one that only reads the triggering run's status and never touches its artifacts. - A
pull_request_targetjob that mentionsGITHUB_TOKENor a secret anywhere, even in a step that runs before the pull request's code is fetched, counts as exposed. - The flagged example also gets other findings about the same job, such as SKY-D299 for the secret and SKY-D313 for the missing timeout.
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-D290]with a reason at the end of the trigger's line, or on its own line directly above it. It must be a real YAML comment.YAML on: # skylos: ignore[SKY-D290] reads only the triggering run's status workflow_run: workflows: [CI] types: [completed]A baseline (
skylos baseline ., then--baseline) hides it too, but the entry is the rule, the absolute file path and the line. It stops matching when lines above the trigger move or the checkout is at another path.[tool.skylos] ignore = ["SKY-D290"]turns the rule off for the whole project.