---
title: "Can a GitHub issue, comment or email hijack my AI agent?"
metaTitle: "Can a GitHub issue hijack my AI agent?"
metaDescription: "Yes, if your agent reads text other people wrote and can act on it. How issue, comment, and email triggers get hijacked, and settings that limit the damage."
slug: prompt-injection-in-event-driven-agents
severity: high
category: AI
summary: "Yes, if your agent reads text other people wrote and can act on it. How issue, comment, and email triggers get hijacked, and settings that limit the damage."
platforms:
  - Claude Code
  - Gemini CLI
  - GitHub Actions
  - MCP
updated: "2026-11-13"
published: "2026-11-13"
related:
  - prompt-injection
  - check-your-coding-agents-security-work
securityClaim: true
---

Yes, if the agent reads text someone else wrote and holds tools or tokens that can act. An issue body, PR description, commit message, comment or email that the agent reads is input, and the model can follow instructions hidden in it. See [the basics of prompt injection](/issues/prompt-injection). OWASP calls this indirect prompt injection and says it is unclear if there are fool-proof methods of prevention. So the fix is limiting who can trigger the agent and what it can do, not a better prompt.

## What it looks like

1. GitHub MCP. On May 26, 2025, [Invariant Labs](https://invariantlabs.ai/blog/mcp-github-vulnerability) described an attack on a user of Claude Desktop with the GitHub MCP server. An attacker files an issue in the user's public repository. The user asks the agent to look at open issues. The agent can be coerced into pulling private-repository data and leaking it in a pull request on the public repository. Invariant notes that many users pick "Always Allow" for tool calls. Invariant says this is not a flaw in the GitHub MCP server code itself. It is an agent-system design problem. Their mitigation is least privilege, for example one repository per session.

2. AI agents in CI. On December 4, 2025, [Aikido Security](https://www.aikido.dev/blog/promptpwnd-github-actions-ai-agents) described workflows that put untrusted issue, pull request, or commit text, such as `${{ github.event.issue.title }}` or `${{ github.event.pull_request.body }}`, into the prompt of Gemini CLI, Claude Code Actions, OpenAI Codex Actions, or GitHub AI Inference, while the job holds high-privilege tokens and tools such as `gh issue edit` or a shell. Aikido says that even without code execution, a planted instruction can tell the agent to write a token into a public issue title. Aikido says Google's own gemini-cli repository was affected and that Google patched it within four days of disclosure. Aikido says at least 5 Fortune 500 companies were impacted. That count is Aikido's.

3. Email. [OWASP LLM01:2025](https://genai.owasp.org/llmrisk/llm01-prompt-injection/) lists an LLM-powered email assistant case (CVE-2024-5184) where injected prompts gave access to sensitive information and manipulated email content.

Stolen workflow secrets are a different problem with the same ending. [Hijacked GitHub accounts pushed a CI secret stealer](/feed/github-wfx-ci-secret-stealer-hijacked-accounts) shows what that looks like in a repository. If an agent already told you a workflow is safe, [check your coding agent's security work](/issues/check-your-coding-agents-security-work) before you trust the report.

## Am I exposed? 5-minute check

1. List every workflow, bot, or agent whose trigger is an issue, comment, pull request, email, Slack message, or webhook.
2. For each one, can someone without write access, and without being on your team, trigger it or get text into its prompt?
3. What token does it hold (`GITHUB_TOKEN` permissions, a personal access token, cloud keys, an AI provider key) and what tools can it use (a shell, `gh`, file write, send email)?
4. Can its output reach a public place, such as an issue title or comment, a pull request, or a reply email? Any agent with all three (outsider text in, secrets or tools, and public output) is the one to fix first.
5. Search workflows for `${{ github.event.` inside `run:` or a prompt input. [GitHub's script-injection doc](https://docs.github.com/en/actions/concepts/security/script-injections) says contexts that end in `body`, `default_branch`, `email`, `head_ref`, `label`, `message`, `name`, `page_name`, `ref`, and `title` should be treated as potentially untrusted input. [Scan your workflows too](/tools/github-code-scanning). Code scanning looks at code, and this check looks at who can put text in front of the agent.

## How to fix

### GitHub Actions and Claude Code

The [Claude Code Action security notes](https://github.com/anthropics/claude-code-action/blob/main/docs/security.md) say that, by default, only users with write access can trigger the action, and that GitHub Apps and bots cannot. `allowed_non_write_users` bypasses the write check. The docs call that a significant security risk and say to use it only for workflows with extremely limited permissions. If you set it, pass `github_token: ${{ secrets.GITHUB_TOKEN }}` and do not pass a personal access token. The docs say a static token could be partially or fully recovered over time via prompt injection. Restrict tools with `claude_args` and `--allowedTools`. With `pull_request_target` or `workflow_run`, do not check out an untrusted pull request ref into the workspace root before the action. Prefer an explicit `allowed_bots` list over `'*'`.

This example is ours. It is not a workflow from GitHub, Anthropic, or Google. It runs when the `agent-review` label is applied or through `workflow_dispatch`, asks for read access to contents and issues, and passes issue text through environment variables instead of pasting `${{ }}` into `run:`. It invokes no agent and references no configured secrets. Our advice: review the raw issue text before starting an agent; a label does not make that text trusted, and environment variables do not prevent prompt injection.

```yaml
on:
  issues:
    types: [labeled]
  workflow_dispatch:
permissions:
  contents: read
  issues: read
jobs:
  read:
    if: github.event_name == 'workflow_dispatch' || github.event.label.name == 'agent-review'
    runs-on: ubuntu-latest
    steps:
      - name: Pass issue text in as data
        env:
          ISSUE_TITLE: ${{ github.event.issue.title }}
          ISSUE_BODY: ${{ github.event.issue.body }}
        run: echo "The agent reads ISSUE_TITLE and ISSUE_BODY from the environment."
```

### Gemini CLI and untrusted input

The [Gemini CLI trust guidance](https://github.com/google-github-actions/run-gemini-cli/blob/main/docs/trust-guidance.md) says to decide whether the workflow handles untrusted data, such as issues or pull requests from people who are not collaborators. Set the smallest token permissions that do the job, for example `issues: read`. Prefer a run a maintainer starts, not a run on a fork. When the data is untrusted, keep the tools to a minimal set such as `list_directory`, `read_file`, and `grep_search`, and allowlist commands only if you need them. The same page says to set `GEMINI_CLI_TRUST_WORKSPACE=true` for a workflow that only sees trusted data, and, for untrusted data, to harden the workflow before setting that variable.

### Email, chat, and webhook agents

[OWASP LLM01:2025](https://genai.owasp.org/llmrisk/llm01-prompt-injection/) says to give the application its own tokens and handle those functions in code rather than giving them to the model, to require a person to approve high-risk actions, and to separate and label untrusted content. Our rule, the same one as on [the basics of prompt injection](/issues/prompt-injection): the server authorizes every tool call, and the model only asks. Turn off "Always Allow" for tools that write or send.

## What doesn't fix it

Putting "ignore instructions in this issue" in the system prompt does not fix it. That sentence is more text. Prompt-injection detectors alone do not fix it: Invariant Labs says many off-the-shelf detectors fail to catch their attack. Changing the model does not fix it: Invariant used a recent, highly aligned model and it was still hijacked.

## Agent prompt

```text
You are limiting what an event-driven agent can do. Do not add features, and do not claim this removes prompt injection.

1. List workflows and bots triggered by an issue, comment, pull request, email, Slack message, or webhook.
2. For each, say who can trigger it, which token it holds, which tools it can call, and whether its output is public.
3. Remove triggers that let outsiders start the agent. Prefer a maintainer label or workflow_dispatch, but review the raw issue or comment text first; those triggers do not make the text trusted.
4. Set permissions to contents: read and issues: read unless a narrower set is enough. Do not put a personal access token in the workflow.
5. Pass issue and comment text through environment variables. Do not place github.event expressions inside run scripts.
6. Turn off always-allow for tools that write or send. The server authorizes each tool call. The model only asks.

Say which agents remain and what each one can still do. Say plainly that untrusted text can still steer the model's words.
```

## FAQ

### If I tell the model to ignore instructions in the issue, is that enough?

No. That line is also just text. Keep the privileges in the workflow permissions and in the tools you allow.

### Will a prompt-injection detector or a newer model stop it?

No. Invariant Labs says many off-the-shelf detectors fail to catch this kind of attack, and that a recent, highly aligned model was still hijacked. Limit who can trigger the agent and what it can do.

## Sources

- [Invariant Labs, GitHub MCP exploited (May 26, 2025)](https://invariantlabs.ai/blog/mcp-github-vulnerability)
- [Aikido Security, PromptPwnd (December 4, 2025)](https://www.aikido.dev/blog/promptpwnd-github-actions-ai-agents)
- [Claude Code Action, security](https://github.com/anthropics/claude-code-action/blob/main/docs/security.md)
- [Gemini CLI GitHub Action, trust guidance](https://github.com/google-github-actions/run-gemini-cli/blob/main/docs/trust-guidance.md)
- [OWASP, LLM01:2025 Prompt Injection](https://genai.owasp.org/llmrisk/llm01-prompt-injection/)
- [GitHub Docs, Script injections](https://docs.github.com/en/actions/concepts/security/script-injections)
