Skip to main content

SKY-D295 · CI/CD pipelines

Job runs on a self-hosted runner

High

A self-hosted runner is a machine you own that GitHub sends jobs to, instead of a fresh virtual machine GitHub throws away after each job. SKY-D295 reports every job whose runs-on: may pick such a runner, so a person can check who is able to start that job.

Languages
GitHub Actions workflows
Quality gate
counted toward the gate limits (full and diff scans)
Finding type
review
Catalog name
GitHub Actions self-hosted runner
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

Code in a job runs on the runner with its network access and whatever the last job left behind. If a pull request from a fork can reach the runner, its author can install a backdoor that reads the secrets, caches and build outputs of every later job, including your releases.

What Skylos flags

.github/workflows/gpu-tests.yml · YAMLReported on line 9
name: GPU testson:  pull_request:    branches: [main]permissions:  contents: readjobs:  gpu-tests:    runs-on: [self-hosted, linux, gpu]    steps:      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683        with:          persist-credentials: false      - run: pip install -e ".[test]" && pytest tests/gpu

What Skylos leaves alone

.github/workflows/unit-tests.yml · YAML
name: Unit testson:  pull_request:    branches: [main]permissions:  contents: readjobs:  unit-tests:    strategy:      matrix:        os: [ubuntu-latest, macos-15, windows-2022]    runs-on: ${{ matrix.os }}    steps:      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683        with:          persist-credentials: false      - run: pip install -e ".[test]" && pytest tests/unit

Why Skylos leaves it alone

runs-on is an expression, but it reads a matrix written out in the file, and every value in it is a GitHub-hosted label. Skylos expands the matrix and finds no row that could reach a machine you own.

How Skylos decides

  1. Reads workflow files under .github/workflows. Composite actions have no runs-on, so they are not checked.
  2. Skips a job without runs-on and a job that calls a reusable workflow with uses:; the called workflow is checked on its own.
  3. Reports the job when one of its labels is self-hosted (any case), when runs-on names a runner group, or when it is empty, a mapping with other keys than labels, or a label that is not text.
  4. A label written as an expression ${{ … }} counts, unless it is exactly ${{ matrix.<name> }} and every row of a matrix written in the file gives labels from GitHub's list of hosted images, such as ubuntu-latest, windows-2022 or macos-15.
  5. Any other fixed label, such as gpu-large, is not reported, because only the self-hosted label proves a machine you own.
  6. The trigger is not considered. One HIGH finding per job, on its runs-on line.

How to fix it

Do not let pull requests reach a self-hosted runner. Run them on GitHub-hosted runners, and keep the self-hosted job for events only people with write access can cause, such as a push to main. Use ephemeral runners, which take one job and are then destroyed, and record that review next to runs-on.

.github/workflows/gpu-tests.yml · YAML · the fix, against the flagged file
name: GPU testson:Removed:   pull_request:Added:   push:    branches: [main]permissions:  contents: readjobs:  gpu-tests:Added:     # skylos: ignore[SKY-D295] ephemeral runner, pushes to main only    runs-on: [self-hosted, linux, gpu]    steps:      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683        with:          persist-credentials: false      - run: pip install -e ".[test]" && pytest tests/gpu

When it can be wrong

  • A self-hosted job that only runs on push, schedule or workflow_dispatch is reported the same as one that runs on pull requests from forks, because the trigger is not read.
  • Missed: a self-hosted runner picked by a custom label alone, such as runs-on: gpu-large, without the self-hosted label.
  • runs-on: ${{ inputs.runner }} and matrices built with fromJSON() are reported, because Skylos cannot see which label they become.

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-D295] as a YAML comment at the end of the runs-on line or on its own line directly above it, one rule per marker.

    YAML
    # skylos: ignore[SKY-D295] ephemeral runner, pushes to main onlyruns-on: [self-hosted, linux, gpu]
  • [tool.skylos] ignore = ["SKY-D295"] turns the rule off for the whole project.

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