Skip to content

ci: prevent fork PRs from auto-triggering the full CI matrix (cost control — surfaced by #2752) #2757

Closed

Description

@zackees

Symptom

External-fork PR #2752 (from JChalka/FastLED:master) automatically triggered the full CI matrix on every commit. Visible runs include:

  • build (ubuntu-24.04) — 2m38s
  • build / build (×3 variants) — 18m44s + 3m53s + 23m44s
  • test / build (×2 variants) — 5m57s + 6m9s
  • Additional pull_request-triggered runs visible in the run history: unit tests linux, wasm, uno, teensy41, example tests linux

That's ~60+ minutes of GHA runner time per push with no maintainer gate. For a contributor with normal iteration cadence (5–10 force-pushes per PR) on a multi-target build matrix, a single review cycle can easily burn 5–10 hours of runner time — and JChalka/FastLED:master is not an outside collaborator nor a previously-merged contributor, so this is the worst case.

Why this happens

Six workflows currently trigger on pull_request:

.github/workflows/build_esp32s3.yml
.github/workflows/build_teensy41.yml
.github/workflows/build_uno.yml
.github/workflows/build_wasm.yml
.github/workflows/example_test_linux.yml
.github/workflows/unit_test_linux.yml

All use the safe pull_request trigger (not pull_request_target), so there is no secrets-leak / RCE risk — fork code runs without write tokens. The only file using pull_request_target is project_automation.yml, and it sparse-checks-out only the base repo's ci/ dir, never the PR head. Confirmed safe.

So this is purely a runner-minutes / cost issue, not a security issue. But it's a real cost issue.

Repository settings observed

// GET /repos/FastLED/FastLED/actions/permissions
{"enabled":true,"allowed_actions":"all","sha_pinning_required":false}

// GET /repos/FastLED/FastLED/actions/permissions/workflow
{"default_workflow_permissions":"write","can_approve_pull_request_reviews":true}

The fork-pull-request approval policy itself (Settings > Actions > General > Fork pull request workflows from outside collaborators) is not exposed in the REST API — it's UI-only. Based on the observed auto-run behavior, the setting is currently Require approval for first-time contributors only (the GitHub default) or looser. JChalka has prior merged contributions, so subsequent fork PRs auto-run forever.

Prevention options (pick one or combine)

Option A — Tighten the UI setting (cheapest, most aggressive)

Set Settings → Actions → General → Fork pull request workflows from outside collaborators → "Require approval for all outside collaborators". Every fork PR run will require a maintainer to click "Approve and run" on each push.

  • Pros: One UI click, zero workflow edits, fully blocks runaway runs.
  • Cons: Approve-each-push friction for active external contributors. Maintainers must remember to re-approve after every force-push during a review cycle.

Option B — Label-gated trigger ("ok-to-test" pattern)

Convert the 6 pull_request-triggered workflows to add an if: guard requiring a maintainer-applied label:

jobs:
  build:
    if: >-
      github.event.pull_request.head.repo.full_name == github.repository ||
      contains(github.event.pull_request.labels.*.name, 'ok-to-test')
    # ...

Maintainer applies ok-to-test once → all subsequent runs auto-fire until the label is removed (or until a fresh head_ref_force_pushed event, depending on how strict you want it).

  • Pros: One-time approval per PR (not per push); maintainer keeps explicit control.
  • Cons: Six workflow files to edit; need a small process doc explaining the label.

Option C — Workflow-level fork short-circuit + manual workflow_dispatch

Add if: github.event.pull_request.head.repo.full_name == github.repository to skip ALL pull_request-triggered runs from forks. Then expose workflow_dispatch so a maintainer can manually trigger the matrix against the PR head when they're ready to review.

  • Pros: Zero auto-runs on forks, completely opt-in.
  • Cons: Most friction for the contributor (they can't iterate against CI feedback themselves without maintainer involvement).

Recommendation

Combine A + B. Set the UI to "Require approval for all outside collaborators" as the safety floor (covers everything including any new pull-request-triggered workflow added later by mistake), AND add an ok-to-test label gate so that once a maintainer has vetted the PR, the contributor can iterate without per-push approval clicks. This is the pattern used by Kubernetes, Envoy, Istio, etc.

Not in scope for this issue (but worth noting)

  • default_workflow_permissions: write is the GHA default; consider tightening to read and explicitly granting permissions: write-all per-workflow only where needed (most workflows here are pure CI and don't need write).
  • can_approve_pull_request_reviews: true — Actions are allowed to approve PRs. Almost certainly not used, but worth disabling if not.
  • Both of the above are separate hardening tasks; they don't address the runner-minutes issue directly.

Reference

🤖 Generated with Claude Code

Activity

  1. zackees commented on Jun 4, 2026

    @zackees
    MemberAuthor

    Correction to the original security claim

    The user (zackees) challenged my unqualified "no secrets-leak / RCE risk" claim in the issue body. They're right that pull_request from forks is NOT a magic safety boundary — the attack classes (self-hosted runner takeover, cache poisoning, secrets-in-env exfiltration) are real and well-documented in the GitHub Actions security literature.

    I ran three parallel deep-dive audits to try to prove an attack is feasible against FastLED's current config. All three came back negative for currently exploitable, but the conditions that defend against them are fragile (one workflow edit away). Honest report:

    What's currently mitigated

    Attack class Why it doesn't land today
    Self-hosted runner takeover Zero runs-on: self-hosted anywhere. All 6 fork-triggerable workflows terminate on stock GitHub-hosted Ubuntu.
    Secrets in env reaching fork code Zero secrets.* references in any of the 6 fork-triggerable workflows OR their reusable templates (build_template.yml, template_unit_test.yml, template_example_test.yml, build_wasm.yml). The only env: is BUILD_ARGS: ${{ inputs.args }} (literal input, no secret).
    GITHUB_TOKEN write-scope GitHub forces fork-PR GITHUB_TOKEN to read-only regardless of permissions: or default_workflow_permissions: write. Verified against current docs.
    Checkout-token leak to fork code Every actions/checkout in PR-triggered workflows uses persist-credentials: false — so even the ephemeral checkout token is wiped from .git/config BEFORE ./install / ./test / ./compile / ci/*.py (fork-controlled) runs.
    Cache poisoning from PR → master No direct actions/cache@v*. The indirect caches via astral-sh/setup-uv@v6 and FastLED/fbuild/.github/actions/setup@main use keys that look shared, but GitHub server-side scopes fork-PR cache writes to refs/pull/N/merge invisibly. push-to-master cannot restore a fork-PR-written cache.
    Docker GHA cache poisoning The Docker workflows with type=gha cache (docker_*.yml) are workflow_call-only, not reachable from pull_request.

    What's NOT mitigated (one edit away from exploit)

    The templates execute extensive fork-controlled code:

    • ./install (template_unit_test.yml:52, template_example_test.yml:57) → uv sync of fork's pyproject.toml → Hatchling build backend executes whatever the fork ships
    • ./test (template_unit_test.yml:63)
    • ./compile (build_template.yml:86)
    • ci/wasm_compile.py, ci/wasm_test.py (build_wasm.yml:91, :129)
    • ci/ci-compile.py, ci/symbol_analysis_runner.py, ci/optimization_report.py, etc.

    If any future PR adds env: TOKEN: ${{ secrets.X }} at the JOB level of one of those three templates, that secret IS immediately readable by every fork PR's ./install, ./test, or ci/*.py. The "no secrets in PR-triggered workflows" rule is currently an unenforced convention.

    Additionally:

    • Supply-chain pin: FastLED/fbuild/.github/actions/setup@main (build_template.yml:64) is pinned to a mutable branch ref. A compromise of FastLED/fbuild becomes immediate RCE on every FastLED CI runner. SHA-pin recommended.

    Additional ask: add an enforced invariant

    The cost-control recommendations from the original issue (UI tightening + ok-to-test label) still stand. To make the security side robust, add a CI-side lint that fails the workflow if anyone adds secrets.* to a pull_request-triggered workflow or its callees. Sketch:

    # ci/lint_actions/no_secrets_in_pr_workflows.py
    # 1. Parse .github/workflows/*.yml
    # 2. For each workflow with `on.pull_request:`, recursively follow `uses: ./...`
    # 3. If any reachable file contains `${{ secrets.<NAME> }}` (excluding GITHUB_TOKEN which is forced read-only),
    #    fail with a specific error pointing at the line.
    # Allowlist: explicitly-marked exceptions (e.g. a secret that is genuinely meant to be public-readable).

    That converts the "currently-safe-but-one-edit-away" status into a durable invariant.

    Net change to original issue

    Changing the framing from "this is purely a cost-control issue, not a security issue" to "this is a cost-control issue today, and there's a small but real security cliff one workflow edit away — worth adding a lint to defend the invariant."

    The recommendations themselves (UI tightening + ok-to-test label-gate + workflow-level short-circuit) don't change — they remain the right cost-control mix. The lint check is an additional, orthogonal defensive measure.

  2. added a commit that references this issue on Jun 4, 2026
    54e4698
  3. moved this from Triage to Done in FastLED Trackeron Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions