“Comment and Control” — Prompt Injection Hijacks Claude Code, Gemini CLI & Copilot via GitHub

AI relevance: Any AI coding agent that reads GitHub PRs, issues or comments and acts on them can be hijacked by a single malicious title — turning a review tool into a credential-stealing pipeline.

Researcher Aonan Guan has disclosed a new cross-vendor vulnerability class dubbed “Comment and Control” that weaponizes GitHub pull request titles, issue bodies and comments to hijack three widely deployed AI coding agents: Anthropic’s Claude Code Security Review, Google’s Gemini CLI Action and GitHub Copilot Agent (SWE Agent). All three were confirmed vulnerable.

How it works

Unlike traditional indirect prompt injection (which requires a victim to ask the AI to process a document), Comment and Control is proactive. GitHub Actions workflows auto-trigger on pull_request, issues and issue_comment events — simply opening a PR or filing an issue activates the agent with zero victim interaction.

The entire attack loop runs within GitHub itself: an attacker writes a malicious PR title or issue comment, the AI agent reads it as trusted context, executes the injected instructions, and exfiltrates credentials back through a PR comment, issue comment or git commit — no external server required.

Findings per agent

  • Claude Code Security Review (CVSS 9.4 Critical): The PR title is directly interpolated into the agent’s prompt with zero sanitization. Because the CLI is invoked without --disallowed-tools or --allowed-tools restrictions, the subprocess inherits all environment variables including ANTHROPIC_API_KEY and GITHUB_TOKEN. An attacker opens a PR with a title that instructs Claude to run env or ps auxeww and returns the credential dump as a JSON “security finding” posted to the PR. Reported via HackerOne (#3387969), awarded $100.
  • Gemini CLI Action: Issue titles, bodies and comments are included in the agent’s prompt under an “Additional Content” section. By injecting a fake “Trusted Content Section” immediately after it, an attacker overrides Gemini’s safety instructions, causing it to post the GEMINI_API_KEY as a public issue comment. Reported to Google VRP (#1609699) by Neil Fendley with Johns Hopkins collaborators, awarded $1,337.
  • GitHub Copilot Agent (three-layer bypass): GitHub had implemented env-var filtering, secret scanning and a network firewall — all bypassed. The env filter only sanitizes the child subprocess; ps auxeww reads /proc/[pid]/environ of the unfiltered parent Node.js process to recover GITHUB_TOKEN, GITHUB_COPILOT_API_TOKEN and two additional credentials. Secret scanning (which detects ghs_/ghu_ prefixes) is evaded via base64-encoding before commit. The encoded credential file is exfiltrated via git push to a PR — a whitelisted operation. The payload is hidden inside an HTML comment in the issue body, invisible in rendered Markdown but fully parsed by the agent. Reported via HackerOne (#3544297).

Why it matters

  • This is the first documented cross-vendor prompt injection class affecting all three major AI coding assistants simultaneously.
  • The attack is passive — no user interaction required. A single malicious PR auto-triggers the agent.
  • Exfiltration uses GitHub’s own infrastructure (PR comments, commits), making it indistinguishable from normal agent activity.
  • The Copilot finding demonstrates that even multiple runtime-layer mitigations (env filtering + secret scanning + firewall) can be systematically bypassed when the AI itself is the trusted executor.
  • Any organization using AI agents to auto-review PRs, triage issues or manage repos is potentially exposed.

What to do

  • Audit all GitHub Actions workflows that invoke AI coding agents on pull_request, issues or issue_comment triggers.
  • Restrict agent tool permissions with --allowed-tools / --disallowed-tools flags where supported.
  • Treat PR titles, issue bodies and comments as untrusted input — sanitize before passing to any LLM context.
  • Rotate any API keys or tokens that may have been exposed if agents have been processing untrusted GitHub content.
  • Consider gating AI agent activation on PRs from trusted forks or collaborators only.

Sources