Summary
In January 2022, Microsoft announced that Excel 4.0 macros will be restricted by default, as a measure to protect customers against malware based on XLM 4.0 macros. As a more aggressive measure, on February 07, 2022, Microsoft announced that they will start blocking VBA macros for files downloaded from the internet. This is an important step toward security as Office documents containing malicious VBA code are commonly abused by attackers to deliver other threats, such as BazarLoader, Trickbot, and remote access trojans like AveMaria and AgentTesla. In January 2022, 31% of all malware downloads Netskope blocked were malicious Office files.
Visual Basic for Applications (VBA) is a powerful tool for automation within Office files, but it also provides many resources for attackers, especially when combined with LoLBins. In 2021, Netskope described many different techniques used by attackers through VBA macros. Earlier in 2022, we also identified a malicious campaign that was using Web Archives to abuse Microsoft Office.
Previously, Microsoft Office applications required users to click “Enable” in a dialog box to run macros. So, attackers would simply use social engineering to convince their victims to click “Enable”. The hope is that the new stance of blocking VBA macros will reduce malware infections by making it harder for attackers to execute their macros on victims’ computers.
This change only applies to Windows, and only to Access, Excel, PowerPoint, Visio, and Word. There is no change for users running Office for Mac because it relies on an NTFS feature.
We believe this is an important step as it directly impacts many threat campaigns, such as Emotet. However, this doesn’t mean that attackers will stop using Office files. In this blog post, we will explain how it works and how we expect attackers will adapt.
Files downloaded from the internet
Microsoft announced that VBA macros on files downloaded from the internet will be blocked by default. But how does Microsoft Office know whether a file was downloaded from the internet?
Back in 1993, Windows NT 3.1 was released by Microsoft, and along with the OS, a new file system was introduced: NTFS. This file system was designed to be more robust than other technologies, such as FAT, introducing many new features.
Every file in NTFS is composed of at least one stream, which can have different types. One of these attributes is named $DATA, which holds the contents of the file. One of the many features provided by NTFS is the ability to store multiple $DATA attributes, commonly known as Alternate Data Stream (ADS).
The full name of a stream is defined as “filename:stream_name:stream_type”. For example, let’s assume we just created a file named “hello.txt” at “C:\Test“, with a simple text message.
If we inspect the streams of this file, which can be done through PowerShell or the Streams utility from Sysinternals, we will only see a single data stream.
Since the default data stream of a file is unnamed, the full stream name in our example is “C:\Test\hello.txt::$DATA”.
We can create an ADS by simply adding a new stream, which is named “HiddenValue” in this example.
Once this is done, we can repeat the process and access the file’s streams through PowerShell. Now, we can see the details about the stream we have created, which is stored under “C:\Test\hello.txt:HiddenValue:$DATA”.
If we open this file via notepad normally, we would not see the data we added to the “HiddenValue”, as the software reads just the default data stream. However, we can access the ADS by adding the stream name to the file path:
ADS is commonly abused by malware authors, as it provides the ability to store “hidden” data within files.
All right, but what does this have to do with files downloaded from the internet?
When a file is downloaded on Windows s