# GitHub MCP indirect prompt injection → private repo exfil

- ID: invariant-github-mcp-private-repo-2025-05
- Reported: 2025-05-26
- Researcher: Invariant Labs
- Organization: Invariant Labs
- AI role: ai_agent_or_mcp_as_target (Agent / MCP as target)
- Confidence in AI involvement: not assessed
- Research / borderline: false
- Last reviewed: 2026-10-20
- Entry page: https://openattacks.ai/attacks/invariant-github-mcp-private-repo-2025-05/
- Entry JSON: https://openattacks.ai/api/attacks/invariant-github-mcp-private-repo-2025-05.json
- Browse title: GitHub MCP prompt injection leaks private repositories
- Editorial summary: Research showed a malicious public GitHub issue can coerce an agent using GitHub MCP to leak private repo contents publicly. The root cause is an architectural trust issue, not a code bug.
- Evidence class (catalog annotation): Research demonstration
- Source-stated target environments: Agents & MCP; Developer workflows
- Stage hunts and conditional defenses: https://openattacks.ai/api/defenses/invariant-github-mcp-private-repo-2025-05.json

## Technique
Malicious GitHub issue content can indirectly prompt-inject an agent using the official GitHub MCP server. When a user asks the agent to inspect public issues, the agent can be coerced to read private repositories and leak contents via public PR/issue. Architectural trust issue (broad agent permissions + untrusted GitHub content), not a simple GitHub MCP code bug.

## Stack relevance (editorial)
Assessment: mapped. Editorial applicability reviewed against the catalog source account; not a scan or independent incident verification.
First action: Separate public issue content from private-repository access and restrict the GitHub MCP token.
- Relationship: workflow; tools: no specific product; OS scope: not OS-specific / not stated; requires existing MCP connections: true.
  Relevance: The demonstration combines untrusted GitHub issue text with an agent able to read private repositories.
  Condition to check: Confirm use of GitHub MCP, access to both public issues and private repository data, and a path to publish that data.
  Evidence: https://invariantlabs.ai/blog/mcp-github-vulnerability
A product mention alone is not a victim-side applicability mapping. Selection does not verify affected versions, permissions or compromise.

## Initial access
User asks agent with GitHub MCP to process attacker-controlled public issue

