Skip to content
CSRF Write-up Advanced

Gitpod remote code execution 0day vulnerability via WebSockets

The Gitpod server's WebSocket JSONRPC endpoint lacked Origin checks and relied solely on cookies for authentication, allowing cross-site WebSocket hijacking. By hosting a malicious page on a workspace subdomain (same site as gitpod.io), an attacker could bypass SameSite cookies and execute JSONRPC calls to take over the victim's account and workspaces.

Elliot Ward Follow

Published on snyk.io

In this post, we present the first findings from our current research into Cloud Development Environments (CDEs) — which allowed a full account takeover through visiting a link, exploiting a commonly misunderstood vulnerability (WebSocket Hijacking), and leveraging a practical SameSite cookie bypass.

Elliot Ward, on snyk.io

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 WebSocket endpoint did not validate the Origin header and relied solely on cookies for authentication, and the SameSite cookie policy was bypassed because the attacker's page was hosted on a subdomain of the same site.

Impact

An attacker could take over a victim's Gitpod account and workspaces, including adding an SSH key for persistent access, by tricking the victim into visiting a link.

What the attacker needed

Victim clicks a link; attacker has a Gitpod account; attacker can host content on a workspace subdomain

The fix

The vulnerability was fixed by Gitpod within a single working day, and a new version was released for self-hosted instances.

How it was found

  1. Set up a Gitpod account and observe the WebSocket handshake to the server.
  2. Tamper with the Origin header to confirm that cross-origin WebSocket connections are accepted.
  3. Host a malicious page on a workspace subdomain to bypass SameSite cookies.
  4. Patch the VS Code server to serve the malicious HTML at the /version endpoint.
  5. Send the link to a victim; when visited, the page opens a WebSocket to gitpod.io and executes JSONRPC calls.
  6. Use the JSONRPC methods to extract tokens and add an SSH key, gaining full workspace access.

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.

WebSockets let a website and server talk in real time. Normally, a browser stops one website from reading responses from another, but WebSockets do not have that protection. If a site uses only cookies to authenticate WebSocket connections, a malicious site can open a connection and read the data, which is called cross-site WebSocket hijacking.

What is CSRF?

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

More by Elliot Ward

View all

1 more disclosed report, best first.

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.