Safe Mode Boot
Adversaries may abuse Windows safe mode to disable endpoint defenses. Safe mode starts up the Windows operating system with a limited set of drivers and services. Third-party security software such as endpoint detection and response (EDR) tools may not start after booting Windows in safe mode. There are two versions of safe mode: Safe Mode and Safe Mode with Networking. Adversaries may abuse safe mode to disable endpoint defenses that may not start with a limited boot. Hosts can be forced into safe mode after the next reboot via modifications to Boot Configuration Data (BCD) stores using bcdedit. Adversaries may also add their malicious applications to the list of minimal services that start in safe mode by modifying relevant Registry values. This technique has been used by multiple ransomware families including REvil, Black Basta, LockBit 3.0, AvosLocker, Qilin, and RansomHub to encrypt files while EDR tools are inactive.
let BcdEditSafeMode = dynamic([
"safeboot", "safebootalternateshell",
"{current}", "{default}"
]);
let SafeModeRegistryPaths = dynamic([
"SafeBoot\\Minimal",
"SafeBoot\\Network"
]);
union
(
DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName =~ "bcdedit.exe"
| where ProcessCommandLine has_any ("safeboot", "/set", "network", "minimal")
| extend IsSafeBootSet = ProcessCommandLine has "safeboot"
| extend IsNetworkMode = ProcessCommandLine has "network"
| extend IsDeleteSafeBoot = ProcessCommandLine has "deletevalue" and ProcessCommandLine has "safeboot"
| project Timestamp, DeviceName, AccountName, FileName,
ProcessCommandLine, InitiatingProcessFileName,
InitiatingProcessCommandLine,
IsSafeBootSet, IsNetworkMode, IsDeleteSafeBoot
),
(
DeviceRegistryEvents
| where Timestamp > ago(24h)
| where RegistryKey has_any (SafeModeRegistryPaths)
| where ActionType in ("RegistryValueSet", "RegistryKeyCreated")
| project Timestamp, DeviceName, AccountName,
RegistryKey, RegistryValueName, RegistryValueData,
InitiatingProcessFileName, InitiatingProcessCommandLine,
ActionType
),
(
DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName =~ "bootcfg.exe"
| where ProcessCommandLine has "/raw" and ProcessCommandLine has_any ("safeboot", "/SAFEBOOT")
| project Timestamp, DeviceName, AccountName, FileName,
ProcessCommandLine, InitiatingProcessFileName,
InitiatingProcessCommandLine
)
| sort by Timestamp desc Data Sources
Required Tables
False Positives
- System administrators using bcdedit to troubleshoot boot issues or configure safe mode for maintenance windows
- IT helpdesk technicians remotely booting endpoints into safe mode to remove stubborn malware or driver conflicts
- Software installers that register themselves under SafeBoot registry keys as a legitimate minimal service (rare but possible with driver installers)
- Windows Update or BIOS firmware updates that temporarily modify BCD settings during a planned update cycle
References (7)
- https://attack.mitre.org/techniques/T1562/009/
- https://www.bleepingcomputer.com/news/security/revil-ransomware-has-a-new-windows-safe-mode-encryption-mode/
- https://news.sophos.com/en-us/2019/12/09/snatch-ransomware-reboots-pcs-into-safe-mode-to-bypass-protection/
- https://www.cyberark.com/resources/blog/cyberark-labs-from-safe-mode-to-domain-compromise
- https://www.cybereason.com/blog/medusalocker-ransomware
- https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/bcdedit
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1562.009/T1562.009.md
Unlock Pro Content
Get the full detection package for T1562.009 including response playbook, investigation guide, and atomic red team tests.