Skip to content
RCE Write-up Advanced

Your AI Coding Assistant Will Run Whatever Its Config File Says

Two AI coding tools turned attacker-influenced configuration or OAuth metadata into running commands: GitHub Copilot's protected-file check could be bypassed with a trailing dot on Windows, and opencode passed a valid-looking https URL containing a PowerShell subexpression to the shell. An attacker could achieve code execution on the user's machine, often chained with indirect prompt injection.

medium.com

Published on medium.com

[bug bounty hunters and appsec engineers] This month, a single trailing dot in GitHub Copilot’s own security prompt was turned into a remote code execution vulnerability.

Gopal Rajguru, on medium.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 a trust handoff where validation happens on one representation of a value (a raw filename string or a parsed URL) while execution happens on another (the OS-canonicalised path or the raw string passed to a shell).

Impact

An attacker could achieve remote code execution on the user's machine, with persistence via config and possible lateral movement using the agent's credentials; the opencode issue affected only Windows and WSL, and the Copilot issue required prompt injection to plant the malicious config.

What the attacker needed

AI coding agent with file write access; Attacker-controlled text in model context; Windows or WSL for the opencode case; Victim opens a malicious repository or issue

The fix

Microsoft fixed Copilot by normalising the file path with GetFullPath before comparing, and opencode was fixed by upgrading the open package so the argument is single-quoted and a scheme check was added.

How it was found

  1. Get attacker-controlled text into the agent's context, for example a poisoned README, issue or dependency file.
  2. Instruct the agent to write a malicious MCP server definition to the protected config file using a filename with a trailing dot.
  3. The confirmation check compares the raw name and allows the write; Windows strips the dot and writes the real config file.
  4. The IDE then launches the attacker's MCP server automatically.
  5. For opencode, have the remote server return an authorisation_endpoint that is a valid https URL containing a PowerShell subexpression.
  6. The URL passes the URL check and is passed to the open package, which on Windows runs it through PowerShell and executes the subexpression.

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.

These tools read configuration files and web addresses to decide what programs to start. The problem is that the part checking the value and the part actually running it looked at slightly different versions of the same text. So a value that looked harmless to the checker could still become a command when the operating system or shell handled it.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.