Back to Intelligence

CVE-2026-136858: Critical JetBrains TeamCity Flaw Exploited to Hijack Build Agents — Detection and Remediation Guide

SA
Security Arsenal Team
December 6, 2026
10 min read

Threat actors are actively exploiting a critical vulnerability in JetBrains TeamCity On-Premises, tracked as CVE-2026-136858, to hijack build agents in the wild. This is not a theoretical risk: a compromised CI/CD server is one of the highest-value targets in any environment, because build infrastructure sits at the intersection of source code, signing keys, deployment credentials, and production access. Organizations running internet-exposed or insufficiently segmented TeamCity servers should treat this as an emergency patch-and-hunt event.

If your TeamCity server is reachable from the internet, or from network segments where an attacker could already have a foothold, assume you are a target and move directly to the Detection and Remediation sections below.

Why a TeamCity Compromise Is a Tier-1 Incident

I've led multiple IR engagements where build infrastructure was the actual objective — not a stepping stone. A hijacked build agent gives an attacker:

  • Source code access across every project the agent builds.
  • Secrets at rest and in flight: API keys, cloud credentials, signing certificates, NuGet/npm/Maven tokens, and deployment passwords are routinely injected into builds as environment variables.
  • A supply-chain launchpad: an attacker who controls the build can inject malicious code into artifacts your developers and customers trust implicitly.
  • Lateral movement: build agents often have privileged network paths to artifact repositories, container registries, and deployment targets.

JetBrains TeamCity has been a repeat target for exactly these reasons, including state-aligned actors in past campaigns. Defenders should approach CVE-2026-136858 with the same urgency.

Technical Analysis

