Skip to content
AI / LLM Disclosed report Advanced

Source Code and data exfiltration via Github Copilot

Copilot Chat rendered attacker-controlled image links and hidden HTML from prompt-injected content, allowing data exfiltration via URL parameters. A compromised session could exfiltrate workspace source code to an attacker domain.

Marlon Fabiano Follow

Originally disclosed on HackerOne

  • Triaged in 49 days
  • Fixed in 5 months
  • Paid in 5 months
  • Disclosed after 6 months

Summary by the program

Due to insecure output handling in Copilot client interfaces, a prompt injection initiated attack was able to result in data exfiltration in a number of ways. A user that was prompt injected, by running Copilot Chat in a specific manner on an untrusted repository, could have generated arbitrary image links pointing to an attacker controlled domain that would be rendered in the Copilot Chat interface, allowing for data exfiltration via URL parameters. This attack could potentially have allowed a compromised Copilot session (Copilot Chat being called on a malicious cloned local repository) to exfiltrate the contents of the same workspace to the malicious domain.

Other risky behaviors that were also noted was that links could be created to attacker controlled domains via Copilot, which would not be immediately apparent to end users, causing another avenue for data exfiltration which required more user interaction, lowering the severity.

This vulnerability was addressed by only rendering images from trusted domains, and by adding interstitial modals to let users know where links pointed. GitHub also hardened the rendering specification for all Copilot clients to ensure that the context provided to Copilot is made more apparent to end users to mitigate the impact of unseen content affecting the output of Copilot.

Summary by the researcher

** Prompt Injection in GitHub Copilot Leading to Source Code Exfiltration **

Description: This vulnerability exploits the way GitHub Copilot handles instructions within chat, workspace and code suggestion features.

By utilizing prompt injection techniques (direct and indirect), an attacker can manipulate Copilot to embed and execute hidden malicious instructions. These instructions can then be used to exfiltrate sensitive information, such as the developer’s source code, to an attacker-controlled domain. The issue arises due to Copilot's insecure handling of output, where it can process instructions input directly into the chat or inserted into a workspace file and execute embedded malicious content without the user's knowledge. The Copilot chat's ability to render certain HTML tags (e.g., <h1>) invisibly to the user further exacerbates the risk, allowing an attacker to hide their payload from the victim.

Impact: The impact of this vulnerability is very interesting, as it allows an attacker to extract sensitive source code from a developer’s environment (credentials, tokens, configurations, etc.). Copilot’s ability to render and execute hidden commands without the user’s knowledge amplifies the potential damage. VS Code and Jet Brains were affected. GitHub.com was not affected.

The original report as published on HackerOne, by astrounder. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 5 min read.

Context

GitHub Copilot is the AI assistant integrated into developer tooling, including the Copilot Chat interfaces in VS Code and JetBrains IDEs. Copilot Chat takes instructions from the user, from the workspace and from code suggestions, and renders its output back into the client interface. That output can include HTML elements and links, which the client renders for the user.

The report concerns the way those client interfaces handle Copilot's output. The program's summary describes the class of issue as insecure output handling: a prompt injection attack that could result in data exfiltration in a number of ways. The researcher classifies the weakness as code injection and rates the severity low. The affected products named in the report are VS Code and JetBrains; GitHub.com was not affected.

Setup

The report does not describe any accounts, roles, tool versions or specific configuration. The precondition it does describe is behavioural: a user runs Copilot Chat in a specific manner on an untrusted repository. In the exfiltration scenario the program describes, Copilot Chat is called on a malicious cloned local repository, so the attacker controls content inside the workspace that Copilot reads as context.

Finding it

The researcher noticed that Copilot processes instructions that arrive through several channels: input typed directly into the chat, content inserted into a workspace file, and the code suggestion features. Because Copilot does not reliably distinguish instructions from data, an attacker who can place text in any of those channels can embed hidden malicious instructions that Copilot then follows.

The second observation is about rendering. Copilot Chat can render certain HTML tags, for example <h1>, invisibly to the user. That gives an attacker a way to hide a payload from the victim while it is present in the conversation, and it is what turns an instruction-following problem into an exfiltration channel.

Exploitation

The program's summary and the researcher's summary describe the attack at the level of mechanism rather than with individual requests. The report contains no HTTP requests, payloads, commands or responses, so the steps below follow the described behaviour only.

Step 1: get instructions into Copilot's context

The attacker uses prompt injection, both direct and indirect. Direct injection means instructions typed into the chat; indirect injection means instructions placed in content Copilot consumes, such as a file in the workspace. The program's scenario is the indirect case: the victim clones a malicious repository and runs Copilot Chat on it, so the repository content carries the attacker's instructions.

