the_open_door
coffee
ESEN
← Back to index

RCE in JetBrains TeamCity (CVE-2023-42793)

TeamCity On-Premises before 2023.05.4 carries an authentication bypass in its REST API that an unauthenticated attacker can chain up to remote code execution as the CI server user.

The chain has two parts:

curl -X POST "http://<ip>/app/rest/users/id:1/tokens/RPC2" -H "Content-Type: application/json"

On a CI this is especially serious: the server usually holds deployment credentials, SSH keys and repository tokens (secrets in source), and its build history may contain recoverable private keys (.git dump).

Nuances. It affects TeamCity On-Premises; TeamCity Cloud was patched by the vendor. The exact bypass path depends on the version, so confirm the version (/login.html shows it) before firing a specific PoC.

How to detect it. The bypass leaves a recognizable signature in the access log: requests that force a 404 on a prior resource and then an unauthenticated POST to /app/rest/users/id:1/tokens/..., i.e. the creation of a token for an administrative account through a path that skips the session. On the host, the RCE phase shows as the TeamCity process (java) spawning an anomalous child after internal server parameters are modified or a plugin/script is deployed. The creation of an administrative token from an external IP, or a change to the build-tools path followed by execution, is the chain.

Defence. Upgrade to 2023.05.4 or later; restrict network access to the CI panel; rotate stored tokens and credentials after any suspicion, since their value persists beyond the patch.

Machines where it's used