## AI tooling and models
- [GitHub MCP server](https://github.com/github/github-mcp-server)
- coding agents

## Other tooling
- unknown

## Victims and sectors
unknown

## Target geography
- unknown

## Attribution
unknown

## Scale and metrics
unknown

## Attack flow
Catalog reconstruction of the supplied source account. Unknowns and research caveats are preserved.
### step-1: Agent reads an attacker issue [access]
A user asks an agent with GitHub MCP access to inspect public issues.
Evidence: https://invariantlabs.ai/blog/mcp-github-vulnerability

### step-2: Issue instructions override the task [ai]
Indirect prompt injection redirects the model through untrusted issue content.
Evidence: https://invariantlabs.ai/blog/mcp-github-vulnerability

### step-3: Agent accesses private repositories [execution]
Broad tool permissions let the agent retrieve private data.
Evidence: https://invariantlabs.ai/blog/mcp-github-vulnerability

### step-4: Private content becomes public [impact]
The demonstrated chain leaks content through a public pull request or issue.
Evidence: https://invariantlabs.ai/blog/mcp-github-vulnerability

Connections:
- step-1 -> step-2
- step-2 -> step-3
- step-3 -> step-4

## Stage defense and hunting recommendations
Editorial recommendations, not validated coverage. Source-controlled query starters are drafts. Custom-schema examples require telemetry collection and field mapping; absence of a mapping means not assessed. MagicSword policy opportunities require managed Windows scope and enforcement.
### step-1: Unexpected agent tool use
- Visibility: Defender-side logs where collected
- Query origin: catalog_authored; status: draft; log scope: custom_schema
- SIGMA query download: /api/detections/agent-tools.sigma.yml
- KQL query download: /api/detections/agent-tools.kql
- SPL query download: /api/detections/agent-tools.spl
- Hunt hypothesis: Untrusted content or a changed tool definition precedes a file read, command, or remote call outside the user's intended task.
- Required telemetry: Agent tool-call audit records with session / tool / destination; Tool-definition and approval changes; Endpoint process, file-access and network evidence where available
- Investigate: Join input provenance, tool descriptions and calls by session ID and compare the action to the approved task.
- Investigate: Inspect child processes and destinations; record whether execution was in-process, local, or through a remote SaaS connector.
- Limitation: Process logs cannot recover model intent. Remote connectors and in-process interpreters may produce no local child process. Prompt content alone is not a reliable signature.
- No direct MagicSword prevention claim is recorded for this stage.

### step-2: Untrusted content enters an agent session
- Visibility: Application / agent audit records
- Query origin: catalog_authored; status: draft; log scope: custom_schema
- SIGMA query download: /api/detections/agent-input.sigma.yml
- KQL query download: /api/detections/agent-input.kql
- SPL query download: /api/detections/agent-input.spl
- Hunt hypothesis: An agent ingests external content or an untrusted session identifier before a tool action or configuration change outside the approved task.
- Required telemetry: Input provenance, source type and request/session identifier; Captured tool responses or retrieved content where collection is approved; Subsequent tool calls, configuration changes and approval decisions
- Investigate: Join the ingested input to later actions by session or request ID; preserve the original content as evidence.
- Investigate: Compare the resulting action with the approved task and baseline. Receiving suspicious text alone is not successful injection.
- Limitation: Requires application instrumentation and a custom field mapping. Input exposure does not prove that the model followed instructions, executed a tool or bypassed approval. Avoid collecting sensitive prompt bodies unless authorized.
- Qualification: Preserve issue-result provenance and the agent session, then inspect later repository reads and public writes.
- No direct MagicSword prevention claim is recorded for this stage.

### step-3: Private access → public repository artifact
- Visibility: Defender-side logs where collected
- Query origin: catalog_authored; status: draft; log scope: custom_schema
- SIGMA query download: /api/detections/repository.sigma.yml
- KQL query download: /api/detections/repository.kql
- SPL query download: /api/detections/repository.spl
- Hunt hypothesis: A token or agent reads private material and creates a public issue, repository, commit or visibility change inconsistent with the approved task.
- Required telemetry: Git-provider organization / enterprise audit; Repository and token permission inventory; Agent tool and secret-scanning / DLP records
- Investigate: Join access and public-write actions by actor / token and time; inspect visibility changes and newly created repositories.
- Investigate: Verify whether the artifact contains sensitive data using approved scanning, retaining original source qualifications.
- Limitation: Git-provider audit completeness depends on product and plan. Not every file read or issue body is present in organization audit logs.
- No direct MagicSword prevention claim is recorded for this stage.

### step-4: Private access → public repository artifact
- Visibility: Defender-side logs where collected
- Query origin: catalog_authored; status: draft; log scope: custom_schema
- SIGMA query download: /api/detections/repository.sigma.yml
- KQL query download: /api/detections/repository.kql
- SPL query download: /api/detections/repository.spl
- Hunt hypothesis: A token or agent reads private material and creates a public issue, repository, commit or visibility change inconsistent with the approved task.
- Required telemetry: Git-provider organization / enterprise audit; Repository and token permission inventory; Agent tool and secret-scanning / DLP records
- Investigate: Join access and public-write actions by actor / token and time; inspect visibility changes and newly created repositories.
- Investigate: Verify whether the artifact contains sensitive data using approved scanning, retaining original source qualifications.
- Limitation: Git-provider audit completeness depends on product and plan. Not every file read or issue body is present in organization audit logs.
- No direct MagicSword prevention claim is recorded for this stage.


## MITRE ATLAS
Mappings are catalog annotations based on described behavior, not assignments or endorsements by MITRE.
- AML.T0051.001: Indirect — Public GitHub issue content indirectly injects the agent.
  Technique: https://atlas.mitre.org/techniques/AML.T0051.001
  Evidence: https://invariantlabs.ai/blog/mcp-github-vulnerability
- AML.T0086: Exfiltration via AI Agent Tool Invocation — GitHub write tools publish private repository content.
  Technique: https://atlas.mitre.org/techniques/AML.T0086
  Evidence: https://invariantlabs.ai/blog/mcp-github-vulnerability

## Defensive notes
Scope MCP tokens per-repo; block cross-repo actions; treat issues as untrusted input

## Sources
- https://invariantlabs.ai/blog/mcp-github-vulnerability
