SKY-D313 · CI/CD pipelines
Privileged job running outsiders' code has no timeout
A GitHub Actions job without timeout-minutes may run for 360 minutes, GitHub's default limit. SKY-D313 reports such a job when it holds some privilege and runs pull request code that someone without write access to the repository can start.
- Languages
- GitHub Actions workflows
- Quality gate
- counted toward the gate limits (full and diff scans)
- Finding type
- review
- Catalog name
- GitHub Actions privileged job missing timeout
Why it matters
The pull request author decides how long their code runs. A test that hangs, or a crypto miner hidden in a fork's change, keeps the runner busy for six hours, using your minutes and holding the base repository's context for all that time.
What Skylos flags
name: Fork PR testson: pull_request_target: types: [opened, synchronize]permissions: contents: readjobs: test: name: Test the pull request runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} persist-credentials: false - uses: actions/setup-node@v4 with: node-version: 22 - run: npm ci --ignore-scripts - run: npm testWhat Skylos leaves alone
name: Labelon: pull_request_target: types: [opened, synchronize]permissions: contents: read pull-requests: writejobs: label: name: Label by changed paths runs-on: ubuntu-latest steps: - uses: actions/labeler@v5 with: sync-labels: trueWhy Skylos leaves it alone
This job is privileged and has no timeout, but it never checks out the pull request's code: the labeler only reads the list of changed files. The author cannot make it run longer.
How Skylos decides
- Reads workflow files under
.github/workflows. Jobs that call a reusable workflow, and jobs that settimeout-minutesto any value, are skipped. - A job is privileged when the workflow is started by
release, a tag push,pull_request_targetorworkflow_run, or when the job's effectivepermissions:grant any write scope,id-token: writeandwrite-allincluded. - The job must be reachable by an account without write access: one of the workflow's
issues,issue_comment,pull_request_target, review, discussion orworkflow_runtriggers, for event types an outsider can cause, that the job'sif:and the jobs itneedsdo not shut out. A recognised permission check in a needed job shuts them out; one in the same job does not.pull_requestandpushnever count. - The job must run pull request code: an
actions/checkoutwhosereforrepositorynames the pull request head (pull_request.head,merge_commit_sha,github.head_ref,refs/pull/), or arun:withgh pr checkoutor agit fetch,checkoutorpullof apull/ref. - Reports LOW on the first line of the file that contains
<job-id>:.
How to fix it
Set timeout-minutes on the job, a little above its normal run time. It limits how long the code can run; whether this job should run fork code at all is a separate question (SKY-D290).
name: Fork PR testson: pull_request_target: types: [opened, synchronize]permissions: contents: readjobs: test: name: Test the pull request runs-on: ubuntu-latestAdded: timeout-minutes: 15 steps: - uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} persist-credentials: false - uses: actions/setup-node@v4 with: node-version: 22 - run: npm ci --ignore-scripts - run: npm testWhen it can be wrong
- Any
timeout-minuteson the job clears it, even360or an expression. A timeout on each step does not count. - A job that runs fork code after a permission check in one of its own steps is still reported, because only checks in jobs it
needscount.
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-D313] <reason>on the job's line or on the line directly above it, one rule per marker.YAML jobs: # skylos: ignore[SKY-D313] runner pool enforces a 20-minute limit test:[tool.skylos] ignore = ["SKY-D313"]turns the rule off for the whole project. A baseline also works, but it records the absolute file path and line, so it stops matching when the checkout moves or lines above the finding change.