In May 2025 Invariant Labs showed that an AI agent connected to the official GitHub MCP server with a broadly scoped GitHub token could be hijacked by a prompt injection hidden in an issue on a public repository. Asked to "look at the open issues", the agent read the issue, pulled data from the owner's private repositories and published it in a pull request on the public repo. The fix is not a patch but a narrower token: give agents fine-grained GitHub tokens limited to the repositories the task needs.
| Disclosed | May 26, 2025 |
|---|---|
| Affected | GitHub MCP Server, Claude Desktop, GitHub |
| Type | AI agent |
| Status | Status unknown |
What was exposed
Whatever the agent's GitHub credential could read. In the demonstration the agent used the owner's token, which covered private repositories, and leaked their names and contents, including details of a private project, the owner's relocation plans and salary, into a public pull request anyone could read. The token itself was not disclosed; the problem is that the agent used its full scope on behalf of text written by an attacker. Any secret committed to a private repository the token can reach, such as a .env file or a deployment key, is exposed the same way. The researchers call this pattern a "toxic agent flow": untrusted input, access to private data and a way to publish, all in one agent session.
Am I affected?
You are exposed to this pattern if you run an AI agent (Claude Desktop, Cursor, VS Code agents or similar) with a GitHub MCP server or GitHub tools authenticated by a token that can read private repositories and you ask it to process content from public repositories, such as issues, pull requests or comments that anyone can write. The researchers stress it is not specific to one agent or client. Review your GitHub audit log and public repositories for pull requests, comments or branches your agent created that contain private information.
What to do now
- Give agents a fine-grained GitHub personal access token or GitHub App installation limited to the specific repositories the task needs, with read-only permissions where possible, instead of a classic token covering your whole account.
- Use separate agent sessions or credentials for public-repository triage and for private-repository work, so one session never holds both untrusted input and private access.
- Require human confirmation before an agent creates pull requests, issues or comments on public repositories.
- Search your public repositories for agent-created content that includes private data, delete it, and rotate any secret that appeared in it.
- Monitor agent tool calls; the researchers recommend runtime policies and scanners that restrict an agent to one repository per session.
Keys to rotate
Guides to the credentials this incident put at risk:
Timeline
- Invariant Labs publishes the attack, demonstrated with Claude Desktop, Claude 4 Opus and the official GitHub MCP server. The researchers say it is not a flaw in the GitHub MCP server code and cannot be fixed by a server-side patch alone. Source
What this changes for credential handling
- The agent did what its token allowed. BotPassword gives an agent access through scoped intents tied to a task, rather than a standing token for the whole account.
Frequently asked questions
Am I affected by the GitHub MCP Server incident?
You are exposed to this pattern if you run an AI agent (Claude Desktop, Cursor, VS Code agents or similar) with a GitHub MCP server or GitHub tools authenticated by a token that can read private repositories and you ask it to process content from public repositories, such as issues, pull requests or comments that anyone can write. The researchers stress it is not specific to one agent or client. Review your GitHub audit log and public repositories for pull requests, comments or branches your agent created that contain private information.
What was exposed in the GitHub MCP Server incident?
Whatever the agent's GitHub credential could read. In the demonstration the agent used the owner's token, which covered private repositories, and leaked their names and contents, including details of a private project, the owner's relocation plans and salary, into a public pull request anyone could read. The token itself was not disclosed; the problem is that the agent used its full scope on behalf of text written by an attacker. Any secret committed to a private repository the token can reach, such as a .env file or a deployment key, is exposed the same way. The researchers call this pattern a "toxic agent flow": untrusted input, access to private data and a way to publish, all in one agent session.
Which keys should I rotate?
Rotate any GitHub credentials that were reachable from affected systems, starting with the ones that can publish code or reach production.
Other ai agent and mcp incidents
- OpenCode on Windows and WSL ran commands from a malicious MCP server during OAuth sign-in 2026-10-04
- OpenCode server's upgrade endpoint let any webpage install an attacker's npm package 2026-09-24
- Cursor before 3.0: prompt-injected agent could escape its sandbox and run code as the user 2026-06-05
- Claude Code trust dialog could be bypassed with a spoofed git worktree, running repo hooks 2026-04-24
- Claw Chain: four OpenClaw flaws let a foothold read agent secrets and escape the sandbox 2026-04-23
- OpenClaw Control UI sent its gateway token to any gatewayUrl in a link, enabling 1-click RCE 2026-01-31