Skip to main content

SKY-D313 · CI/CD pipelines

Privileged job running outsiders' code has no timeout

Low

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
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

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

.github/workflows/fork-tests.yml · YAMLReported on line 8
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 test

What Skylos leaves alone

.github/workflows/labeler.yml · YAML
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: true

Why 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

  1. Reads workflow files under .github/workflows. Jobs that call a reusable workflow, and jobs that set timeout-minutes to any value, are skipped.
  2. A job is privileged when the workflow is started by release, a tag push, pull_request_target or workflow_run, or when the job's effective permissions: grant any write scope, id-token: write and write-all included.
  3. The job must be reachable by an account without write access: one of the workflow's issues, issue_comment, pull_request_target, review, discussion or workflow_run triggers, for event types an outsider can cause, that the job's if: and the jobs it needs do not shut out. A recognised permission check in a needed job shuts them out; one in the same job does not. pull_request and push never count.
  4. The job must run pull request code: an actions/checkout whose ref or repository names the pull request head (pull_request.head, merge_commit_sha, github.head_ref, refs/pull/), or a run: with gh pr checkout or a git fetch, checkout or pull of a pull/ ref.
  5. 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).

.github/workflows/fork-tests.yml · YAML · the fix, against the flagged file
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 test

When it can be wrong

  • Any timeout-minutes on the job clears it, even 360 or 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 needs count.

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.

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