<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" ><channel><title>Kévin Subileau &#187; wordpress</title> <atom:link href="https://www.kevinsubileau.fr/tag/wordpress/feed" rel="self" type="application/rss+xml" /><link>https://www.kevinsubileau.fr</link> <description>Espace personnel</description> <lastBuildDate>Sun, 02 Feb 2020 15:18:58 +0000</lastBuildDate> <language>fr-FR</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>Local file disclosure vulnerability in Crayon Syntax Highlighter</title><link>https://www.kevinsubileau.fr/informatique/hacking-securite/crayon-syntax-highlighter-local-file-disclosure-vulnerability.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=rss</link> <comments>https://www.kevinsubileau.fr/informatique/hacking-securite/crayon-syntax-highlighter-local-file-disclosure-vulnerability.html#comments</comments> <pubDate>Tue, 14 Apr 2015 19:00:52 +0000</pubDate> <dc:creator>Kévin Subileau</dc:creator> <category><![CDATA[Hacking et sécurité]]></category> <category><![CDATA[vulnérabilité]]></category> <category><![CDATA[wordpress]]></category><guid isPermaLink="false">http://www.kevinsubileau.fr/?p=1544</guid> <description><![CDATA[I discovered a critical local file disclosure vulnerability in Crayon Syntax Highlighter, a popular Wordpress plugin, that allows remote attackers to read arbitrary files on server's file system, even outside the web root. <a href="https://www.kevinsubileau.fr/informatique/hacking-securite/crayon-syntax-highlighter-local-file-disclosure-vulnerability.html">Lire la Suite <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>I discovered a <strong>local file disclosure vulnerability</strong> affecting <strong>all versions</strong> before 2.7.0 of <strong>Crayon Syntax Highlighter</strong>, a popular syntax highlighter built in PHP and jQuery. According to <a href="https://wordpress.org/plugins/crayon-syntax-highlighter/">wordpress.org</a>, the vulnerable versions of this WordPress plugin are installed on <strong>more than 40,000 websites</strong>.</p><p>This critical vulnerability allows remote attackers to <strong>read arbitrary files</strong> on server's file system, even outside the web root. This includes PHP source code, configuration files and system files as <em>/etc/passwd</em> or <em>wp-config.php</em> for example. Furthermore, as you will see below, <strong>authentication is generally not required</strong> to exploit this vulnerability. Of course, the web server must have read access on the target files.</p><p>I tested a few versions between the old 1.10 to the latest 2.6.10, with a freshly installed WordPress 4.1 and the default configuration, and all tested versions were vulnerable. This means that<strong> the vulnerability exists since at least 3 years.</strong></p><h3>Technical analysis</h3><p>Crayon Syntax Highlighter can highlight from a URL, inline code, or a local file. Here are some examples of normal markup that could be put inside post content in order to highlight code from these three source types:</p><pre class="brush: html; gutter: false; first-line: 1; highlight: []; html-script: false">&lt;!-- Inline code --&gt;
&lt;pre class=&quot;lang:php&quot;&gt;
    &lt;?php //code to highlight here ?&gt;
&lt;/pre&gt;

&lt;!-- URL --&gt;
&lt;pre class=&quot;lang:java&quot; data-url=&quot;http://example.com/class.java&quot;&gt;&lt;/pre&gt;

