{"id":8330,"date":"2017-07-12T20:41:00","date_gmt":"2017-07-13T04:41:00","guid":{"rendered":"http:\/\/www.palada.net\/index.php\/2017\/07\/12\/news-2104\/"},"modified":"2017-07-12T20:41:00","modified_gmt":"2017-07-13T04:41:00","slug":"news-2104","status":"publish","type":"post","link":"https:\/\/www.palada.net\/index.php\/2017\/07\/12\/news-2104\/","title":{"rendered":"Incomplete Patch: More Joomla! Core XSS Vulnerabilities Are Found"},"content":{"rendered":"<p><strong>Credit to Author: Zhouyuan Yang| Date: Wed, 12 Jul 2017 15:50:00 +0000<\/strong><\/p>\n<div class=\"entry\">\n<p>Joomla! is one of the world&#39;s most popular content management systems (CMS). It enables users to build Web sites and powerful online applications. More than 3 percent of Web sites are running Joomla!, and it accounts for more than 9 percent of CMS market share.<\/p>\n<p>As of July 2017, Joomla! has been downloaded over 82 million times. Over 7,800 free and commercial extensions are available from the official Joomla! Extension Directory, and more are available from other sources.<\/p>\n<p>In my last <a href=\"http:\/\/blog.fortinet.com\/2017\/05\/04\/multiple-joomla-core-xss-vulnerabilities-are-discovered\">blog<\/a>, I discovered 2 Cross-Site Scripting (XSS) vulnerabilities in Joomla!. They are identified as <a href=\"https:\/\/developer.joomla.org\/security-centre\/685-core-xss-vulnerability.html\">CVE-2017-7985<\/a> and <a href=\"https:\/\/developer.joomla.org\/security-centre\/686-core-xss-vulnerability.html\">CVE-2017-7986<\/a>. After analyzing the patches for these issues, I discovered 3 more XSS vulnerabilities. Joomla! still identifies these 3 new vulnerabilities as CVE-2017-7985, and has posted a separate <a href=\"https:\/\/developer.joomla.org\/security-centre\/698-20170603-core-xss-vulnerability.html\">security announcement<\/a>.<\/p>\n<p>As detailed in my last blog, these vulnerabilities exist because Joomla! fails to sanitize malicious user input when users post or edit an article. Remote attackers could exploit these vulnerabilities to run malicious code on a victim&rsquo;s browser. This could allow the remote attacker to gain control of the victim&rsquo;s Joomla! account. However, if the victim has higher permission, like system administrator, the remote attacker could actually gain full control of the web server.<\/p>\n<p>These vulnerabilities affect Joomla! CMS versions 1.5.0 through 3.7.2. In this blog, I will share the details of these vulnerabilities.<\/p>\n<h2>Background<\/h2>\n<p>In the patches for CVE-2017-7985 and CVE-2017-7986, Joomla! filtered special characters, like the right double quotation mark, and dangerous HTML codes like &ldquo;formaction.&rdquo; But the filtering process is similar to a blacklist sanitizer, which means it simply matches the bad codes and drops them.<\/p>\n<h2>Analysis<\/h2>\n<p>In this analysis I use the same test account &lsquo;yzy1&rsquo; as in my last post. This account only has publisher permission, which means it&rsquo;s not allowed to use full HTML elements.<\/p>\n<p>In the CVE-2017-7985 and CVE-2017-7986 patches, Joomla! sanitized my PoC<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/joomlahtml.png\" style=\"width: 411px; height: 65px;\" \/><\/p>\n<p>as shown in Figures 1 and 2.<\/p>\n<form>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Joomlaxss2001.png\" style=\"width: 1260px; height: 846px;\" \/><\/p>\n<p align=\"center\">Figure 1. Fix for CVE-2017-7985<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Joomlaxss2003.png\" style=\"width: 1259px; height: 846px;\" \/><\/p>\n<p align=\"center\">Figure 2. Fix for CVE-2017-7986<\/p>\n<p>Because it&rsquo;s a blacklist XSS filter, I found that by adding the HTML &ldquo;<strong>%0d%0a<\/strong>&rdquo; mark, an attacker is able to bypass the filter and insert arbitrary HTML codes.<\/p>\n<p>For example, the PoC in CVE-2017-7985 can be changed to <img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/joomlahtml2.png\" style=\"width: 451px; height: 17px;\" \/>. I added the %0d%0a behind the right double quotation, which allowed the XSS code to be triggered in both the front page and the backend, as shown in figures 3, 4, and 5.<\/p>\n<p>The fix for CVE-2017-7986 can be bypassed in the same way.<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Joomlaxss2005.png\" \/><\/p>\n<p align=\"center\">Figure 3. Inserting new PoC for CVE-2017-7985<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Joomlaxss2007.png\" style=\"width: 1258px; height: 846px;\" \/><\/p>\n<p align=\"center\">Figure 4. New PoC for CVE-2017-7985 triggered in the front page<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Joomlaxss2009.png\" style=\"width: 1248px; height: 911px;\" \/><\/p>\n<p align=\"center\">Figure 5. New PoC for CVE-2017-7985 triggered in administrator page<\/p>\n<p>Moreover, in HTML, &ldquo;%0d%0a&rdquo; serves as a line break, and the HTML codes can work by breaking with &ldquo;%0d%0a&rdquo;. For example, in figure 6, the codes in the two SVG tags have the same function.<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Joomlaxss2011.png\" style=\"width: 740px; height: 195px;\" \/><\/p>\n<p align=\"center\">Figure 6. HTML codes break using &ldquo;%0d%0a&rdquo;<\/p>\n<p>Based on this, I found an easier way to trigger the XSS attack by simply adding the &ldquo;%0d%0a&rdquo;string to arbitrary HTML tags, like a, svg, img, and so on. Here is an example with an SVG tag.<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Joomlaxss2013.png\" style=\"width: 1258px; height: 845px;\" \/><\/p>\n<p align=\"center\">Figure 7. Inserting PoC in SVG tag<\/p>\n<p>The codes will be triggered in both the front page and the administrator page, as shown in figures 8 and 9.<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Joomlaxss2015.png\" style=\"width: 1258px; height: 843px;\" \/><\/p>\n<p align=\"center\">Figure 8. SVG tag XSS in the front page<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Joomlaxss2017.png\" style=\"width: 1248px; height: 909px;\" \/><\/p>\n<p align=\"center\">Figure 9. SVG tag XSS in the administrator page<\/p>\n<p>There is no length limitation, so the attacker can insert the codes as many times as he wants and the XSS codes in the SVG tag will be triggered automatically. The victim only needs to view the article to trigger the attack.<\/p>\n<h2>Exploit<\/h2>\n<p>As I did in my last post, I will now show how an attacker using a low permission account is able to exploit this vulnerability to create a Super User account and then upload a web shell.<\/p>\n<p>To accomplish this, I will first build a small JavaScript for adding a Super User. This script leverages the site administrator&rsquo;s permission to get the CSRF token from the user edit page &ldquo;index.php?option=com_users&amp;view=user&amp;layout=edit&rdquo;, and then posts the add Super User request to the server using the CSRF token. In this example, the new Super User is Fortinet Yzy and the password is fortinet.<\/p>\n<p>  <script src=\"https:\/\/gist.github.com\/anonymous\/e8090732058ec9ea2bfcf234a1ca03b2.js\"><\/script>    <\/p>\n<p>An attacker can add this code to Joomla! by exploiting the XSS vulnerability, as shown in figure 10.<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Joomlaxss2019.png\" style=\"width: 1260px; height: 846px;\" \/><\/p>\n<p align=\"center\">Figure 10. Adding XSS codes<\/p>\n<p>Once the site administrator views the article in the administrator page, a Super User account is created immediately. See figures 11 and 12.<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Joomlaxss2021.png\" style=\"width: 1248px; height: 910px;\" \/><\/p>\n<p align=\"center\">Figure 11. Site Administrator triggers the XSS attack in the administrator page<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Joomlaxss2023.png\" style=\"width: 1249px; height: 911px;\" \/><\/p>\n<p align=\"center\">Figure 12. A new Super User is added by the attacker<\/p>\n<p>The attacker now can login to Joomla! with Super User permission and upload a web shell by installing a plugin. This is shown in figures 13 and 14.<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Joomlaxss2025.jpg\" style=\"width: 1600px; height: 867px;\" \/><\/p>\n<p align=\"center\">Figure 13. Uploading a web shell using the attacker&rsquo;s Super User account<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/Joomlaxss2027.jpg\" style=\"width: 1281px; height: 983px;\" \/><\/p>\n<p align=\"center\">Figure 14. The attacker is able to access the web shell and execute commands<\/p>\n<h2>Solution<\/h2>\n<p>All users of Joomla! should upgrade to the latest version immediately.<\/p>\n<p>Additionally, organizations using Fortinet IPS solutions are already protected from these vulnerabilities with the following signatures:<\/p>\n<p>Joomla!.Core.create-a-post.XSS<\/p>\n<p>Joomla!.Core.LineFeed.Char.XSS.A<\/p>\n<p>Joomla!.Core.LineFeed.Char.XSS.B<\/p>\n<\/p><\/form>\n<\/div<br \/><a href=\"https:\/\/blog.fortinet.com\/2017\/07\/12\/incomplete-patch-more-joomla-core-xss-vulnerabilities-are-found\" target=\"bwo\" >https:\/\/blog.fortinet.com\/feed<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/joomlahtml.png\"\/><\/p>\n<p><strong>Credit to Author: Zhouyuan Yang| Date: Wed, 12 Jul 2017 15:50:00 +0000<\/strong><\/p>\n<p>Joomla! is one of the world&#039;s most popular content management systems (CMS). It enables users to build Web sites and powerful online applications. More than 3 percent of Web sites are running Joomla!, and it accounts for more than 9 percent of CMS market share.    As of July 2017, Joomla! has been downloaded over 82 million times. Over 7,800 free and commercial extensions are available from the official Joomla! Extension Directory, and more are available from other sources.    In my last blog, I discovered 2 Cross-Site Scripting (XSS) vulnerabilities&#8230;<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"colormag_page_container_layout":"default_layout","colormag_page_sidebar_layout":"default_layout","footnotes":""},"categories":[10424,10378],"tags":[],"class_list":["post-8330","post","type-post","status-publish","format-standard","hentry","category-fortinet","category-security"],"_links":{"self":[{"href":"https:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/posts\/8330","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/comments?post=8330"}],"version-history":[{"count":0,"href":"https:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/posts\/8330\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/media?parent=8330"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/categories?post=8330"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/tags?post=8330"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}