{
    "file_item": {
        "filepath": "security-advisories",
        "filename": "CERT-EU-SA2024-023.pdf"
    },
    "title": "Vulnerabilities in JetBrains TeamCity",
    "serial_number": "2024-023",
    "publish_date": "07-03-2024 13:10:35",
    "description": "On March 4, JetBrains released a fix for two vulnerabilities affecting JetBrains TeamCity CI/CD server. Both vulnerabilities are authentication bypass vulnerabilities. If exploited, the most severe vulnerability allows for a complete compromise of a vulnerable TeamCity server by a remote unauthenticated attacker, including unauthenticated RCE.<br>\nIt is advised upgrading the software as soon as possible.<br>\n",
    "url_title": "2024-023",
    "content_markdown": "---\ntitle: 'Vulnerabilities in JetBrains TeamCity'\nnumber: '2024-023'\nversion: '1.0'\noriginal_date: 'March 4, 2024'\ndate: 'March 6, 2024'\n---\n\n_History:_\n\n* _06/03/2024 --- v1.0 -- Initial publication_\n\n# Summary\n\nOn March 4, JetBrains released a fix for two vulnerabilities affecting JetBrains TeamCity CI/CD server. Both vulnerabilities are authentication bypass vulnerabilities. If exploited, the most severe vulnerability allows for a complete compromise of a vulnerable TeamCity server by a remote unauthenticated attacker, including unauthenticated RCE [1,2].\n\nIt is advised upgrading the software as soon as possible.\n\n# Technical Details\n\nThe vulnerability **CVE-2024-27198**, with a CVSS score of 9.8, is an authentication bypass vulnerability in the web component of TeamCity that arises from an alternative path issue. TeamCity exposes a web server over HTTP port 8111 by default (and can optionally be configured to run over HTTPS). An attacker can craft a URL such that all authentication checks are avoided, allowing endpoints that are intended to be authenticated to be accessed directly by an unauthenticated attacker. A remote unauthenticated attacker can leverage this to take complete control of a vulnerable TeamCity server.\n\nThe vulnerability **CVE-2024-27199**, with a CVSS score of 7.3, is an authentication bypass vulnerability in the web component of TeamCity that arises from a path traversal issue. This authentication bypass allows for a limited number of authenticated endpoints to be reached without authentication. An unauthenticated attacker can leverage this vulnerability to both modify a limited number of system settings on the server, as well as disclose a limited amount of sensitive information from the server.\n\n# Affected Products\n\nAll versions of TeamCity On-Premises with a version prior 2023.11.4 are affected by these vulnerabilities. For customers with TeamCity Cloud, JetBrains patched the servers and verified that no exploitation of these vulnerabilities were initiated.\n\n# Recommendations\n\nCERT-EU strongly recommends updating software installations to the latest versions by following the instructions given by the vendor [1,2].\n\n## Detection\n\nTo detect exploitation activities, it is recommended reviewing the web access logs and the software logs [1], by default located in `C:\\TeamCity\\logs\\` on Windows and `/opt/TeamCity/logs/` on Linux.\n\n- An attacker could leverage the vulnerabilities to create a new access token for persistence. In that case, a log entry in the `teamcity-javaLogging` log files would indicate such activity. By searching for strings matching the following regular expression in those log files, one could find succesful exploitation attempts: `;\\S*\\.jsp\\?\\S*jsp=`, and `\\/\\S*\\?\\S*jsp=\\S*;\\.jsp`. \n\n```\n27-Feb-2024 07:15:45.191 WARNING [TC: 07:15:45 Processing REST request; http-nio-80-exec-5] com.sun.jersey.spi.container.servlet.WebComponent.filterFormParameters A servlet request, to the URI http://xxx.xxx.xxx.xxx/app/rest/users/id:1/tokens/wo4qEmUZ;O.jsp?WkBR=OcPj9HbdUcKxH3O&pKLaohp7=d0jMHTumGred&jsp=/app/rest/users/id%3a1/tokens/wo4qEmUZ%3bO.jsp&ja7U2Bd=nZLi6Ni, contains form parameters in the request body but the request body has been consumed by the servlet or a servlet filter accessing the request parameters. Only resource methods using @FormParam will work as expected. Resource methods consuming the request body by other means will not work as expected.\n```\n\n\n- An attacker could leverage the vulnerabilities to upload malicious plugin. In that case, a log entry in the `teamcity-server.log` and the `teamcity-activities.log` log files would indicate such activity. By searching for lines indicating that a plugin was uploaded and subsequently deleted in quick succession, and authenticated with the same user account as that of the initial access token creation, one could find succesful exploitation attempts.\n\n```\n[2024-02-26 07:11:13,304]   INFO - s.buildServer.ACTIVITIES.AUDIT - plugin_uploaded: Plugin \"WYyVNA6r\" was updated by \"user with id=1\" with comment \"Plugin was uploaded to C:\\ProgramData\\JetBrains\\TeamCity\\plugins\\WYyVNA6r.zip\"\n[2024-02-26 07:11:24,506]   INFO - s.buildServer.ACTIVITIES.AUDIT - plugin_disable: Plugin \"WYyVNA6r\" was disabled by \"user with id=1\"\n[2024-02-26 07:11:25,683]   INFO - s.buildServer.ACTIVITIES.AUDIT - plugin_deleted: Plugin \"WYyVNA6r\" was deleted by \"user with id=1\" with comment \"Plugin was deleted from C:\\ProgramData\\JetBrains\\TeamCity\\plugins\\WYyVNA6r.zip\"\n```\n\n- An attacker could leverage the vulnerabilities to create an administrator account. In that case, a log entry in the in the `teamcity-server.log` and the `teamcity-activities.log` log files would indicate such activity. It is also possible to review the TeamCity administration console\u2019s Audit page for newly created accounts.\n\n```\n[2024-02-26 07:45:06,962]   INFO - tbrains.buildServer.ACTIVITIES - New user created: user with id=23\n[2024-02-26 07:45:06,962]   INFO - s.buildServer.ACTIVITIES.AUDIT - user_create: User \"user with id=23\" was created by \"user with id=23\"\n```\n\n- To find exploitation of the second exploitation, one can search for double dot path segments (i.e., `../`), in the web access logs, after the the follwing vulnerable paths: `/res/`, `/update/`, and `/.well-known/acme-challenge/`.\n\n# References\n\n[1] <https://www.rapid7.com/blog/post/2024/03/04/etr-cve-2024-27198-and-cve-2024-27199-jetbrains-teamcity-multiple-authentication-bypass-vulnerabilities-fixed/>\n\n[2] <https://blog.jetbrains.com/teamcity/2024/03/additional-critical-security-issues-affecting-teamcity-on-premises-cve-2024-27198-and-cve-2024-27199-update-to-2023-11-4-now/>",
    "content_html": "<p><em>History:</em></p><ul><li><em>06/03/2024 --- v1.0 -- Initial publication</em></li></ul><h2 id=\"summary\">Summary</h2><p>On March 4, JetBrains released a fix for two vulnerabilities affecting JetBrains TeamCity CI/CD server. Both vulnerabilities are authentication bypass vulnerabilities. If exploited, the most severe vulnerability allows for a complete compromise of a vulnerable TeamCity server by a remote unauthenticated attacker, including unauthenticated RCE [1,2].</p><p>It is advised upgrading the software as soon as possible.</p><h2 id=\"technical-details\">Technical Details</h2><p>The vulnerability <strong>CVE-2024-27198</strong>, with a CVSS score of 9.8, is an authentication bypass vulnerability in the web component of TeamCity that arises from an alternative path issue. TeamCity exposes a web server over HTTP port 8111 by default (and can optionally be configured to run over HTTPS). An attacker can craft a URL such that all authentication checks are avoided, allowing endpoints that are intended to be authenticated to be accessed directly by an unauthenticated attacker. A remote unauthenticated attacker can leverage this to take complete control of a vulnerable TeamCity server.</p><p>The vulnerability <strong>CVE-2024-27199</strong>, with a CVSS score of 7.3, is an authentication bypass vulnerability in the web component of TeamCity that arises from a path traversal issue. This authentication bypass allows for a limited number of authenticated endpoints to be reached without authentication. An unauthenticated attacker can leverage this vulnerability to both modify a limited number of system settings on the server, as well as disclose a limited amount of sensitive information from the server.</p><h2 id=\"affected-products\">Affected Products</h2><p>All versions of TeamCity On-Premises with a version prior 2023.11.4 are affected by these vulnerabilities. For customers with TeamCity Cloud, JetBrains patched the servers and verified that no exploitation of these vulnerabilities were initiated.</p><h2 id=\"recommendations\">Recommendations</h2><p>CERT-EU strongly recommends updating software installations to the latest versions by following the instructions given by the vendor [1,2].</p><h3 id=\"detection\">Detection</h3><p>To detect exploitation activities, it is recommended reviewing the web access logs and the software logs [1], by default located in <code>C:\\TeamCity\\logs\\</code> on Windows and <code>/opt/TeamCity/logs/</code> on Linux.</p><ul><li>An attacker could leverage the vulnerabilities to create a new access token for persistence. In that case, a log entry in the <code>teamcity-javaLogging</code> log files would indicate such activity. By searching for strings matching the following regular expression in those log files, one could find succesful exploitation attempts: <code>;\\S*\\.jsp\\?\\S*jsp=</code>, and <code>\\/\\S*\\?\\S*jsp=\\S*;\\.jsp</code>. </li></ul><pre><code>27-Feb-2024 07:15:45.191 WARNING [TC: 07:15:45 Processing REST request; http-nio-80-exec-5] com.sun.jersey.spi.container.servlet.WebComponent.filterFormParameters A servlet request, to the URI http://xxx.xxx.xxx.xxx/app/rest/users/id:1/tokens/wo4qEmUZ;O.jsp?WkBR=OcPj9HbdUcKxH3O&amp;pKLaohp7=d0jMHTumGred&amp;jsp=/app/rest/users/id%3a1/tokens/wo4qEmUZ%3bO.jsp&amp;ja7U2Bd=nZLi6Ni, contains form parameters in the request body but the request body has been consumed by the servlet or a servlet filter accessing the request parameters. Only resource methods using @FormParam will work as expected. Resource methods consuming the request body by other means will not work as expected.\n</code></pre><ul><li>An attacker could leverage the vulnerabilities to upload malicious plugin. In that case, a log entry in the <code>teamcity-server.log</code> and the <code>teamcity-activities.log</code> log files would indicate such activity. By searching for lines indicating that a plugin was uploaded and subsequently deleted in quick succession, and authenticated with the same user account as that of the initial access token creation, one could find succesful exploitation attempts.</li></ul><pre><code>[2024-02-26 07:11:13,304]   INFO - s.buildServer.ACTIVITIES.AUDIT - plugin_uploaded: Plugin \"WYyVNA6r\" was updated by \"user with id=1\" with comment \"Plugin was uploaded to C:\\ProgramData\\JetBrains\\TeamCity\\plugins\\WYyVNA6r.zip\"\n[2024-02-26 07:11:24,506]   INFO - s.buildServer.ACTIVITIES.AUDIT - plugin_disable: Plugin \"WYyVNA6r\" was disabled by \"user with id=1\"\n[2024-02-26 07:11:25,683]   INFO - s.buildServer.ACTIVITIES.AUDIT - plugin_deleted: Plugin \"WYyVNA6r\" was deleted by \"user with id=1\" with comment \"Plugin was deleted from C:\\ProgramData\\JetBrains\\TeamCity\\plugins\\WYyVNA6r.zip\"\n</code></pre><ul><li>An attacker could leverage the vulnerabilities to create an administrator account. In that case, a log entry in the in the <code>teamcity-server.log</code> and the <code>teamcity-activities.log</code> log files would indicate such activity. It is also possible to review the TeamCity administration console\u2019s Audit page for newly created accounts.</li></ul><pre><code>[2024-02-26 07:45:06,962]   INFO - tbrains.buildServer.ACTIVITIES - New user created: user with id=23\n[2024-02-26 07:45:06,962]   INFO - s.buildServer.ACTIVITIES.AUDIT - user_create: User \"user with id=23\" was created by \"user with id=23\"\n</code></pre><ul><li>To find exploitation of the second exploitation, one can search for double dot path segments (i.e., <code>../</code>), in the web access logs, after the the follwing vulnerable paths: <code>/res/</code>, <code>/update/</code>, and <code>/.well-known/acme-challenge/</code>.</li></ul><h2 id=\"references\">References</h2><p>[1] <a rel=\"noopener\" target=\"_blank\" href=\"https://www.rapid7.com/blog/post/2024/03/04/etr-cve-2024-27198-and-cve-2024-27199-jetbrains-teamcity-multiple-authentication-bypass-vulnerabilities-fixed/\">https://www.rapid7.com/blog/post/2024/03/04/etr-cve-2024-27198-and-cve-2024-27199-jetbrains-teamcity-multiple-authentication-bypass-vulnerabilities-fixed/</a></p><p>[2] <a rel=\"noopener\" target=\"_blank\" href=\"https://blog.jetbrains.com/teamcity/2024/03/additional-critical-security-issues-affecting-teamcity-on-premises-cve-2024-27198-and-cve-2024-27199-update-to-2023-11-4-now/\">https://blog.jetbrains.com/teamcity/2024/03/additional-critical-security-issues-affecting-teamcity-on-premises-cve-2024-27198-and-cve-2024-27199-update-to-2023-11-4-now/</a></p>",
    "licence": {
        "title": "Creative Commons Attribution 4.0 International (CC-BY 4.0)",
        "link": "https://creativecommons.org/licenses/by/4.0/",
        "restrictions": "https://cert.europa.eu/legal-notice",
        "author": "The Cybersecurity Service for the Union institutions, bodies, offices and agencies"
    }
}