What is Gitpod?
Gitpod's WebSocket API accepted cross-origin connections with the victim's cookies, allowing an attacker-controlled page to request the user's GitHub access token. Separately, the login flow could be pointed at a self-managed GitLab instance, letting an attacker log in as any Gitpod account by choosing the email address.
about.gitlab.com
Published on about.gitlab.com
While looking at GitLab's Gitpod integration, I came across two rather critical flaws in Gitpod itself. In this post, I'll cover the process of identifying the vulnerabilities and some background on Gitpod.
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 WebSocket endpoint did not check the Origin header, and the login flow trusted the email from an arbitrary OAuth provider without verifying the provider was a trusted one.
Impact
An attacker could steal a logged-in user's GitHub, GitLab or Bitbucket access token and impersonate them, though the first attack required luring the user to an exposed port; the second allowed logging in as any account.
What the attacker needed
Victim is logged in to Gitpod; victim visits attacker-controlled page; attacker controls a self-managed GitLab instance
The fix
The WebSocket issue was fixed in Gitpod's May 2021 release and the login issue was fixed within about five hours.
How it was found
- Expose an application port from a Gitpod workspace to get a page under the same subdomain.
- Serve a script on that page that opens a WebSocket to the main Gitpod API.
- Send a getToken request over the WebSocket for github.com.
- Read the returned access token and use it against the GitHub API.
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 WebSocket is a two-way connection a web page can open to a server. Normally a site should only accept such connections from its own pages, but Gitpod accepted them from any site, so a malicious page could ask for the user's GitHub token. In the second bug, Gitpod trusted the email address returned by a GitLab server the attacker controlled, so the attacker could pretend to be any user.
What is Account takeover?
Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.