CVE-2021-40444 - MSHTML RCE - Generate document for fishing assessment
Today we’ll talk about a Microsoft MSHTML Remote Code Execution Vulnerability and how to generate your own documents for fishing assessments.
Here is a list of subtopics of this post:
- Vulnerability summary
- How does the vulnerability work?
- Are there public exploits?
- How to use your own template?
- Mitigate
- Sources
Vulnerability summary
Chronology | 7th September 2021 – warning from Microsoft, 14th September 2021 - patch |
Vulnerable OS versions | Windows 8.1-10, Windows Server 2008-2019 |
Affected products | MSHTML, ActiveX, Office |
Impact | RCE via Social Engineering |
How does the vulnerability work?
Attackers exploit CVE-2021-40444
using specially crafted Microsoft Office
documents.
Such a document uses the MSHTML
mechanism to open a malicious website hosted on an attacker-controlled endpoint. Link to this website exists as an Object Linking and Embedding (OLE)
MIME HTML (MHTML)
object in the context of a document. The website executes JavaScript
code and ActiveX
controls, which then run malicious code on the system on which the malicious Office document was opened. This code is hosted on an attacker-controlled endpoint in the form of a dynamic link library (DLL)
.
Are there public exploits?
There is a publicly available exploit, which generates documents:
CVE-2021-40444 POC by lockedbyte
The generated document looks like this:
But in phishing assessments, we will need a more detailed and realistically looking layout.
How to use your own template?
Initially, we would need the exploit from GitHub and our document, which we will use as a template.
1.Move existing template in exploit into another folder
2.Unzip your document, replacing template folder in exploit directory
3.From original CVE-2021-40444/data/word_dat_orig/word/_rels/document.xml.rels
copy strings below into CVE-2021-40444/data/word_dat/word/_rels/document.xml.rels
, increasing or decreasing rId
according to your document content:
4.From CVE-2021-40444/data/word_dat_orig/word/document.xml
, copy the block containing rId6
and rId5
to CVE-2021-40444/data/word_dat/word/document.xml
. A similar block is below. Replace rId
with yours from the previous step.
5.Create listener
6.Generate .dll
using msfvenom
and place into directory CVE-2021-40444/test
7.Generate your malicious document with exploit
8.Use the exploit to open the http server hosting the html file
9.Deliver document on your target machine.
10.Open document and receive shell
Mitigate
Install patch September’s patches.
That’s it. Stay safe and Happy Hacking!
Check out the list of sources for additional information
Sources
- Microsoft release on CVE-2021-40444
- “Remote Code Execution 0-Day (CVE-2021-40444) Hits Windows, Triggered Via Office Docs” by TrendMicro
- “Cybersecurity Advisory: Hackers Are Exploiting CVE-2021-40444” by Huntress
- “THREAT ALERT: Microsoft MSHTML Remote Code Execution Vulnerability” by Cybereason Global SOC Team