Remote Prompt Injection in Gitlab Duo Leads to Source Code Theft
GitLab Duo, an AI assistant, was vulnerable to remote prompt injection through hidden instructions in project content, allowing an attacker to manipulate its responses and inject HTML. This could lead to theft of private source code and confidential issue data via exfiltration to an attacker-controlled server.
legitsecurity.com
Published on legitsecurity.com
That’s exactly what we uncovered: a remote prompt injection vulnerability that allows attackers to steal source code from private projects, manipulate code suggestions shown to other users, and even exfiltrate confidential, undisclosed zero-day vulnerabilities — all through GitLab Duo Chat.
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 assistant treated all project content as trusted instructions and rendered its responses as HTML without adequate sanitisation, allowing hidden prompts to manipulate behaviour and inject active HTML.
Impact
An attacker could steal private source code and confidential issue data, and manipulate code suggestions, but GitLab patched the issue and the exploit chain is no longer possible.
What the attacker needed
Victim uses GitLab Duo; attacker can add content to a public project; victim interacts with Duo on that content
How it was found
- Attacker embeds a hidden prompt in a merge request description for a public project.
- Victim user interacts with Duo by asking for a code review or merge request analysis.
- Duo processes the hidden prompt and injects a malicious <img> tag into the response.
- The browser sends a GET request to the attacker's server, which contains sensitive source code as a Base64-encoded parameter.
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.
GitLab Duo is an AI helper inside GitLab that reads code and comments to answer questions. Attackers could hide secret instructions in places like merge request descriptions, and the AI would follow them, even though they were not from the user. This let attackers trick the AI into sending private code to their own servers.
What is AI / LLM?
Prompt injection, data exfiltration and tool abuse in features built on language models, and the ordinary bugs around them.