AI agent · May 26, 2025

GitHub MCP prompt injection: a public issue could make an agent leak private repository data

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.

DisclosedMay 26, 2025
AffectedGitHub MCP Server, Claude Desktop, GitHub
TypeAI agent
StatusStatus 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

  1. 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.
  2. 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.
  3. Require human confirmation before an agent creates pull requests, issues or comments on public repositories.
  4. Search your public repositories for agent-created content that includes private data, delete it, and rotate any secret that appeared in it.
  5. 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

  1. 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.

Keep keys out of reach of the next compromised package

BotPassword is in early access. Request an invite and we'll email you when your spot opens.