Remote Code Execution in Realms Wiki install.sh by Javantea Mar 15, 2015 Product: Realms Wiki Website: http://realms.io/ Github: https://github.com/scragg0x/realms-wiki CVSS Score: 7.9 (AV:A/AC:M/Au:N/C:C/I:C/A:C) On line 20 of realms-wiki install.sh, a GPG key that is requested via HTTP is added to the apt keyring. A remote attacker that has a man-in-the-middle (via ARP spoof, DNS spoof, or HTTP man-in-the-middle) against the person running install.sh can use this to sign arbitrary packages that are installed. This gives the remote attacker root privileges on the affected machine. install.sh:20: wget -qO - http://packages.elasticsearch.org/GPG-KEY-elasticsearch | sudo apt-key add - This line of code was probably copied and pasted from someone else's code. Even if you don't run Realms Wiki, you may have run this code when you installed a different project. As you can see, this key is being used all over the place. https://github.com/search?q=GPG-KEY-elasticsearch&type=Code&utf8=%E2%9C%93 It seems to affect more than just Ubuntu and Debian systems, some people import the same key into RedHat's keyring. Gentoo and RedHat-derived systems running Realms Wiki appear to be unaffected. While many vendors consider this attack theoretical, let me ensure you that it is practical and easily accomplished in a datacenter, a broadband network, or a wireless network. Practically any person that runs install.sh as root can be compromised. The CVSS score for this vulnerability is inflated beyond its actual impact. Even though this is remote code execution, the attacker has to be in place during the installation which limits the window of attack considerably. This doesn't mean that this attack isn't a serious issue. Disclosure Timeline: Found: Sun, Mar 15, 2015 Reported to author: Sun, Mar 15, 2015 Full Disclosure: Thu, Mar 25, 2015 I have chosen to release after 10 days because I have heard no response from the author. I do not wish to give attackers any further window to exploit these vulnerabilities. Therefore I am using full-disclosure to warn users that their sites can be CSRFed and if they install it when an attacker has a man-in-the-middle, their entire system can become compromised. I am also posting the CSRF vulnerability along with this (which is higher severity due to the lower difficulty in exploitation). Thanks to those who have written this wiki. It's well-written and will need some bug fixes. I plan on making many improvements to this wiki in the future. Regards, Javantea