Summary
A critical flaw in Eigent's GitHub Actions CI workflow enables arbitrary code execution on the CI runner when processing fork-based pull requests.
By abusing a pull_request_target workflow that checks out and runs untrusted PR code with repository write permissions, an attacker could execute commands with the workflow's privileges to steal secrets, modify the repository, or manipulate releases.
Affected context
This vulnerability arises in repositories using GitHub Actions workflows that:
- Are triggered with
pull_request_targetfor forked pull requests - Check out and execute code from the untrusted PR branch
- Grant the workflow write-level repository permissions or access to sensitive secrets
In such setups, the CI runner effectively trusts and executes unreviewed code contributed by external users, allowing that code to run with elevated automation privileges.
Exploit preconditions
- Attack surface: GitHub Actions CI environment for the Eigent repository.
- Required access: Ability to open a pull request from a fork (no prior repository write access required); the workflow itself holds write permissions.
- Trigger point: Creation or update of a fork-based pull request that triggers the
pull_request_targetworkflow and causes the job to checkout and run PR code. - Why exploitation is possible: The workflow combines
pull_request_target(which runs in the context of the base repository with its permissions) with checkout of untrusted PR code and execution of that code, allowing attackers to inject arbitrary commands executed with the workflow's privileges.
Why this happens
The core issue is a CI pipeline misconfiguration that treats untrusted pull request code as if it were trusted automation logic.
Specifically, the GitHub Actions workflow uses the pull_request_target event, which runs in the security context of the base repository, but then checks out and executes code from the untrusted PR branch. This maps to CWE-94: Improper Control of Generation of Code ('Code Injection'), where externally supplied content is allowed to influence what commands or scripts the system runs. In this case, the PR author effectively controls the code executed by the CI runner, which has repository write permissions and possibly access to secrets.
Potential impact
- Stealing repository secrets that the CI workflow can access (tokens, keys, credentials).
- Using the workflow's write token to push malicious commits or tags to the repository.
- Creating or modifying GitHub releases to distribute tampered artifacts.
- Posting comments or manipulating pull requests and issues via the GitHub API.
- Tampering with build outputs, test results, or packaging pipelines.
- Establishing a persistent supply-chain compromise by injecting backdoors into the codebase.
General mitigation guidance
Effective mitigation focuses on separating trust boundaries and preventing untrusted code from running with elevated repository permissions:
- Avoid combining
pull_request_targetwith checkout and execution of PR code; preferpull_requestfor workflows that run untrusted code, as it uses the fork's limited permission context. - If
pull_request_targetis required (for label management or triage), avoid running arbitrary PR scripts or commands; operate only on metadata (titles, labels, base refs). - Restrict workflow permissions to the minimum required (
permissions:in the workflow), avoiding broadwriteaccess where not strictly needed. - Use separate workflows: one minimal-privilege workflow for running PR tests, and another, more privileged, workflow only for trusted branches or after approval.
- Treat all fork-based PR content as untrusted input and avoid interpolating it directly into shell commands, scripts, or configuration without strict controls.
How teams detect issues like this
Detection typically involves reviewing CI configuration and enforcing policy checks around workflow behavior:
- Static analysis of GitHub Actions workflows to flag usage of
pull_request_targetcombined withactions/checkoutof the PR head and subsequent execution of PR-controlled code. - Code review checklists specifically calling out CI workflows that:
- Run on PR events,
- Have write permissions,
- Execute scripts from repository or PR content.
- Automated policy enforcement (e.g., repository rules or CI policy tools) that:
- Restrict which events can run privileged workflows,
- Require explicit review for workflows granting broad permissions.
- Periodic audits of workflow logs for suspicious actions such as unexpected pushes, tag creations, or API calls originating from PR-triggered jobs.

