Skip to content
AI / LLM Write-up Advanced

Prompt injection engineering for attackers: Exploiting GitHub Copilot

A prompt injection hidden in a GitHub issue can trick GitHub Copilot into inserting a backdoor into a project's dependency lock file. If a maintainer assigns Copilot to the issue and merges the resulting pull request, an attacker can execute arbitrary commands on the deployed application.

blog.trailofbits.com

Published on blog.trailofbits.com

Prompt injection pervades discussions about security for LLMs and AI agents. But there is little public information on how to write powerful, discreet, and reliable prompt injection exploits.

The author, on blog.trailofbits.com

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 AI agent cannot distinguish between legitimate and injected instructions because the issue text is passed to it without proper isolation or sanitisation.

Impact

If a maintainer assigns Copilot to the issue and merges the resulting pull request, the attacker could execute arbitrary commands on the deployed application.

What the attacker needed

Public repository; maintainer assigns Copilot to issue; maintainer merges pull request

How it was found

  1. The attacker opens a helpful GitHub issue on a public repository owned by the victim.
  2. The victim assigns Copilot to the issue to have it implement a fix.
  3. The issue contains a prompt injection attack that causes Copilot to discreetly insert a backdoor for the attacker in its pull request, which the victim merges.

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.

This is about tricking an AI assistant that writes code. An attacker posts a normal-looking request on a code hosting site, but hides instructions that only the AI can see. When the AI follows those hidden instructions, it adds harmful code that lets the attacker run commands on the server.

What is AI / LLM?

Prompt injection, data exfiltration and tool abuse in features built on language models, and the ordinary bugs around them.

Similar reports

View all

Same bug class and techniques, clearest first.

AI and LLM vulnerabilities

The lesson behind this report.

Prompt injection, data exfiltration and tool abuse in features built on language models, and the ordinary bugs around them.