/

CVE-2024-58354

Severity:

CRITICAL RISK

(9.9)

Command Injection (CWE-77) in cal.com GitHub Actions

CVE-2024-58354

Deferred

Vulnerability type

Category:

Command Injection in CI/CD Pipelines

CWE:

CWE-77

Impact:

Repository Takeover via CI Command Execution

Severity:

CRITICAL RISK

(9.9)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

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.

Sources

SourceLink
github.comgithub.com/calcom/cal.diy/commit/9aa60fae41a6b6b101c86bf430754b439f440871
github.comgithub.com/calcom/cal.diy/security/advisories/GHSA-p3f6-52gv-cj7m
vulncheck.comvulncheck.com/advisories/cal-com-repository-takeover-via-pull-request-target-workflow

Frequently asked

questions

Yes. Any user who can open a pull request can supply code that will be executed by the workflow, enabling remote exploitation through GitHub's web interface.

The attacker typically only needs the ability to create a pull request against the repository, such as from a fork. No maintainer or write access to the repository itself is required.

The safest pattern is to ensure that workflows triggered by pull requests either:

  • Run with read-only tokens and minimal permissions, or
  • Avoid executing untrusted PR code altogether, especially via shell commands or project scripts.

Sensitive operations that require write access should be isolated into workflows that are not triggered directly by external contributors.

Treat CI workflows as part of your security-critical infrastructure by:

  • Reviewing all uses of pull_request_target and replacing it where not strictly necessary.
  • Applying least-privilege principles to CI tokens and explicitly defining permissions for each workflow.
  • Restricting or sandboxing execution of contributor-controlled scripts, and adding automated checks that flag risky CI patterns before they reach main branches.
Find out what's already
exploitable in your codebase.