&lt;!-- Local file - the interesting case --&gt;
&lt;pre class=&quot;lang:java&quot; data-url=&quot;/java_sample/class.java&quot;&gt;&lt;/pre&gt;</pre><p>In the local file case, by default, the path given in the <em>data-url</em> attribute is relative to the WordPress root directory. In the plugin settings page, the user can also specify a sub-folder from which this relative path should start. But, as you can see below in this piece of code <a href="https://github.com/aramk/crayon-syntax-highlighter/blob/6ae074e367aa1b80983e64fd41e3300d6491d706/crayon_highlighter.class.php#L71">extracted from crayon</a>, the problem is that <strong>there is absolutely no control</strong> over the file type or the path given (stored in the variable <em>$url</em>).</p><pre class="brush: php; gutter: true; first-line: 71; highlight: [79,84]; html-script: false">// Try to replace the site URL with a path to force local loading
if (strpos($url, $site_http) !== FALSE || strpos($url, $site_path) !== FALSE ) {
    $url = str_replace($site_http, $site_path, $url);
    // Attempt to load locally
    $local = TRUE;
    $local_url = $url;
} else if (empty($scheme)) {
    // No url scheme is given - path may be given as relative
    $local_url = preg_replace(&#039;#^((\/|\\\\)*)?#&#039;, $site_path . $this-&gt;setting_val(CrayonSettings::LOCAL_PATH), $url);
    $local = TRUE;
}
// Try to find the file locally
if ($local == TRUE) {
    if ( ($contents = CrayonUtil::file($local_url)) !== FALSE ) {
        $this-&gt;code($contents);
    } else {
        // [...]
    }
}</pre><p>The given path is simply prepended with the base path at line 79, and then the file's content is loaded at line 84 (the method <em><a href="https://github.com/aramk/crayon-syntax-highlighter/blob/6ae074e367aa1b80983e64fd41e3300d6491d706/util/crayon_util.class.php#L80">CrayonUtil::file</a></em> just calls the function <a href="http://php.net/manual/function.file-get-contents.php"><em>file_get_contents</em></a>). So, for example, assuming that the administrator hasn't modified the standard WordPress file structure and with the default settings, <strong>it's possible to get the database credentials</strong> and WordPress secret keys simply by putting the code below inside a post or page content:</p><pre class="brush: html; gutter: false; html-script: false">&lt;pre data-url=&quot;/wp-config.php&quot;&gt;&lt;/pre&gt;</pre><p>You can also use a <strong>directory traversal attack</strong> to reach the root directory and get the content of <em>/etc/passwd</em> for example:</p><pre class="brush: html; gutter: false; html-script: false">&lt;pre data-url=&quot;/../../../../../../../../../../../../../../../../../etc/passwd&quot;&gt;&lt;/pre&gt;</pre><p>Of course it's also possible to get the content of theme's source files, <em>.htaccess</em> and <em>.htpasswd</em> files, log files, and other files that could contain highly sensitive information.</p><p>But so far, I told you that these exploits must be put inside a post or page, so normally this requires authentication. But the real issue is that <strong>unauthenticated visitors</strong> can also exploit the vulnerability simply by <strong>posting a comment</strong> containing the same malicious markup (except when an alternative comment system is used, as Disqus). It's because Crayon can also highlight inside comments, and this feature is enabled by default. <strong>This is why I say that authentication is generally not required</strong> to exploit this vulnerability.</p><p>Even if comments are <strong>moderated</strong> before publication, <strong>the issue remains the same</strong> because WordPress display the comment to its author before moderation with a message like <em>"Your comment is awaiting moderation."</em>. So the file content is revealed <strong>before the administrator can delete</strong> the malicious comment.</p><p>You can see bellow a <strong>screen capture</strong> showing the exploit in action, both inside the post content and a comment before moderation:</p><div id="attachment_1719" class="wp-caption aligncenter" style="width: 310px"><a href="http://kevinsubileau.fr/wp-content/uploads/2015/04/crayon-syntax-highlighter-file-disclosure.png"><img class="size-medium wp-image-1719" alt="Disclosure of /etc/passwd and wp-config.php (click to enlarge)" src="http://www.kevinsubileau.fr/wp-content/uploads/2015/04/crayon-syntax-highlighter-file-disclosure-cropped-300x166.png" width="300" height="166" /></a><p class="wp-caption-text">Disclosure of /etc/passwd and wp-config.php (click to enlarge)</p></div><h3>Vendor response</h3><p>I sent the initial report of the vulnerability to the plugin author on January 4. He replied quickly and confirmed the issue.</p><p>On April 5, he informed me that he had patched the issue. Finally, on April 13, he released the version 2.7.0, which includes this patch.</p><p>I thank him for his cooperation and his excellent work.</p><h3>Remediation</h3><p>The preferred solution is to <strong>update quickly to the latest version</strong> (&gt;= 2.7.0), which fix the vulnerability by removing support of local file highlighting.</p><p>In the event where you really cannot install the update, an alternative way to limit risks is to<strong> disable Crayon in comments</strong>, in order to prevent attacks from unauthenticated visitor. But it will still be possible to exploit the vulnerability through a post or page content...</p><div id="attachment_1721" class="wp-caption aligncenter" style="width: 610px"><img class=" wp-image-1721 " alt="Disable Crayons in comments to prevent unauthenticated attacks" src="http://www.kevinsubileau.fr/wp-content/uploads/2015/04/crayon-syntax-highlighter-disable-comment.png" width="600" height="198" /><p class="wp-caption-text">Disable Crayons in comments to prevent unauthenticated attacks</p></div><h3>CVSS Score</h3><p>I evaluate the CVSS Score at <strong>7.8</strong> (AV:N/AC:L/Au:N/C:C/I:N/A:N).</p><h3>References</h3><p>Secunia : <a title="Security Advisory SA63998 - WordPress Crayon Syntax Highlighter Plugin Arbitrary File Disclosure Vulnerability - Secunia" href="http://secunia.com/advisories/63998/">#63998</a>.<br /> WPVDB : <a href="https://wpvulndb.com/vulnerabilities/7904">#7904</a>.<br /> OSVDB : <a href="http://osvdb.org/show/osvdb/121278">#121278</a>.</p><h3>About me</h3><p>For non-French speakers that can't read <a title="Présentation" href="http://www.kevinsubileau.fr/espace-professionnel">others pages about me</a> on this blog (sorry, it's currently primarly intended to French speakers), I will introduce me briefly in English here so that you can know who am I. I'm <strong>Kevin Subileau</strong>, 23 years old. I'm not a professional security researcher (yet), but I'm a <strong>passionate in computing science</strong>, junior <strong>system &amp; network engineer</strong> by day, and <strong>web developer</strong> by night, also interested by <strong>computing security</strong>. You can contact me by leaving a comment below (in English or French), on <a href="https://twitter.com/ksubileau">Twitter</a> or by filling <a href="/contact">this form</a> (fields are, top to bottom, name / email / subject / comment).</p> ]]></content:encoded> <wfw:commentRss>https://www.kevinsubileau.fr/informatique/hacking-securite/crayon-syntax-highlighter-local-file-disclosure-vulnerability.html/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Vulnérabilité mfunc dans W3 Total Cache et WP Super Cache</title><link>https://www.kevinsubileau.fr/informatique/hacking-securite/attaque-vulnerabilite-mfunc-wordpress-w3tc.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=rss</link> <comments>https://www.kevinsubileau.fr/informatique/hacking-securite/attaque-vulnerabilite-mfunc-wordpress-w3tc.html#comments</comments> <pubDate>Sat, 22 Mar 2014 19:00:42 +0000</pubDate> <dc:creator>Kévin Subileau</dc:creator> <category><![CDATA[Hacking et sécurité]]></category> <category><![CDATA[vulnérabilité]]></category> <category><![CDATA[wordpress]]></category><guid isPermaLink="false">http://www.kevinsubileau.fr/?p=951</guid> <description><![CDATA[Le week-end dernier, j'ai reçu trois commentaires tentant d'exploiter une faille de sécurité connue affectant les deux plugins de cache les plus utilisés pour Wordpress. <a href="https://www.kevinsubileau.fr/informatique/hacking-securite/attaque-vulnerabilite-mfunc-wordpress-w3tc.html">Lire la Suite <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>Le week-end dernier, j'ai reçu simultanément trois commentaires plutôt originaux à modérer sur ce site. En effet, ces derniers tentaient d'<strong>exploiter une vulnérabilité connue</strong> sur les deux plugins de cache les plus populaires, <strong>W3 Total Cache et WP Super Cache</strong>. Cette faille de sécurité a été reportée il y a un an environ par <a href="https://wordpress.org/support/topic/pwn3d">kisscsaby sur le forum WordPress</a>, et a fort heureusement <strong>été totalement corrigée</strong> depuis. J'ai tout de même souhaité vous en parler car je l'ai trouvée intéressante à étudier et aussi parce qu'elle reste active sur les nombreux sites non mis à jour...</p><div id="attachment_953" class="wp-caption aligncenter" style="width: 497px"><img class="size-full wp-image-953" alt="wp_mfunc_vulnerability" src="http://www.kevinsubileau.fr/wp-content/uploads/2014/03/wp_mfunc_vulnerability.png" width="487" height="173" /><p class="wp-caption-text">Voilà un commentaire plus que suspect...</p></div><p>Cette attaque s'appuie sur plusieurs fonctions (<em>mfunc</em>, <em>mclude</em>, et <em>dynamic-cached-content</em>) présentes sur les versions vulnérables (W3TC ≤ 0.9.2.8 ou WPSC ≤ 1.2), et permet d'<strong>exécuter un code PHP arbitraire</strong> sur le serveur. Autant dire que l'on peut tout faire ! Pour comprendre, il faut savoir qu'un site WordPress avec une version vulnérable d'un de ces plugins va exécuter le code PHP situé <strong>à l'intérieur de la balise ouvrante <em>mfunc</em>.</strong> Par exemple, le code <code>&lt;!--mfunc echo PHP_VERSION; -–&gt;&lt;!–-/mfunc-–&gt;</code> va afficher la version de PHP utilisé.</p><p>Cette fonctionnalité permet initialement au développeur du site d'indiquer les éléments qui ne doivent pas être mis en cache par le plugin, comme par exemple la date ou le temps de génération de la page. Le code compris dans cette balise est alors exécuté à chaque fois, tandis que le reste de la page est mis en cache.</p><p><span id="more-951"></span>Le problème est que <strong>WordPress autorise par défaut l'utilisation d'un certain nombre de balises HTML</strong> dans les commentaires, y compris<strong> les balises de commentaire HTML</strong> (<code>&lt;!--</code> et <code>--&gt;</code>). Il est donc possible pour un visiteur malveillant d'injecter des balises <em>mfunc</em> dans le site, et donc du code arbitraire, en postant un simple commentaire comportant cette balise. <strong>WordPress ne la filtrera pas</strong> puisqu'elle sera interprétée comme un simple commentaire HTML, et elle sera donc stockée en base de données. En revanche, lorsque la page affichant le commentaire sera rechargée, <strong>le plugin de cache exécutera le code PHP</strong> intégré conformément à la fonctionnalité précédemment décrite.</p><h3>Analyse détaillée de l'attaque</h3><p>Regardons maintenant plus en détail les tentatives d'attaques que j'ai reçues. Voici tout d'abord <strong>le contenu complet des commentaires</strong> que l'on a tenté de déposer :<br /> <img class="aligncenter size-full wp-image-965" alt="wp_mfunc_attack_1" src="http://www.kevinsubileau.fr/wp-content/uploads/2014/03/wp_mfunc_attack_1.png" width="775" height="240" /></p><p>On peut voir que l'attaque vise à <strong>évaluer un code PHP encodé en base 64</strong>. Mais qu'y a-t-il derrière cette chaîne de caractères imbuvable ? Le décodage en utilisant la fonction <code><a href="http://www.php.net/manual/function.php-base64_decode.php">base64_decode</a></code> nous donne ceci :</p><p><img class="aligncenter size-full wp-image-966" alt="wp_mfunc_attack_2" src="http://www.kevinsubileau.fr/wp-content/uploads/2014/03/wp_mfunc_attack_2.png" width="775" height="195" /></p><p>L'objectif est donc d'écrire dans le fichier <em>wp-content/cache/qwkmrn.php</em> le code PHP suivant :</p><p><img class="aligncenter size-full wp-image-969" alt="wp_mfunc_attack_3" src="http://www.kevinsubileau.fr/wp-content/uploads/2014/03/wp_mfunc_attack_3.png" width="775" height="165" /></p><p>Le code est pollué par des commentaires inutiles que l'on peut retirer simplement en utilisant la fonction <code><a href="http://www.php.net/manual/function.php-strip-whitespace.php">php_strip_whitespace</a></code> ou la commande <em>php -w</em>. Voici ce que cela donne après ce nettoyage :</p><p><img class="aligncenter size-full wp-image-970" alt="wp_mfunc_attack_4" src="http://www.kevinsubileau.fr/wp-content/uploads/2014/03/wp_mfunc_attack_4.png" width="775" height="120" /></p><p>Une fois encore, on se retrouve face à une évaluation d'un code encodé en base64. Après un second décodage, on obtient le code suivant :</p><p><img class="aligncenter size-full wp-image-971" alt="wp_mfunc_attack_5" src="http://www.kevinsubileau.fr/wp-content/uploads/2014/03/wp_mfunc_attack_5.png" width="775" height="75" /></p><p>Le code est encore une fois pollué par des commentaires inutiles. Mais au final, après nettoyage, <strong>on obtient un code très simple</strong> :</p><p><img class="aligncenter size-full wp-image-972" alt="wp_mfunc_attack_6" src="http://www.kevinsubileau.fr/wp-content/uploads/2014/03/wp_mfunc_attack_6.png" width="611" height="15" /></p><p>L'attaquant dispose alors d'un <strong>shell PHP</strong> qui va lui permettre d’<strong>exécuter à distance les commandes qu'il souhaite</strong> simplement en les passant en paramètre de la page <em>http://sitecible.com/wp-content/cache/qwkmrn.php?nmdxp=</em>. Une backdoor a été introduite, et votre site se retrouve totalement aux mains du pirate...</p><h3>Comment se protéger ?</h3><p>Tout d'abord, si vous utilisez toujours une version vulnérable (W3TC ≤ 0.9.2.8 ou WP Super Cache ≤ 1.2), il est indispensable que <strong>vous mettiez immédiatement à jour votre site</strong>. Ensuite, vous pouvez mettre en place un système de <strong>filtrage des spams</strong> sur les commentaires, tel qu'un captcha, un honeypot ou le plugin Akismet. Enfin, assurez-vous également que tous les commentaires passent par <strong>une étape de modération</strong>, ou, à défaut, utilisez <strong>un service externe</strong> tel que Disqus.</p><p><small>NB : Le code est volontairement sous forme d'image, ce serai bête de risquer de s'auto-attaquer...</small></p> ]]></content:encoded> <wfw:commentRss>https://www.kevinsubileau.fr/informatique/hacking-securite/attaque-vulnerabilite-mfunc-wordpress-w3tc.html/feed</wfw:commentRss> <slash:comments>7</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching using disk: basic

Served from: www.kevinsubileau.fr @ 2026-04-14 14:29:48 -->