GitHub MCP exploited: Accessing private repositories via MCP
A malicious GitHub issue on a public repository can contain a prompt injection that manipulates an AI agent using the GitHub MCP server into reading private repository data and leaking it into a public pull request. An attacker could thus exfiltrate sensitive information from private repositories.
invariantlabs.ai
Published on invariantlabs.ai
Invariant has discovered a critical vulnerability affecting the widely-used GitHub MCP integration (14k stars on GitHub). The vulnerability allows an attacker to hijack a user's agent via a malicious GitHub Issue, and coerce it into leaking data from private repositories.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the agent treats untrusted content from GitHub issues as instructions, allowing indirect prompt injection to trigger a sequence of tool calls that leak private data.
Impact
An attacker could exfiltrate private repository data, such as project details and personal information, by leaking it into a public pull request; the attack works with any agent using the GitHub MCP server, though Claude Desktop by default requires user confirmation of tool calls.
What the attacker needed
Agent uses GitHub MCP server; attacker can create issue on public repo; user prompts agent to check issues
The fix
The vulnerability should be fixed at the agent system level by implementing granular permission controls (e.g., limiting agent access to only necessary repositories) and continuous security monitoring.
How it was found
- Create a public repository and a private repository.
- Place a malicious issue containing a prompt injection in the public repository.
- Prompt the agent to look at open issues in the public repository.
- The agent reads the malicious issue and follows its instructions.
- The agent pulls private repository data into context.
- The agent creates a pull request in the public repository containing the private data.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
An AI agent connected to GitHub can be tricked by a malicious issue into reading private code and posting it publicly. The issue contains hidden instructions that the agent follows, thinking they are part of the user's request.
What is AI / LLM?
Prompt injection, data exfiltration and tool abuse in features built on language models, and the ordinary bugs around them.