Step 2: make Copilot produce attacker-controlled output

Once the injected instructions are followed, Copilot generates output chosen by the attacker. In the image-based variant, that output is an arbitrary image link pointing to an attacker-controlled domain. In the link-based variant, Copilot creates links to attacker-controlled domains.

Step 3: render the output in the chat interface

The Copilot Chat interface renders the generated image link. Because the link points at the attacker's domain, the client's request to fetch the image reaches the attacker, and data placed in the URL parameters travels with it. This is the exfiltration channel: the URL parameters are under the attacker's control through the injected instructions.

Step 4: exfiltrate workspace contents

The program states that this attack could potentially have allowed a compromised Copilot session, meaning Copilot Chat being called on a malicious cloned local repository, to exfiltrate the contents of the same workspace to the malicious domain. The researcher's impact statement is broader: the attacker can extract sensitive source code from the developer's environment, including credentials, tokens and configurations.

Step 5: the link variant

The report also notes a second avenue: links created via Copilot to attacker-controlled domains that would not be immediately apparent to end users. This variant requires more user interaction, which the program says lowers the severity.

Root cause

The mistake is insecure output handling in the Copilot client interfaces. Copilot's output is treated as renderable content, so HTML and links produced under the influence of injected instructions are displayed and, for images, fetched by the client. Before the fix, images from arbitrary domains were rendered and link destinations were not made apparent, which the fix addressed. The researcher also points to Copilot's handling of instructions: it processes instructions input directly into the chat or inserted into a workspace file and acts on embedded malicious content without the user's knowledge. The ability to render HTML tags such as <h1> invisibly compounds this, because the payload can be hidden from the victim.

Impact

An attacker who can get instructions in front of Copilot, for example by hosting a repository the victim clones and runs Copilot Chat against, could cause data from the same workspace to be sent to an attacker-controlled domain through image URL parameters. The researcher describes the extractable data as sensitive source code from the developer's environment, including credentials, tokens and configurations. The program hedges the workspace exfiltration as something the attack could potentially have allowed. The link-based avenue requires more user interaction and was therefore rated lower. VS Code and JetBrains were affected; GitHub.com was not.

Fix

  1. Images are now rendered only from trusted domains.
  2. Interstitial modals were added so users are told where links point before following them.
  3. The rendering specification for all Copilot clients was hardened so that the context provided to Copilot is made more apparent to end users, mitigating the impact of unseen content on Copilot's output.

Variants to test

  • Indirect prompt injection through repository content: place instructions in a file in a repository and run the assistant's chat against it. A positive result is the assistant producing output that follows the injected instruction rather than the user's request.
  • Image-based exfiltration: get the assistant to emit an image link to a domain you control with data in the URL parameters. A positive result is a request arriving at your domain carrying the data.
  • Link-based exfiltration: get the assistant to emit a link to a domain you control. A positive result is a link the user cannot distinguish from a legitimate one before clicking.
  • Hidden HTML rendering: get the assistant to emit HTML tags that render without being visible to the user. A positive result is content present in the conversation that the user does not see.
  • Client coverage: repeat the above in each assistant client you have access to. A positive result is any client that renders attacker-controlled images or links without domain restrictions or an interstitial warning.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 10 min read.

What happened, in plain words

GitHub Copilot is an AI assistant built into the tools developers use to write code. You type a request in plain language, and it answers, often by writing code for you. It lives inside programs called IDEs (integrated development environments), such as VS Code and JetBrains, and it also has a chat panel, Copilot Chat, where you talk to it.

Copilot Chat does not only read what you type. It also reads the files in the folder you have open (the workspace) and the code suggestions it offers. It then shows its answer back inside the chat window, and that answer can contain formatting and links, including images.

The problem in this report is what happens when someone slips instructions into that material. If a developer opens a folder downloaded from an attacker and asks Copilot about it, the attacker's text can end up being treated as an instruction rather than as content to read. Copilot then produces output the attacker chose, for example an image link pointing at the attacker's own website. When the chat window displays that image, the developer's computer fetches it from the attacker's site, and anything the attacker packed into the link travels along with the request. That is how data leaves the machine.

The report calls this class of mistake insecure output handling. The researcher labels the weakness code injection and the severity low. The affected products were VS Code and JetBrains. GitHub.com was not affected.

Context