What We Know

  • Affected product: JetBrains TeamCity On-Premises (self-hosted server and connected build agents). TeamCity Cloud, hosted by JetBrains, is managed by the vendor and not the focus of this campaign.
  • Vulnerability: CVE-2026-136858, a critical flaw that allows attackers to compromise the TeamCity server and, through it, take control of connected build agents.
  • Exploitation status: Confirmed active exploitation in the wild, per reporting by BleepingComputer. This elevates the response from routine patch cycle to incident-response posture: patch and hunt for compromise that may predate the patch.
  • Attack flow (defender's view): the attacker targets the TeamCity server component, gains execution or administrative control within the TeamCity context, then leverages the server's trusted relationship with registered build agents to push malicious build steps or agent-side payloads. From the agent, the attacker inherits everything the agent can touch: source checkouts, build-time secrets, and downstream deployment paths.

For authoritative fixed-version information, refer directly to the JetBrains security advisory and the original reporting at BleepingComputer. Do not rely on third-party mirrors for version numbers — confirm against the vendor advisory and upgrade to the latest fixed TeamCity release immediately.

Key Defender Observations

The behaviors that matter for detection, regardless of the exact exploit primitive:

  1. The TeamCity server process spawning shells or scripting interpreters (cmd.exe, powershell.exe, /bin/sh, /bin/bash) — legitimate TeamCity builds run on agents, not on the server. Process execution under the server process is a strong signal of server-side compromise.
  2. New or modified build agent registrations — attackers hijack agents by registering rogue agents or reconfiguring authorized agent lists.
  3. Unexpected changes to build configurations — new build steps that download and execute remote payloads (curl/wget/Invoke-WebRequest chains) are classic post-exploitation behavior in CI/CD compromise.
  4. Webshell or dropped payloads in the TeamCity web application directories — a common persistence mechanism after exploiting web-facing flaws.

Detection & Response

The detections below target the post-exploitation behaviors described above. Tune the TeamCity installation paths and agent hostnames to your environment before deploying.

Sigma Rules

YAML
---
title: TeamCity Server Process Spawning Shell or Scripting Interpreter
id: 3f8c2a71-9b4d-4e6f-a1c2-7d5e8f0a9b3c
status: experimental
description: Detects the TeamCity server process (TeamCityService/java hosting the server) spawning command shells or scripting engines. Builds execute on agents, not the server, so child shell processes under the server are a strong indicator of server-side exploitation such as CVE-2026-136858.
references:
  - https://www.bleepingcomputer.com/news/security/critical-jetbrains-teamcity-flaw-exploited-to-hijack-build-agents/
  - https://attack.mitre.org/techniques/T1059/
author: Security Arsenal
date: 2026/04/06
tags:
  - attack.execution
  - attack.t1059
logsource:
  category: process_creation
  product: windows
detection:
  selection_parent:
    ParentImage|contains:
      - '\\TeamCity\\'
      - '\\teamcity-server\\'
    ParentCommandLine|contains:
      - 'teamcity'
  selection_child:
    Image|endswith:
      - '\\cmd.exe'
      - '\\powershell.exe'
      - '\\pwsh.exe'
      - '\\wscript.exe'
      - '\\cscript.exe'
      - '\\mshta.exe'
      - '\\rundll32.exe'
      - '\\certutil.exe'
      - '\\bitsadmin.exe'
      - '\\curl.exe'
      - '\\wget.exe'
  condition: selection_parent and selection_child
falsepositives:
  - TeamCity server-side plugins performing legitimate maintenance tasks (rare; investigate before excluding)
level: high
---
title: TeamCity Agent Executing Remote Download and Execute Chain
id: 8a1d4e62-3c7b-4f5a-9d2e-1b6c8a0f4e7d
status: experimental
description: Detects build agents executing download-and-execute patterns (curl/wget/Invoke-WebRequest piped to shells or writing executables to temp directories), consistent with attacker-issued build steps after agent hijack via CVE-2026-136858.
references:
  - https://www.bleepingcomputer.com/news/security/critical-jetbrains-teamcity-flaw-exploited-to-hijack-build-agents/
  - https://attack.mitre.org/techniques/T1105/
author: Security Arsenal
date: 2026/04/06
tags:
  - attack.command_and_control
  - attack.t1105
  - attack.execution
logsource:
  category: process_creation
  product: windows
detection:
  selection_download:
    CommandLine|contains:
      - 'Invoke-WebRequest'
      - 'Invoke-RestMethod'
      - 'curl.exe http'
      - 'wget http'
      - 'certutil -urlcache'
      - 'bitsadmin /transfer'
  selection_execute:
    CommandLine|contains:
      - '\\Temp\\'
      - '\\AppData\\Local\\Temp\\'
      - 'iex '
      - 'Invoke-Expression'
      - '| sh'
      - '| bash'
  condition: selection_download and selection_execute
falsepositives:
  - Legitimate build scripts that bootstrap dependencies; baseline known build jobs and alert on deviations
level: high
---
title: Webshell or Payload Dropped in TeamCity Web Application Directory
id: 5c9e2f47-1a8d-4b3c-8e6f-2d7a9c0b5e1f
status: experimental
description: Detects creation of script or executable files inside TeamCity server web application and plugin directories, a common persistence mechanism after exploitation of the TeamCity web interface.
references:
  - https://www.bleepingcomputer.com/news/security/critical-jetbrains-teamcity-flaw-exploited-to-hijack-build-agents/
  - https://attack.mitre.org/techniques/T1505/003/
author: Security Arsenal
date: 2026/04/06
tags:
  - attack.persistence
  - attack.t1505.003
logsource:
  category: file_event
  product: windows
detection:
  selection_path:
    TargetFilename|contains:
      - '\\TeamCity\\webapps\\'
      - '\\TeamCity\\plugins\\'
      - '\\TeamCity\\web\\'
  selection_ext:
    TargetFilename|endswith:
      - '.jsp'
      - '.jspx'
      - '.aspx'
      - '.ashx'
      - '.php'
      - '.war'
  condition: selection_path and selection_ext
falsepositives:
  - Legitimate TeamCity plugin installations or upgrades; correlate with change windows
level: high

KQL — Microsoft Sentinel / Defender

This query hunts for the TeamCity server spawning shells, download-and-execute chains on build agents, and new inbound connections to the TeamCity web UI from unusual sources. It assumes process events via Defender for Endpoint (DeviceProcessEvents) and firewall/syslog ingestion for network context (CommonSecurityLog).

KQL — Microsoft Sentinel / Defender
let Lookback = 7d;
let TeamCityHosts = dynamic(["teamcity", "tc-agent", "build-agent"]);
// Stage 1: TeamCity server process spawning shells or LOLBins
let ServerExec = DeviceProcessEvents
| where TimeGenerated > ago(Lookback)
| where DeviceName has_any (TeamCityHosts)
| where InitiatingProcessCommandLine has "teamcity" or InitiatingProcessFolderPath has "teamcity"
| where FileName in~ ("cmd.exe","powershell.exe","pwsh.exe","mshta.exe","wscript.exe","cscript.exe","rundll32.exe","certutil.exe","bitsadmin.exe","curl.exe","wget.exe")
| project TimeGenerated, DeviceName, InitiatingProcessCommandLine, FileName, ProcessCommandLine, AccountName, InitiatingProcessId, ProcessId;
// Stage 2: download-and-execute patterns on any build host
let DownloadExec = DeviceProcessEvents
| where TimeGenerated > ago(Lookback)
| where DeviceName has_any (TeamCityHosts)
| where ProcessCommandLine has_any ("Invoke-WebRequest","Invoke-RestMethod","certutil -urlcache","bitsadmin /transfer","curl.exe http","wget http")
| where ProcessCommandLine has_any ("Temp","iex ","Invoke-Expression",".ps1",".bat",".exe");
// Stage 3: unusual inbound connections to TeamCity web port (default 8111)
let InboundWeb = CommonSecurityLog
| where TimeGenerated > ago(Lookback)
| where DestinationPort in (8111, 80, 443)
| where DeviceName has_any (TeamCityHosts) or DestinationHostName has_any (TeamCityHosts)
| summarize ConnectionCount=count(), FirstSeen=min(TimeGenerated), LastSeen=max(TimeGenerated) by SourceIP, DestinationHostName, DestinationPort
| where ConnectionCount > 50;
ServerExec
| union DownloadExec
| project TimeGenerated, DeviceName, FileName, ProcessCommandLine, InitiatingProcessCommandLine, AccountName
| order by TimeGenerated desc;
// Review InboundWeb separately for source IPs hitting the TeamCity UI from untrusted networks

Run ServerExec and DownloadExec first — these are high-fidelity. Use InboundWeb to identify external sources that may have scanned or attacked your server, then pivot those source IPs into your full telemetry for pre-patch exploitation attempts.

Velociraptor VQL

Deploy this hunt across TeamCity server and agent hosts to identify suspicious child processes of the TeamCity service and recently created script files in TeamCity directories.

VQL — Velociraptor
-- Hunt: TeamCity post-exploitation artifacts (CVE-2026-136858)
-- Part 1: shells/download tools spawned under TeamCity processes
SELECT Pid, Ppid, Name, Exe, CommandLine, Username, CreateTime
FROM pslist()
WHERE CommandLine =~ '(?i)(powershell|cmd\.exe|curl|wget|certutil|bitsadmin|mshta)'
  AND (
    CommandLine =~ '(?i)(Invoke-WebRequest|Invoke-RestMethod|urlcache|/transfer|http://|https://)'
    OR Exe =~ '(?i)\\(Temp|AppData)\\'
  )

-- Part 2: recently dropped scripts/binaries in TeamCity directories
SELECT FullPath, Size, Mtime, Ctime
FROM glob(globs=[
  'C:/TeamCity/webapps/**/*.jsp',
  'C:/TeamCity/webapps/**/*.war',
  'C:/TeamCity/plugins/**/*.jar',
  'C:/Program Files/TeamCity/**/*.jsp'
])
WHERE Mtime > now() - 604800
ORDER BY Mtime DESC

Combine with netstat() scoped to the TeamCity process PID to identify unexpected outbound connections from the server — build servers should have a short, well-known egress list (VCS, artifact repos, agent ports). Anything else deserves scrutiny.

Remediation & Verification Script

Use this PowerShell script on TeamCity server hosts (Windows) to capture the installed version, enumerate recently modified files in TeamCity web/plugin directories (potential webshells), and export recent process ancestry evidence for IR review. Run as Administrator.

PowerShell
# CVE-2026-136858 - TeamCity compromise verification script
# Run as Administrator on the TeamCity SERVER host

$ReportDir = "C:\IR\TeamCity_CVE-2026-136858_$(Get-Date -Format yyyyMMdd_HHmmss)"
New-Item -ItemType Directory -Path $ReportDir -Force | Out-Null

# 1. Capture installed TeamCity version (check against JetBrains fixed-version advisory)
$tcDir = "C:\TeamCity"
if (Test-Path "$tcDir\conf\teamcity-startup.properties") {
    Get-Content "$tcDir\conf\teamcity-startup.properties" | Out-File "$ReportDir\teamcity-startup.txt"
}
Get-ChildItem "$tcDir\webapps\ROOT\WEB-INF\lib" -Filter "*.jar" -ErrorAction SilentlyContinue |
    Select-Object Name, LastWriteTime | Out-File "$ReportDir\webapp-jars.txt"
Write-Host "[+] Compare build number in TeamCity UI (Administration > Diagnostics) against JetBrains fixed versions." -ForegroundColor Yellow

# 2. Hunt for recently modified script/web files (potential webshells)
$lookback = (Get-Date).AddDays(-14)
Get-ChildItem -Path "$tcDir\webapps","$tcDir\plugins" -Recurse -Include *.jsp,*.jspx,*.war,*.jar,*.aspx -ErrorAction SilentlyContinue |
    Where-Object { $_.LastWriteTime -gt $lookback } |
    Select-Object FullName, LastWriteTime, Length |
    Export-Csv "$ReportDir\recent-web-files.csv" -NoTypeInformation

# 3. Export running processes with parent relationships for shell-under-server review
Get-CimInstance Win32_Process |
    Select-Object ProcessId, ParentProcessId, Name, CommandLine, CreationDate |
    Export-Csv "$ReportDir\process-tree.csv" -NoTypeInformation

# 4. Check TeamCity build agent service status and recent outbound connections
Get-NetTCPConnection -State Established -ErrorAction SilentlyContinue |
    Where-Object { $_.RemotePort -notin 80,443,8111,9090 } |
    Select-Object LocalAddress,LocalPort,RemoteAddress,RemotePort,OwningProcess |
    Export-Csv "$ReportDir\netconn-unusual.csv" -NoTypeInformation

Write-Host "[+] Evidence collected in $ReportDir. Review recent-web-files.csv and process-tree.csv for anomalies BEFORE patching if exploitation is suspected." -ForegroundColor Green

Important: if you find evidence of compromise, preserve the box (or at minimum the evidence above plus %TeamCity_HOME%\logs\teamcity-server.log and teamcity-activities.log) before upgrading — the patch will not tell you whether you were already breached.

Remediation

  1. Patch immediately. Upgrade TeamCity On-Premises to the fixed release specified in the official JetBrains security advisory. Confirm the exact fixed build number against the vendor advisory — do not rely on secondary reporting for version specifics.
  2. Assume pre-patch exposure. Because CVE-2026-136858 is confirmed exploited in the wild, patching alone is insufficient. Hunt for compromise dating back at least 14–30 days using the detections above.
  3. Rotate everything the build touches. If compromise is suspected or confirmed, treat all secrets reachable from the server and agents as burned: VCS tokens, cloud IAM keys, artifact registry credentials, code-signing certificates, and any environment-variable secrets in build configurations.
  4. Audit build agents and configurations. Review TeamCity's authorized agents list for unknown or rogue agents. Diff build configurations against known-good versions (TeamCity keeps project settings as versioned XML/Kotlin DSL in <TeamCity Data Directory>/config/projects — look for unauthorized new build steps, especially anything fetching remote scripts).
  5. Remove internet exposure. The TeamCity UI (default port 8111, or whatever you've mapped) should not be reachable from the public internet. Place it behind a VPN or authenticated reverse proxy with SSO/MFA. Restrict inbound access to the agent communication port to known agent subnets.
  6. Segment build infrastructure. Agents should have least-privilege egress: only the VCS, artifact repositories, and deployment targets they genuinely need. Deny agent-to-agent and server-to-internal-flat-network paths by default.
  7. Verify artifact integrity. If the server was exposed during the exploitation window, validate the integrity of artifacts built and published during that period before they ship to production or customers — this is the supply-chain blast radius.
  8. Monitor going forward. Deploy the Sigma and KQL detections above permanently, and alert on new agent registrations and build configuration changes as first-class security events.

Bottom Line

CVE-2026-136858 is the kind of vulnerability that turns a single unpatched server into an enterprise-wide supply-chain incident. The combination of confirmed active exploitation and the inherent privilege of CI/CD infrastructure means the correct response is: patch now, hunt backwards, rotate credentials, and verify your build pipeline's integrity end to end. If you lack the internal capacity to run the compromise assessment, engage an IR partner before you close the ticket on the patch.

Related Resources

Security Arsenal Red Team Services AlertMonitor Platform Book a SOC Assessment pen-testing Intel Hub

Is your security operations ready?

Get a free SOC assessment or see how AlertMonitor cuts through alert noise with automated triage.