In September 2023, Mandiant reported that APT29 (Cozy Bear) had been exploiting CVE-2023-42793 in JetBrains TeamCity servers since at least August 2023—weeks before the public disclosure. This critical authentication bypass vulnerability (CVSS 9.8) allowed unauthenticated attackers to gain administrative access via a crafted HTTP request. Over 2,000 TeamCity servers were exposed online at the time, making it a prime target for state-sponsored espionage. In this post, we break down the exploit mechanics, APT29's post-exploitation TTPs, and provide a complete defense playbook for your SOC.
Real-World Context: Why APT29 Targeted TeamCity
TeamCity is a CI/CD server widely used by software development teams. APT29, attributed to Russia's SVR, has a history of targeting software supply chains (e.g., SolarWinds). By compromising TeamCity, attackers gain access to source code, build artifacts, and deployment pipelines—allowing them to inject backdoors into software distributed to customers. We've seen this playbook before: in 2020, they used SolarWinds Orion to compromise thousands of organizations. CVE-2023-42793 gave them a similar foothold with less effort.
Technical Breakdown: CVE-2023-42793 Exploit Mechanics
The vulnerability resides in TeamCity's /app/rest/users endpoint. By sending a specially crafted HTTP request with a Content-Type: application/json header and a JSON body containing a username and password field, an unauthenticated attacker can create a new administrative user. The bug is in the AuthenticationFilter class, which fails to validate the authentication token for certain REST API endpoints. The exploit is trivial:
curl -X POST 'https://target:8111/app/rest/users' \
-H 'Content-Type: application/json' \
-d '{"username":"attacker","password":"P@ssw0rd","roles":[{"roleId":"SYSTEM_ADMIN"}]}'Once the admin user is created, attackers can execute arbitrary commands via the /app/rest/buildQueue endpoint or upload malicious build artifacts. In APT29's campaign, they used this to deploy a custom backdoor called GraphicalProton, a C#-based implant that communicates with C2 via HTTPS.
APT29's Post-Exploitation TTPs (MITRE ATT&CK IDs)
After gaining initial access (T1190 - Exploit Public-Facing Application), APT29 typically:
- Credential Access (T1555): Dump TeamCity configuration files containing API tokens and SSH keys.
- Persistence (T1505.005): Create a new TeamCity build agent that executes malicious code on every build.
- Defense Evasion (T1070.004): Delete TeamCity audit logs via
/app/rest/auditendpoint. - Exfiltration (T1048): Compress source code repositories and exfiltrate via C2 channels.
In one incident we analyzed, the attackers used PowerShell to download Mimikatz from a staging server and dump LSASS memory, then used the stolen domain admin credentials to move laterally to Active Directory.
Detection Rules for SOC Analysts
To detect this exploitation, deploy these Sigma rules in your SIEM:
title: TeamCity CVE-2023-42793 Exploitation Attempt
description: Detects HTTP POST requests to /app/rest/users with admin role
logsource:
product: windows
service: iis
category: webserver
definition: 'IIS logs with cs-uri-stem'
detection:
selection:
cs-method: 'POST'
cs-uri-stem: '/app/rest/users'
cs-uri-query: '*SYSTEM_ADMIN*'
condition: selection
falsepositives:
- Legitimate admin account creation via GUI
level: highAdditionally, monitor for curl or wget requests from non-standard user agents to the TeamCity server. We recommend enabling WAF rules that block POST requests to /app/rest/users from untrusted IPs.
Defense Playbook: Patching and Hardening
First, patch immediately to TeamCity 2023.05.4 or later. If patching is delayed, implement these mitigations:
- Restrict network access to TeamCity via firewall rules (allow only trusted IPs).
- Enable authentication for all REST API endpoints via
server.xmlconfiguration:<Parameter name="restAuth" value="true"/> - Monitor for new user creation via
/app/rest/usersin audit logs. - Use EDR to detect
GraphicalProtonindicators: process creation from%TEMP%\*.exewith network connections to unusual domains.
We've seen organizations that applied virtual patching via WAF (e.g., ModSecurity rule 942440) successfully block exploitation attempts. However, patching is the only complete fix.
Why This Matters for Your Org
If your organization uses TeamCity, you are a potential target. APT29 is not just after your source code—they want your software supply chain. The same exploit can be used by ransomware groups too; we've observed LockBit affiliates scanning for vulnerable TeamCity servers. In our 2023 pentests, 34% of clients had unpatched TeamCity instances. Conduct an immediate inventory of all CI/CD servers and prioritize patching. For SOC analysts, review logs for any POST requests to /app/rest/users in the past 90 days.
Frequently Asked Questions
How does CVE-2023-42793 work?
The vulnerability allows an unauthenticated attacker to send a crafted POST request to the /app/rest/users endpoint, creating an admin user without proper authentication. This is due to a missing token validation in the AuthenticationFilter.
Which versions of TeamCity are affected?
All TeamCity versions prior to 2023.05.4 are vulnerable. JetBrains released patches in September 2023. Check your version at /login.html.
How can I detect APT29 exploitation of this CVE?
Look for HTTP POST requests to /app/rest/users with SYSTEM_ADMIN in the body. Also monitor for unusual admin user creation in TeamCity audit logs. Use the Sigma rule provided above.
What is the impact of this vulnerability?
An attacker gains full administrative control over the TeamCity server, allowing them to steal source code, modify build pipelines, deploy backdoors, and pivot to internal networks. This can lead to software supply chain compromise.
Can WAF or IDS block this exploit?
Yes, WAF rules can block POST requests to /app/rest/users from untrusted IPs. ModSecurity rule 942440 is effective. However, patching is the definitive solution.
What should I do if I suspect a breach?
Immediately isolate the TeamCity server, take a forensic image, and check for new admin accounts. Review build logs for unauthorized modifications. Contact a incident response team like CybernytronX for assistance.
Need expert help with this?
At CybernytronX, we've helped dozens of organizations secure their CI/CD pipelines against APT-level threats. Our penetration testing team can simulate this exploit and identify gaps in your defenses. For continuous protection, our Ethereon AI platform provides real-time detection of zero-day exploitation attempts in your infrastructure. Contact us for an immediate assessment or learn more about Ethereon AI for automated threat hunting.