To follow the rest of this article you need a few ideas from zero.

  • IDE: the program a developer writes code in. Think of it as a very capable text editor with extra buttons. VS Code and JetBrains make IDEs.
  • Workspace: the folder of files you have open in the IDE. Copilot can read those files to give better answers, the same way a colleague might glance at your notes before helping.
  • Copilot Chat: the conversation panel inside the IDE. You ask a question, it answers.
  • Rendering: turning text into something visual. When a chat window sees a link, it may draw it as a clickable link, and when it sees an image address, it may download and show the picture. The program doing this is the client.
  • HTML: the language web pages are written in. Tags like <h1> mark up a heading. A chat window that renders HTML will interpret such tags instead of showing them as plain text.
  • Prompt injection: tricking an AI assistant by hiding instructions in something it reads. Compare it to a note slipped into a stack of papers that says "ignore the reader and do this instead". The assistant cannot always tell the difference between the papers' content and an order.
  • Data exfiltration: getting data out of a place it is supposed to stay in, and into the hands of someone else.

The report concerns the way the Copilot client interfaces handle Copilot's output. The program's summary describes the class of issue as insecure output handling: a prompt injection attack that could result in data exfiltration in a number of ways. The researcher classifies the weakness as code injection and rates the severity low. The affected products named in the report are VS Code and JetBrains; GitHub.com was not affected.

Setup

The report does not describe any accounts, roles, tool versions or specific configuration. The precondition it does describe is behavioural: a user runs Copilot Chat in a specific manner on an untrusted repository. In the exfiltration scenario the program describes, Copilot Chat is called on a malicious cloned local repository, so the attacker controls content inside the workspace that Copilot reads as context.

Two words there are worth unpacking. A repository is a project folder kept under version control, usually downloaded (cloned) from a code hosting site. Cloning simply means copying it to your own computer. An untrusted repository is one whose contents you did not write and cannot vouch for, which is exactly the situation where an attacker can plant text.

Finding it

The researcher noticed that Copilot processes instructions that arrive through several channels: input typed directly into the chat, content inserted into a workspace file, and the code suggestion features. Because Copilot does not reliably distinguish instructions from data, an attacker who can place text in any of those channels can embed hidden malicious instructions that Copilot then follows.

The second observation is about rendering. Copilot Chat can render certain HTML tags, for example <h1>, invisibly to the user. That gives an attacker a way to hide a payload from the victim while it is present in the conversation, and it is what turns an instruction-following problem into an exfiltration channel.

Why does the invisible tag matter so much? Because the victim never sees the trick. If the payload were shown as plain text, the developer would notice something odd. Rendered but invisible, it sits in the conversation doing its work silently.

Exploitation

The program's summary and the researcher's summary describe the attack at the level of mechanism rather than with individual requests. The report contains no HTTP requests, payloads, commands or responses, so the steps below follow the described behaviour only.

Step 1: get instructions into Copilot's context

The attacker uses prompt injection, both direct and indirect. Direct injection means instructions typed into the chat; indirect injection means instructions placed in content Copilot consumes, such as a file in the workspace. The program's scenario is the indirect case: the victim clones a malicious repository and runs Copilot Chat on it, so the repository content carries the attacker's instructions.

Why this step comes first: the assistant can only be steered by text it actually reads. Putting the text in a file means the attacker does not need the victim to type anything unusual; opening the project is enough.

Step 2: make Copilot produce attacker-controlled output

Once the injected instructions are followed, Copilot generates output chosen by the attacker. In the image-based variant, that output is an arbitrary image link pointing to an attacker-controlled domain. In the link-based variant, Copilot creates links to attacker-controlled domains.

A domain is the part of a web address that names the site, the bit after https://. An attacker-controlled domain is simply a website the attacker owns and can watch. Every time someone's computer loads something from it, the attacker sees the request arrive.

Step 3: render the output in the chat interface

The Copilot Chat interface renders the generated image link. Because the link points at the attacker's domain, the client's request to fetch the image reaches the attacker, and data placed in the URL parameters travels with it. This is the exfiltration channel: the URL parameters are under the attacker's control through the injected instructions.

A URL parameter is the extra part of a web address after a question mark, used to pass small pieces of information to a site. In https://example.com/pic?name=value, the parameter is name=value. Because the attacker wrote the instructions that produced the link, the attacker decides what goes in that parameter, and the value can be data taken from the workspace. The image itself may never be a real picture; the point is the request that carries the data.

Step 4: exfiltrate workspace contents

The program states that this attack could potentially have allowed a compromised Copilot session, meaning Copilot Chat being called on a malicious cloned local repository, to exfiltrate the contents of the same workspace to the malicious domain. The researcher's impact statement is broader: the attacker can extract sensitive source code from the developer's environment, including credentials, tokens and configurations.

A credential is a username and password pair, or similar proof of identity. A token is a long random string that acts like a temporary key, letting a program act on your behalf without your password. A configuration is the settings file that tells software how to connect to other services, and it often contains those keys. All three are valuable to an attacker, which is why source code folders are worth stealing.

