Source Code at Risk: Critical Code Vulnerability in CI/CD Platform TeamCity
An authentication bypass in JetBrains TeamCity allowed unauthenticated attackers to create an authentication token for any user, including the default administrator, by exploiting a wildcard path expression that disabled authorization checks for requests ending in /RPC2. This gave attackers administrative access, enabling remote code execution, source code theft, and supply chain compromise.
Published on sonarsource.com
TeamCity is a widely used Continuous Integration and Continuous Deployment (CI/CD) server from JetBrains deployed by more than 30,000 customers worldwide. The application can either be used via the cloud-hosted solution TeamCity Cloud or deployed on an own server via TeamCity on-premises.
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
A wildcard path expression in a global request interceptor disabled authorization checks for any request whose path ended with /RPC2, and a hidden REST endpoint allowed token creation for any user via a path parameter.
Impact
An unauthenticated attacker could gain administrative access and execute arbitrary code, leading to theft of source code, secrets, and private keys, and allowing injection of malicious code into build pipelines.
What the attacker needed
TeamCity on-premises version 2023.05.3 or below; Network access to the TeamCity server
The fix
The vulnerability was fixed in TeamCity version 2023.05.4 by removing the wildcard expression so that pre-handling is only disabled for direct requests to /RPC2 without any prefixes.
How it was found
- Send a request to the hidden token creation endpoint with a path that ends in /RPC2 and includes a user locator and token name.
- The request bypasses authentication because the path matches the wildcard expression.
- The response contains an authentication token for the specified user.
- Use the token to access the application as that user, such as the default administrator.
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.
TeamCity is a server that automatically builds and tests software. A security check that was supposed to run on every request could be skipped for certain web addresses, so an attacker could pretend to be an administrator without logging in. Once inside, they could change the software being built, which is very dangerous.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.