Office Macro Malware

VBA macros in Office documents became the dominant malware delivery method; decades of cat-and-mouse with Microsoft culminating in macros being blocked by default in 2022.

MITRE ATT&CK: T1566.001

Timeline: The Cat and Mouse

1995 ← Attack emerges β†’ 2000 ← Industry responds β†’ 2016 ← Resurgence β†’ 2022 ← Killed β†’ Present

The Evolution

Phase Period What Happened
ATTACK 1995 Concept virus - first macro virus proves the concept
PEAK 1999 Melissa worm - mass-mailing macro virus causes global outages
RESPONSE 2000 Microsoft adds macro warning prompts
Β  2010 Protected View introduced - documents open read-only
RESURGENCE 2016-2021 Emotet, TrickBot, Dridex dominate via β€œEnable Content” social engineering
KILLED Feb 2022 Microsoft blocks macros from internet by default
CURRENT Present Effectively dead for initial access; attackers pivoted to containers

Key Events with Sources

Date Event Significance Source
1995 Concept virus discovered First macro virus; proved VBA could be weaponized Virus Bulletin
Mar 1999 Melissa worm Mass-mailing virus; caused email outages globally FBI
May 2000 ILOVEYOU VBScript worm; billions in damages Wired
2010 Protected View released Office opens internet files read-only Microsoft
2014 Emotet first seen Banking trojan via macros; later became loader CISA
Feb 2022 Macros blocked by default VBA macros from internet blocked without override Microsoft

Overview

Office macros (VBA - Visual Basic for Applications) became the most successful malware delivery mechanism in history. For over 25 years, attackers used macros to download and execute malware. Microsoft’s 2022 decision to block macros from internet sources by default effectively killed this attack vector.

The Attack

How Macro Malware Works

1. Victim receives email with .doc/.xls attachment
2. Victim opens document
3. Document contains VBA macro
4. Macro executes:
   - Downloads payload from attacker server
   - Drops payload to disk
   - Executes payload
5. Malware (ransomware, banker, RAT) now running

VBA Macro Example

Sub AutoOpen()
    ' Runs automatically when document opens
    Dim shell As Object
    Set shell = CreateObject("WScript.Shell")
    shell.Run "powershell -enc [BASE64_PAYLOAD]"
End Sub

Historical Milestones

Concept Virus (1995):

  • First macro virus
  • Spread via Word documents
  • Proved macros could be malicious

Melissa (1999):

  • Mass-mailing macro virus
  • Forwarded itself to Outlook contacts
  • Caused widespread email outages

ILOVEYOU (2000):

  • VBScript, not Office macro, but related
  • Demonstrated script-based malware potential
  • Billions in damages

Modern Campaigns (2016-2022):

  • Emotet, TrickBot, Dridex, QakBot
  • Professional malware distribution
  • β€œEnable Content” social engineering
  • Led to ransomware infections

Social Engineering Lures

Attackers needed users to click β€œEnable Content”:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  PROTECTED VIEW                            β”‚
β”‚  This file came from the internet.         β”‚
β”‚  [Enable Editing]                          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  SECURITY WARNING                          β”‚
β”‚  Macros have been disabled.                β”‚
β”‚  [Enable Content]                          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Common Lures:

  • β€œEnable editing to view content”
  • Document appears blank without macros
  • Fake error messages
  • β€œCreated in older version of Office”
  • Invoice/shipping themes

Defense Evolution

Phase 1: Warnings (2000s)

Microsoft added prompts:

  • β€œThis document contains macros” warning
  • Users could choose to enable or disable
  • Problem: Users clicked β€œEnable” reflexively

Phase 2: Protected View (2010)

Documents from internet opened in sandbox:

  • Read-only by default
  • No macro execution
  • User must click β€œEnable Editing” then β€œEnable Content”
  • Problem: Two clicks, but users still clicked

Phase 3: Mark of the Web (MOTW)

Windows tracks file origin:

file.docm:Zone.Identifier
[ZoneTransfer]
ZoneId=3  (Internet)

Office checks MOTW to apply Protected View.

  • Problem: MOTW could be stripped (archives, ISOs)

Phase 4: Macros Blocked (2022)

Microsoft’s nuclear option:

  • Macros in files from internet: BLOCKED
  • No β€œEnable Content” option
  • Must explicitly unblock in file properties
  • Or move to Trusted Location
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  BLOCKED CONTENT                           β”‚
β”‚  Macros in this file are blocked because   β”‚
β”‚  this file came from the internet.         β”‚
β”‚  [Learn More]                              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Attacker Adaptation

With macros blocked, attackers pivoted:

Container Files

ISO/IMG Files:

  • Mount as virtual drive
  • Contents don’t have MOTW (initially)
  • Contains LNK β†’ DLL β†’ malware

ZIP with LNK Files:

  • LNK (shortcut) executes command
  • Points to LOLBin or payload

OneNote Attachments

  • .one files allow embedded objects
  • Click to run embedded script
  • Microsoft later added restrictions

HTML Smuggling

  • JavaScript constructs payload in browser
  • Downloads as blob (no MOTW initially)
  • See separate entry

XLL Add-ins

  • Excel add-in files (.xll)
  • Native code execution
  • No macro warning
  • Microsoft added blocks in 2023

Current State

Status: Limited

Macro malware is effectively dead for initial delivery:

What Changed Impact
Macros blocked from internet No more β€œEnable Content” attacks
MOTW enforcement improved Fewer bypass opportunities
Container formats addressed ISO/IMG now propagate MOTW
User conditioning Less likely to enable even if possible

Still Works When

  • Documents in Trusted Locations
  • Macros enabled by policy
  • MOTW somehow stripped
  • Document shared internally (not from internet)

Detection Guidance

Legacy Detection

If still seeing macro attempts:

file.extension IN ("doc", "docm", "xls", "xlsm", "xlsb")
AND file.has_macros = true
AND file.source = external

Behavioral Indicators

Office process spawning:

  • WINWORD.EXE β†’ cmd.exe
  • WINWORD.EXE β†’ powershell.exe
  • EXCEL.EXE β†’ wscript.exe

Post-2022 Focus

Monitor for successor techniques:

  • ISO/IMG file attachments
  • OneNote attachments
  • HTML files with JavaScript
  • LNK files in archives
  • XLL add-in files

What Killed It (or Weakened It)

Defense Introduced Impact
Macro Warning Prompts 2000 Users must click to enable macros
Protected View 2010 Documents from internet open read-only
Mark of the Web (MOTW) 2007 Windows tracks files downloaded from internet
VBA Macros Blocked by Default 2022 Macros from internet blocked without workaround

Attacker Adaptation