Skip to content
CSRF Write-up Advanced

CSRFing VS Code's Debug Adapter Protocol

Debug adapters that listen on a local TCP port accept any connection without authentication, and their message framing is identical to HTTP/1.x. A malicious web page could therefore send cross-site requests to those ports that the adapter parses as debug commands, letting the page launch arbitrary processes on the developer's machine.

Dan McNulty Follow

Published on mcnulty.blog

Local debug adapter TCP servers, deployed as part of a Debug Adapter Protocol (DAP) implementation used by VS Code, Visual Studio and other development tools, are vulnerable to cross-site request forgery (CSRF) from malicious JavaScript executed in the IDE user's web browser. This CSRF vulnerability opens the door for…

Dan McNulty (@_Z7mcnulty), on mcnulty.blog

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 debug adapter neither authenticated nor authorised connections to its local TCP port, and its parser accepted HTTP/1.1 framing as valid DAP messages because both use a Content-Length header followed by a body.

Impact

For debug adapters that expose a launch capability, this could give an attacker code execution on the developer's host and a foothold into the software supply chains the developer can reach; the author notes the impact varies by adapter, and the Java debugger issue was fixed in version 0.48.0.

What the attacker needed

Debug adapter uses a local TCP port; developer ran a debug session earlier; victim visits a malicious page

The fix

The issue was fixed in the Java debugger extension in version 0.48.0, and the author notes that either authenticating connections or making the parser stricter would remove the flaw.

How it was found

  1. Start a debug session in the editor so a debug adapter opens a local TCP port.
  2. Get the developer's browser to load a page with malicious JavaScript.
  3. Scan localhost ports to find likely debug adapter servers.
  4. Send cross-site POST requests with a text/plain content type carrying a forged launch request.
  5. The adapter parses the request body as a DAP command and executes it.

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.

A debugger extension in an editor sometimes opens a small server on your own computer so the editor can talk to it. That server trusted anything that connected to it, and it read incoming data the same way a web server reads a request. So a website you visited could quietly send it instructions, and the debugger would run them as if the editor had asked.

What is CSRF?

Another site makes a signed-in user's browser perform an action they did not intend.

More from Microsoft (VS Code)

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site request forgery (CSRF)

The lesson behind this report.

Another site makes a signed-in user's browser perform an action they did not intend.