Wampserver 3.0.6 Privilege Escalation
Posted on 27 December 2016
===================================================== # Vendor Homepage: http://www.wampserver.com/ # Date: 10 Dec 2016 # Version : Wampserver 3.0.6 32 bit x86 # Tested on: Windows 7 Ultimate SP1 (EN) # Author: Heliand Dema # Contact: heliand@cyber.al # CVE: 2016-10031 ===================================================== Wampserver installs two services called 'wampapache' and 'wampmysqld' with weak file permission running with SYSTEM privileges. This could potentially allow an authorized but non-privileged local user to execute arbitrary code with elevated privileges on the system. C:>sc qc wampapache [SC] QueryServiceConfig SUCCESS SERVICE_NAME: wampapache TYPE : 10 WIN32_OWN_PROCESS START_TYPE : 3 DEMAND_START ERROR_CONTROL : 1 NORMAL BINARY_PATH_NAME : "c:wampinapacheapache2.4.23inhttpd.exe" -k runservice LOAD_ORDER_GROUP : TAG : 0 DISPLAY_NAME : wampapache DEPENDENCIES : Tcpip : Afd SERVICE_START_NAME : LocalSystem PS C:> icacls c:wampinapacheapache2.4.23inhttpd.exe c:wampinapacheapache2.4.23inhttpd.exe BUILTINAdministrators:(I)(F) <--- Full Acces NT AUTHORITYSYSTEM:(I)(F) BUILTINUsers:(I)(RX) NT AUTHORITYAuthenticated Users:(I)(M) <--- Modify C:Windowssystem32>sc qc wampmysqld [SC] QueryServiceConfig SUCCESS SERVICE_NAME: wampmysqld TYPE : 10 WIN32_OWN_PROCESS START_TYPE : 3 DEMAND_START ERROR_CONTROL : 1 NORMAL BINARY_PATH_NAME : c:wampinmysqlmysql5.7.14inmysqld.exe wampmysqld LOAD_ORDER_GROUP : TAG : 0 DISPLAY_NAME : wampmysqld DEPENDENCIES : SERVICE_START_NAME : LocalSystem PS C:> icacls c:wampinmysqlmysql5.7.14inmysqld.exe c:wampinmysqlmysql5.7.14inmysqld.exe BUILTINAdministrators:(I)(F) <--- Full Acces NT AUTHORITYSYSTEM:(I)(F) BUILTINUsers:(I)(RX) NT AUTHORITYAuthenticated Users:(I)(M) <--- Modify Notice the line: NT AUTHORITYAuthenticated Users:(I)(M) which lists the permissions for authenticated however unprivileged users. The (M) stands for Modify, which grants us, as an unprivileged user, the ability to read, write and delete files and subfolders within this folder. ====Proof-of-Concept==== To properly exploit this vulnerability, the local attacker must insert an executable file called mysqld.exe or httpd.exe and replace the original files. Next time service starts the malicious file will get executed as SYSTEM.