Blog | G5 Cyber Security

Malicious .XLSM Files

TL;DR

Yes, a text file renamed to look like an Excel Macro-Enabled Workbook (.xlsm) can be malicious. While it won’t open as a normal spreadsheet, Windows might still try to execute code within it if associated with the wrong program or exploited through vulnerabilities. Treat all unexpected .xlsm files with extreme caution.

How It Works

An .xlsm file is essentially a ZIP archive containing XML data and VBA (Visual Basic for Applications) macros. If you simply rename a text file to have an .xlsm extension, it doesn’t magically become a valid Excel file. However, the danger lies in how Windows handles file associations and potential exploits.

Steps to Protect Yourself

  1. Understand File Associations: Windows associates file extensions with programs. If an .xlsm extension is incorrectly associated with a program that can execute code (even unintentionally), opening the renamed text file could trigger malicious behaviour.
  2. Check the File Extension Carefully: Don’t rely solely on the icon. Cyber security best practice is to always verify the actual file extension in the Windows Explorer details pane. Right-click the file, select ‘Properties’, and look at the ‘Type of file’ entry.
  3. Scan with Anti-Virus Software: A good anti-virus program should detect known malicious files, even if they have a misleading extension. Ensure your definitions are up to date.
  4. Use a Sandbox Environment (Advanced): If you suspect a file but aren’t sure, open it in a virtual machine or sandbox environment. This isolates the potential threat from your main system. VirtualBox and VMware Workstation Player are popular options.
  5. Examine File Contents (Advanced): You can rename the .xlsm file to .zip and extract its contents. Look for suspicious files, especially VBA modules (.vba or .bas). Be very careful when doing this; avoid executing any code you find.
    ren malicious.xlsm malicious.zip
  6. Disable Macros by Default in Excel: Configure Excel to disable macros automatically and only enable them for trusted sources. This significantly reduces the risk of macro-based attacks.
    • Go to File > Options > Trust Center > Trust Center Settings…
    • Click ‘Macro Settings’ and select ‘Disable all macros with notification’.
  7. Keep Software Updated: Regularly update your operating system, web browser, and Microsoft Office suite. Updates often include security patches that address vulnerabilities exploited by malicious files.

What Could Happen?

Example Scenario

Imagine someone sends you ‘invoice.xlsm’. It looks legitimate, but it’s actually a text file containing a PowerShell script disguised as an Excel workbook. If your system is configured to run PowerShell scripts with the .xlsm extension (highly unlikely by default, but possible through misconfiguration or user actions), opening ‘invoice.xlsm’ could execute the malicious script.

Exit mobile version