Summary
A critical CI workflow vulnerability in the Meshtastic repository allowed attacker-controlled code from untrusted forks to run with repository secrets and elevated GITHUB_TOKEN permissions.
When a pull_request_target event was opened by an external contributor, the workflow automatically checked out and executed forked code without approval, enabling potential repository takeover and supply chain compromise.
Affected context
This vulnerability occurs in GitHub Actions workflows that:
- Are triggered by
pull_request_targeton untrusted contributions - Check out and execute code from the attacker's fork
- Grant elevated GITHUB_TOKEN scopes and repository secrets to the workflow
- Lack an approval or trust gate before running attacker-controlled jobs
In this case, the main_matrix.yml workflow for Meshtastic's CI pipeline was affected across multiple jobs (check, build, and build-debian-src).
Exploit preconditions
- Attack surface: GitHub Actions CI pipeline for the Meshtastic repository
- Required access: Ability to open a pull request from a fork (author_association: "NONE")
- Trigger point: Automatic execution of the
main_matrix.ymlGitHub Actions workflow onpull_request_target - Why exploitation is possible: The workflow:
- Uses
pull_request_target, which runs in the context of the base repository - Checks out and directly executes attacker-controlled fork code
- Provides access to repository secrets and a highly privileged GITHUB_TOKEN
- Has no manual approval or trust filter before executing CI jobs
Why this happens
The underlying issue is the insecure handling of untrusted code within a privileged CI/CD environment, mapping to CWE-94: Improper Control of Generation of Code and CWE-829: Inclusion of Functionality from Untrusted Control Sphere.
The workflow design allowed forked code to be treated as trusted and executed directly under the repository's security context.
This pattern effectively generates and runs attacker-specified logic during CI, while giving it broad access to secrets and repository write capabilities, violating the principle of least privilege and safe boundary isolation for contributed code.
Potential impact
- Attacker-controlled remote code execution within CI runners
- Exposure or exfiltration of repository secrets (tokens, keys, credentials)
- Repository takeover via privileged GITHUB_TOKEN (e.g., pushing malicious commits, altering branches, modifying workflows)
- Supply chain compromise by injecting malicious artifacts or releases
- Compromise of self-hosted GitHub Actions runners and adjacent infrastructure
General mitigation guidance
Secure CI/CD patterns for this class of vulnerability typically focus on:
- Avoiding
pull_request_targetfor workflows that build or execute fork code, or strictly limiting its capabilities - Ensuring untrusted code runs with minimal permissions, no secrets, and a restricted GITHUB_TOKEN scope (e.g.,
read-only, nocontents: write) - Introducing explicit approval gates or "trusted contributor" checks before running privileged workflows
- Separating workflows that validate contributions from those that perform release or deployment operations
- Treating fork code as untrusted input: run in sandboxed jobs, with isolated environments and without direct access to repository resources
These patterns make it harder for contributed code to gain control over the CI environment or repository state.
How teams detect issues like this
Organizations can detect similar workflow risks by:
- Reviewing GitHub Actions definitions for
pull_request_targettriggers that: - Check out code from forks
- Run arbitrary scripts from contributor-controlled paths
- Access secrets or grant elevated GITHUB_TOKEN scopes
- Using policy-as-code tools or CI security scanners to flag:
- Workflows that mix untrusted code with privileged tokens
- Jobs that run on self-hosted runners with broad permissions
- Implementing static analysis or configuration linting for CI manifests to enforce:
- Least-privilege token scopes
- No-secrets policies on untrusted contribution workflows
- Mandatory manual approval steps for workflows that can modify repository state
- Periodic audits of workflow execution logs to identify suspicious behavior, such as unexpected network calls or repository modifications initiated from PR-triggered jobs.

