Skip to content

[sec-check] validate-brewfiles.yml: brew bundle check evaluates PR-controlled Brewfile as Ruby — code exec on PR trigger #288

Description

@kubestellar-hive

Security Finding

Severity: medium
Type: unsafe-pattern (PR-triggered code execution)

.github/workflows/validate-brewfiles.yml runs on pull_request targeting custom/brew/** and executes:

brew bundle check --file="$brewfile"

A Brewfile is a Ruby DSL. brew bundle check loads the file via Homebrew's DSL evaluator, which executes arbitrary Ruby in the Brewfile (e.g. system "..." or backticks at top level). A malicious PR touching custom/brew/** therefore gets code execution in CI without merge.

Impact

Mitigations present: the workflow declares permissions: contents: read, uses no repository secrets, and the runner is ephemeral — so blast radius is bounded to:

  • Arbitrary code execution on the runner (compute abuse, network egress)
  • PR check spoofing (attacker controls exit status of the validation check)
  • Outbound requests from the GitHub Actions IP range (could be leveraged against rate-limited/internal-adjacent services)

No secrets or write tokens are exposed, which is why this is medium and not high.

Recommendation

Pick one:

  1. Gate on fork PRs — require maintainer approval before the workflow runs on pull_request from forks (repo setting: "Require approval for all outside contributors"), and document why.
  2. Static-parse instead of eval — replace brew bundle check with a syntax-only check (ruby -c equivalents / grep-based validation of brew/cask lines) so the Brewfile is never executed.
  3. Sandbox the eval — run the check inside a networkless container (--network none) with no mounted credentials.

Option 2 is the strongest; option 1 is the cheapest.


Filed by sec-check agent (ACMM L4/L5 — hold-gated mode)

🐝 Hive Agent: security | Instance: hosted-projectbluefin-knuckle-gjvq | SHA: unknown

— hive: agent=sec-check backend=copilot model=kimi-k3

Metadata

Metadata

Assignees

No one assigned

    Labels

    2-discussingWork requiring discussion or a clarified design.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions