VBA Stomping
Adversaries may hide malicious Visual Basic for Applications (VBA) payloads embedded within MS Office documents by replacing the VBA source code location with null bytes, benign code, or random data while leaving previously compiled malicious p-code intact in the PerformanceCache. When the Office application version encoded in the _VBA_PROJECT stream matches the host Office version, the malicious p-code executes directly — bypassing static scanners that examine only the decompressed source code stream and may report no macros present. Tools such as Evil Clippy automate this stomping process. Since the technique defeats source-code-level analysis, detection relies primarily on behavioral indicators: Office applications spawning unexpected child processes, making suspicious outbound network connections, and writing unusual files to disk — the same runtime behaviors as conventional macro malware, but invisible to many automated pre-execution scanning tools.
let OfficeApps = dynamic(["winword.exe", "excel.exe", "powerpnt.exe", "msaccess.exe", "mspub.exe", "visio.exe", "outlook.exe", "onenote.exe"]);
let SuspiciousChildren = dynamic(["cmd.exe", "powershell.exe", "pwsh.exe", "wscript.exe", "cscript.exe", "mshta.exe", "rundll32.exe", "regsvr32.exe", "bitsadmin.exe", "certutil.exe", "msiexec.exe", "wmic.exe", "odbcconf.exe", "forfiles.exe", "schtasks.exe", "at.exe", "pcalua.exe", "installutil.exe", "regasm.exe", "regsvcs.exe"]);
DeviceProcessEvents
| where Timestamp > ago(24h)
| where InitiatingProcessFileName has_any (OfficeApps)
| where FileName has_any (SuspiciousChildren)
| extend IsPowerShell = FileName in~ ("powershell.exe", "pwsh.exe")
| extend IsScriptHost = FileName in~ ("wscript.exe", "cscript.exe", "mshta.exe")
| extend IsLOLBin = FileName in~ ("rundll32.exe", "regsvr32.exe", "certutil.exe", "odbcconf.exe", "bitsadmin.exe", "installutil.exe", "regasm.exe", "regsvcs.exe")
| extend IsShell = FileName =~ "cmd.exe"
| extend IsPersistence = FileName in~ ("schtasks.exe", "at.exe", "msiexec.exe")
| extend RiskScore = toint(IsPowerShell) * 3 + toint(IsScriptHost) * 3 + toint(IsLOLBin) * 2 + toint(IsShell) * 1 + toint(IsPersistence) * 2
| extend SuspiciousCommandLine = ProcessCommandLine has_any ("-enc", "-EncodedCommand", "DownloadString", "Net.WebClient", "Invoke-Expression", "IEX", "http://", "https://", "-nop", "-noprofile")
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
InitiatingProcessFileName, InitiatingProcessCommandLine,
InitiatingProcessFolderPath, FolderPath,
IsPowerShell, IsScriptHost, IsLOLBin, IsShell, IsPersistence,
SuspiciousCommandLine, RiskScore
| sort by Timestamp desc Data Sources
Required Tables
False Positives
- Finance and accounting teams using Excel macros that invoke cmd.exe or PowerShell for data export pipelines, FTP uploads, or ERP system automation
- IT-managed Excel workbooks that launch PowerShell for SCCM inventory collection, compliance reporting, or system configuration checks
- Developer workstations where Office VBA macros automate build, test, or deployment tasks by spawning scripts
- Helpdesk support tooling that uses Word or Excel macros to launch remote assistance utilities or system diagnostic scripts
References (10)
- https://attack.mitre.org/techniques/T1564/007/
- https://www.fireeye.com/blog/threat-research/2020/01/stomp-2-dis-brilliance-in-the-visual-basics.html
- https://outflank.nl/blog/2019/05/05/evil-clippy-ms-office-maldoc-assistant/
- https://medium.com/walmartglobaltech/vba-stomping-advanced-maldoc-techniques-612c484ab278
- https://github.com/bontchev/pcodedmp
- https://github.com/decalage2/oletools
- https://docs.microsoft.com/en-us/openspecs/office_file_formats/ms-ovba/ef7087ac-3974-4452-aab2-7dba2214d239
- https://github.com/outflanknl/EvilClippy
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1564.007/T1564.007.md
- https://learn.microsoft.com/en-us/defender-endpoint/attack-surface-reduction-rules-reference
Unlock Pro Content
Get the full detection package for T1564.007 including response playbook, investigation guide, and atomic red team tests.