T1564.007 VBA Stomping
Adversaries may hide malicious Visual Basic for Applications (VBA) payloads embedded within MS Office documents by replacing the VBA source code with benign data.1
MS Office documents with embedded VBA content store source code inside of module streams. Each module stream has a PerformanceCache
that stores a separate compiled version of the VBA source code known as p-code. The p-code is executed when the MS Office version specified in the _VBA_PROJECT
stream (which contains the version-dependent description of the VBA project) matches the version of the host MS Office application.23
An adversary may hide malicious VBA code by overwriting the VBA source code location with zero’s, benign code, or random bytes while leaving the previously compiled malicious p-code. Tools that scan for malicious VBA source code may be bypassed as the unwanted code is hidden in the compiled p-code. If the VBA source code is removed, some tools might even think that there are no macros present. If there is a version match between the _VBA_PROJECT
stream and host MS Office application, the p-code will be executed, otherwise the benign VBA source code will be decompressed and recompiled to p-code, thus removing malicious p-code and potentially bypassing dynamic analysis.415
Item | Value |
---|---|
ID | T1564.007 |
Sub-techniques | T1564.001, T1564.002, T1564.003, T1564.004, T1564.005, T1564.006, T1564.007, T1564.008, T1564.009, T1564.010 |
Tactics | TA0005 |
Platforms | Linux, Windows, macOS |
Permissions required | User |
Version | 1.1 |
Created | 17 September 2020 |
Last Modified | 15 October 2021 |
Mitigations
ID | Mitigation | Description |
---|---|---|
M1042 | Disable or Remove Feature or Program | Turn off or restrict access to unneeded VB components.7 |
Detection
ID | Data Source | Data Component |
---|---|---|
DS0022 | File | File Metadata |
DS0012 | Script | Script Execution |
References
-
Cole, R., Moore, A., Stark, G., Stancill, B. (2020, February 5). STOMP 2 DIS: Brilliance in the (Visual) Basics. Retrieved September 17, 2020. ↩↩
-
Hegt, S. (2019, May 5). Evil Clippy: MS Office maldoc assistant. Retrieved September 17, 2020. ↩
-
Microsoft. (2020, February 19). 2.3.4.1 _VBA_PROJECT Stream: Version Dependent Project Information. Retrieved September 18, 2020. ↩
-
Sayre, K., Ogden, H., Roberts, C. (2018, October 10). VBA Stomping — Advanced Maldoc Techniques. Retrieved September 17, 2020. ↩
-
Bontchev, V. (2019, July 30). pcodedmp.py - A VBA p-code disassembler. Retrieved September 17, 2020. ↩
-
decalage2. (2019, December 3). python-oletools. Retrieved September 18, 2020. ↩
-
Microsoft. (2020, January 23). How to turn off Visual Basic for Applications when you deploy Office. Retrieved September 17, 2020. ↩