Summary
A GitHub Actions workflow in cal.com dangerously checks out and executes attacker-controlled pull request code with a write-scoped GITHUB_TOKEN.
This allows an attacker to run arbitrary commands in CI and act on behalf of the repository, including mutating branches and pull requests.
Affected context
The vulnerability exists in the cal.com (cal.diy) GitHub Actions automation that handles pull_request_target events.
The workflow chain (pr.yml → check-types.yml) inherits default write permissions for the GITHUB_TOKEN, performs a checkout of untrusted pull request code, and then runs yarn install and package.json scripts.
Any environment using similar workflows, where pull_request_target is combined with write-scoped tokens and execution of PR code, is exposed to comparable risks.
Exploit preconditions
- Attack surface: GitHub repository CI/CD workflows exposed via pull_request_target events.
- Required access: Ability to open a pull request from a fork or branch (no maintainer-level access required).
- Trigger point: Automated workflow run that:
- Uses pull_request_target (executing in the context of the base repository)
- Performs a "dangerous" checkout of PR code
- Executes project scripts (e.g., yarn install, package.json scripts) from the PR.
- Why exploitation is possible: Untrusted PR code is treated as trusted and executed with a write-scoped GITHUB_TOKEN, enabling arbitrary commands to run with repository-level permissions.
Why this happens
The core issue is the execution of attacker-controlled code within a privileged CI environment, mapping to CWE-77: Command Injection.
By combining pull_request_target (which runs in the base repository's security context) with a write-scoped GITHUB_TOKEN and an unsafe checkout of PR code, the workflow effectively allows external contributors to inject commands into the CI runner.
Scripts defined in package.json and invoked by yarn install run without sufficient isolation or permission reduction, turning typical build steps into a command execution channel for untrusted input.
Potential impact
- Repository takeover through arbitrary git operations using the write-scoped GITHUB_TOKEN
- Unauthorized pushes to protected or main branches, including adding backdoors or malicious code
- Forced merges, mutation of pull requests, and manipulation of code review history
- Deletion or force-push of branches, disrupting development workflows and history
- Creation, modification, or deletion of issues and comments, impacting project governance and trust
General mitigation guidance
Effective mitigation centers on limiting what untrusted pull request code can do in CI and reducing token privileges by default.
Common defensive patterns include:
- Avoiding pull_request_target for workflows that build or execute PR code; preferring pull_request with restricted permissions.
- Ensuring GITHUB_TOKEN uses least privilege (e.g., read-only for PR validation jobs) and explicitly scoping permissions per job.
- Isolating or sandboxing any execution of contributor-supplied scripts, avoiding direct shell access or project-level tokens in those jobs.
- Splitting workflows into separate, minimally privileged jobs for checks that must run on PR contents versus actions that require write access.
- Using dedicated, scoped bot tokens only where repository writes are strictly necessary, and never exposing them to untrusted code paths.
How teams detect issues like this
Detection can focus on both configuration review and runtime monitoring of CI workflows:
- Static analysis of workflow YAML files to flag pull_request_target usage combined with dangerous steps (e.g., arbitrary checkout of PR code, shell commands, or script execution).
- Policy checks that enforce explicit GITHUB_TOKEN permissions and disallow write scopes in PR-validation jobs.
- Code review guidelines that treat CI workflows as high-sensitivity infrastructure, with special scrutiny for steps that run package manager scripts, npm/yarn hooks, or custom shell commands.
- Use of automated security tools or linters that scan CI configurations for common CI/CD anti-patterns such as untrusted code execution with elevated privileges.