Step 5: the link variant

The report also notes a second avenue: links created via Copilot to attacker-controlled domains that would not be immediately apparent to end users. This variant requires more user interaction, which the program says lowers the severity.

Why lower? Because the victim has to click. An image loads by itself, but a link only does something when someone follows it, and a careful user might hesitate. More steps for the attacker means less reliable success.

Root cause

The mistake is insecure output handling in the Copilot client interfaces. Copilot's output is treated as renderable content, so HTML and links produced under the influence of injected instructions are displayed and, for images, fetched by the client. Before the fix, images from arbitrary domains were rendered and link destinations were not made apparent, which the fix addressed. The researcher also points to Copilot's handling of instructions: it processes instructions input directly into the chat or inserted into a workspace file and acts on embedded malicious content without the user's knowledge. The ability to render HTML tags such as <h1> invisibly compounds this, because the payload can be hidden from the victim.

In everyday terms: the chat window trusted whatever the assistant handed it. The fix restricts images to trusted domains, adds modals showing where links lead, and makes Copilot's context more apparent.

Impact

An attacker who can get instructions in front of Copilot, for example by hosting a repository the victim clones and runs Copilot Chat against, could cause data from the same workspace to be sent to an attacker-controlled domain through image URL parameters. The researcher describes the extractable data as sensitive source code from the developer's environment, including credentials, tokens and configurations. The program hedges the workspace exfiltration as something the attack could potentially have allowed. The link-based avenue requires more user interaction and was therefore rated lower. VS Code and JetBrains were affected; GitHub.com was not.

Fix

GitHub addressed the vulnerability in three ways, according to the program's summary:

  1. Images are now rendered only from trusted domains.
  2. Interstitial modals were added so users are told where links point before following them.
  3. The rendering specification for all Copilot clients was hardened so that the context provided to Copilot is made more apparent to end users, mitigating the impact of unseen content on Copilot's output.

An interstitial modal is a pop-up that stands between you and the action, asking you to confirm. Here it shows the real destination of a link before you click. Restricting images to trusted domains means the chat window will no longer fetch a picture from a site the attacker owns.

Variants to test

These are the checks the report's behaviour suggests, written so that someone new can follow the idea. They are descriptions of what to try, not instructions to attack anyone.

  • Indirect prompt injection through repository content: place instructions in a file in a repository and run the assistant's chat against it. A positive result is the assistant producing output that follows the injected instruction rather than the user's request.
  • Image-based exfiltration: get the assistant to emit an image link to a domain you control with data in the URL parameters. A positive result is a request arriving at your domain carrying the data.
  • Link-based exfiltration: get the assistant to emit a link to a domain you control. A positive result is a link the user cannot distinguish from a legitimate one before clicking.
  • Hidden HTML rendering: get the assistant to emit HTML tags that render without being visible to the user. A positive result is content present in the conversation that the user does not see.
  • Client coverage: repeat the above in each assistant client you have access to. A positive result is any client that renders attacker-controlled images or links without domain restrictions or an interstitial warning.

Glossary

  • Client: the program on your computer that talks to a service and displays the results, here the Copilot Chat panel inside an IDE.
  • Code injection: a weakness where input supplied by someone else is treated as instructions or code and acted on.
  • Configuration: a settings file that tells software how to behave, often holding connection details and keys.
  • Copilot Chat: the conversational panel of GitHub Copilot inside a developer's editor.
  • Credential: proof of identity such as a username and password.
  • Data exfiltration: moving data out of a protected place to somewhere the attacker controls.
  • Domain: the site-naming part of a web address, after https://.
  • HTML: the markup language used to describe web page content, including tags such as <h1>.
  • IDE: integrated development environment, the program developers write code in, such as VS Code or JetBrains.
  • Insecure output handling: accepting output from one component and rendering or acting on it without checking it is safe.
  • Interstitial modal: a confirmation pop-up shown before an action, used here to reveal where a link really points.
  • Prompt injection: hiding instructions in content an AI assistant reads so that it follows them instead of the user's request.
  • Rendering: turning text into visible output, such as drawing a link or loading an image.
  • Repository: a project folder kept under version control, often downloaded (cloned) from a hosting site.
  • Token: a random string that acts as a temporary key for a program, standing in for a password.
  • URL parameter: the part of a web address after a question mark that passes small values to a site.
  • Workspace: the folder of files open in an IDE, which Copilot can read as context.

More by Marlon Fabiano

View all

1 more disclosed report, best first.

More from GitHub

View all

The newest disclosed reports for this program.

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.