Your AI Coding Assistant Is Now the Vulnerability
A path normalisation flaw in Visual Studio Copilot allowed an attacker to bypass a guardrail that protected sensitive configuration files by appending a trailing dot to the filename. Once the configuration was writable, the attacker could register a malicious MCP server or point a setting to an arbitrary executable, leading to remote code execution.
Published on thezubairusman.medium.com
A trailing dot, a trusted config file, and an agent with the keys to your machine: why the IDE became the attack surface.
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
The guardrail compared the raw filename string against a protected name, but Windows file APIs strip trailing dots, so the check and the actual file operation disagreed.
Impact
An attacker could achieve remote code execution on the developer's machine by chaining indirect prompt injection with the path bypass, and the same vulnerable library affected both Visual Studio and SQL Server Management Studio.
What the attacker needed
Copilot processes untrusted content; User asks assistant to read untrusted content; Windows operating system
The fix
The fix normalises the path with a GetFullPath call before the check, and users should update Visual Studio 2022 to build 17.14.42 or later, or Visual Studio 2026 to 18.10.4 or later.
How it was found
- The attacker delivers untrusted content to Copilot, such as a poisoned file or web page, to perform indirect prompt injection.
- Copilot is tricked into writing to a protected configuration file by using a filename with a trailing dot, which bypasses the name check.
- The modified configuration registers a malicious MCP server or sets ripgrepPath to an arbitrary executable.
- Visual Studio automatically launches the rogue MCP server or the executable when the assistant runs a text search, achieving code execution.
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.
The AI assistant inside Visual Studio was supposed to ask before changing its own important settings files. But the check only compared the filename as text, and Windows ignores a dot at the end of a filename. So an attacker could sneak past the check and change those files anyway, then make the assistant run harmful commands.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.