SEC Consult Vulnerability Lab Security Advisory < 20191211-0 > ======================================================================= title: File Extension Spoofing product: Windows Defender Antivirus vulnerable version: 4.18.1908.7-0 fixed version: Virus Definition Update of 2019/09/30 CVE number: - impact: High homepage: https://www.microsoft.com/de-at/windows/comprehensive-security found: 2019-09-25 by: David Haintz (Office Vienna) SEC Consult Vulnerability Lab An integrated part of SEC Consult Europe | Asia | North America https://www.sec-consult.com ======================================================================= Vendor description: ------------------- "Keep your PC safe with trusted antivirus protection built-in to Windows 10. Windows Defender Antivirus delivers comprehensive, ongoing and real-time protection against software threats like viruses, malware and spyware across email, apps, the cloud and the web." Source: https://www.microsoft.com/de-at/windows/comprehensive-security Business recommendation: ------------------------ Update to the latest version of the Windows Defender Antivirus definitions. Vulnerability overview/description: ----------------------------------- The vulnerability is based on the file extension spoofing method using the RTL unicode character to display a spoofed file extension. This method uses the LTR unicode character, that instructs the following text to be shown in left-to-right order. Lets assume [LTR] is the LTR unicode character, an attacker can use this unicode character to fool a user into believing that a file has a different extension. For example an attacker may name an executable file (.exe) 'spoofed-[LTR]gpj.exe', which would be displayed as 'spoofed-exe.jpg' on an LTR-based system. The most important point here is to have the extension you want to be shown in reverse order, since it will be shown right-to-left. Combined with the right file icon, an attacker can imitate an arbitrary file extension. Same goes for other extensions too, like 'xlsx' for a Microsoft Excel Sheet. During testing it happened that 'xlsx' was typed in the wrong order ('xslx' instead of 'xlsx' since reverse order) and Windows Defender Antivirus removed the test file while we tried to execute it. As a result, two files were created, with the exact same executable but with different fake extensions: 1. spoofed-[RTL]xslx.exe (displayed as 'spoofed-exe.xlsx') 2. spoofed-[RTL]xlsx.exe (displayed as 'spoofed-exe.xslx') The second one was deleted, while the first one could be executed without any problem. Therefore, other extensions related to Microsoft Office were tested as well, but it seems only the xlsx extension had a detection for it. While the security issue of spoofing the file extension by using the RTL unicode character (on RTL systems it is the same just with LTR) is widely known, it seems to be unknown that Microsoft already started to add detection mechanisms for this issue. But since it is not implemented for all extensions and it seems to be implemented in the wrong order, this feature is mostly unknown. Proof of concept: ----------------- For the proof of concept a file has to be renamed in Unicode mode using the Unicode character '202E' ('\u202E' in C), which stands for RTL. The sample code is written in C/C++ and uses the unicode API of Windows. A Python PoC has been made as well. C/C++: #include int main(int argc, char** argv) { wchar_t opath[] = L"test.exe"; wchar_t npath_ok[] = L"spoofed-\u202Exslx.exe"; // String for filename 'spoofed-exe.xlsx' wchar_t npath_wrong[] = L"spoofed-\u202Exlsx.exe"; // String for filename 'spoofed-exe.xslx' // Copy 'test.exe' to file shown as 'spoofed-exe.xlsx' CopyFileW(opath, npath_ok, false); // Copy 'test.exe' to file shown as 'spoofed-exe.xslx' CopyFileW(opath, npath_wrong, false); } Python: from shutil import copyfile opath = "test.exe" npath_ok = "spoofed-\u202Exslx.exe" # String for filename 'spoofed-exe.xlsx' npath_wrong = "spoofed-\u202Exlsx.exe" # String for filename 'spoofed-exe.xslx' # Copy 'test.exe' to file shown as 'spoofed-exe.xlsx' copyfile(opath, npath_ok) # Copy 'test.exe' to file shown as 'spoofed-exe.xslx' copyfile(opath, npath_wrong) There will be two new files after the execution (as long as 'test.exe' exists) and the file shown as 'spoofed-exe.xslx' will be deleted while trying to execute (or earlier) as shown in figure 1. [ win-defender-ext-spoofing1.png ] Figure 1: File gets deleted by Windows Defender Antivirus. But the file shown as 'spoofed-exe.xlsx' will be executed without any problem. [ win-defender-ext-spoofing2.png ] Figure2: Test file is executed. Vulnerable / tested versions: ----------------------------- Windows Defender Antivirus has been tested in its latest version 4.18.1908.7-0, updated at 25th of September 2019. Vendor contact timeline: ------------------------ 2019-09-26: Providing vendor the advisory through secure@microsoft.com 2019-10-01: Microsoft answered that this is no vulnerability, but the virus definition database will be updated 2019-12-11: Public release of security advisory Solution: --------- The update of the virus definition database of the 30th of September provides a fix. Workaround: ----------- There is no workaround available. Advisory URL: ------------- https://www.sec-consult.com/en/vulnerability-lab/advisories/index.html ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SEC Consult Vulnerability Lab SEC Consult Europe | Asia | North America About SEC Consult Vulnerability Lab The SEC Consult Vulnerability Lab is an integrated part of SEC Consult. It ensures the continued knowledge gain of SEC Consult in the field of network and application security to stay ahead of the attacker. The SEC Consult Vulnerability Lab supports high-quality penetration testing and the evaluation of new offensive and defensive technologies for our customers. Hence our customers obtain the most current information about vulnerabilities and valid recommendation about the risk profile of new technologies. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Interested to work with the experts of SEC Consult? Send us your application https://www.sec-consult.com/en/career/index.html Interested in improving your cyber security with the experts of SEC Consult? Contact our local offices https://www.sec-consult.com/en/contact/index.html ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Mail: research at sec-consult dot com Web: https://www.sec-consult.com Blog: http://blog.sec-consult.com Twitter: https://twitter.com/sec_consult EOF David Haintz / @2019