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 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.

Microsoft Sentinel / Defender
kusto
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
high severity medium confidence

Data Sources

Process: Process Creation Command: Command Execution Microsoft Defender for Endpoint

Required Tables

DeviceProcessEvents

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

Unlock Pro Content

Get the full detection package for T1564.007 including response playbook, investigation guide, and atomic red team tests.

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections