Detect Environmental Keying in Sumo Logic CSE
Adversaries may environmentally key payloads to constrain execution to a specific target by deriving cryptographic decryption keys from target-specific values such as volume serial numbers, machine GUIDs, hostnames, domain membership, or DPAPI-bound credentials. Because the decryption key is never transmitted and is derived solely from the victim environment, the payload cannot be analyzed in sandboxes or reversed without access to the exact target system. Real-world examples include APT41 using DPAPI to bind payloads to specific user accounts and machines, PowerPunch using volume serial numbers to generate XOR keys, InvisiMole using DPAPI to prevent decryption outside the compromised host, ROKRAT requiring a specific victim hostname to decrypt strings, and the Ninja implant storing payloads encrypted with keys derived from drive serial numbers.
MITRE ATT&CK
- Tactic
- Defense Evasion
- Technique
- T1480 Execution Guardrails
- Sub-technique
- T1480.001 Environmental Keying
- Canonical reference
- https://attack.mitre.org/techniques/T1480/001/
Sumo Detection Query
_sourceCategory="windows*" (sourcetype="WinEventLog:Microsoft-Windows-Sysmon/Operational" OR sourcetype="WinEventLog:Security")
| where EventID in ("1","13","4688","4657")
| eval lowerImage = toLowerCase(coalesce(Image, NewProcessName, ""))
| eval lowerCmd = toLowerCase(coalesce(CommandLine, ProcessCommandLine, ""))
| eval lowerTarget = toLowerCase(coalesce(TargetObject, ObjectName, ""))
| eval is_wmi_hw = if(
EventID in ("1","4688") and
(
lowerImage matches "(wscript\.exe|cscript\.exe|mshta\.exe|regsvr32\.exe|rundll32\.exe|wmic\.exe|certutil\.exe|powershell\.exe|pwsh\.exe)"
) and
(
lowerCmd matches "(win32_diskdrive|win32_logicaldisk|win32_volume|serialnumber|volumeserialnumber|win32_computersystemproduct|uuid|identifyingnumber)"
),
1, 0)
| eval is_wmic_uuid = if(
EventID in ("1","4688") and
lowerImage matches "wmic\.exe" and
lowerCmd matches "(bios|baseboard|csproduct|computersystemproduct|uuid|serialnumber|identifyingnumber)",
1, 0)
| eval is_registry_machineid = if(
EventID in ("13","4657") and
(
lowerTarget matches ".*microsoft.cryptography.*machineguid.*" or
lowerTarget matches ".*windows nt.currentversion.*(productid|digitalproductid).*"
) and not (
lowerImage matches "(svchost\.exe|wmiprvse\.exe|lsass\.exe|searchindexer\.exe|msmpeng\.exe|sgrmbroker\.exe|spoolsv\.exe|services\.exe|runtimebroker\.exe|taskhostw\.exe)"
),
1, 0)
| eval is_dpapi_ps = if(
EventID in ("1","4688") and
lowerImage matches "(powershell\.exe|pwsh\.exe)" and
lowerCmd matches "(cryptprotectdata|cryptunprotectdata|protecteddata|system\.security\.cryptography\.protecteddata|unprotect\(|\[dpapi\])",
1, 0)
| where is_wmi_hw=1 or is_wmic_uuid=1 or is_registry_machineid=1 or is_dpapi_ps=1
| eval DetectionMethod = if(is_dpapi_ps=1, "DPAPI_PowerShell_Keying",
if(is_registry_machineid=1, "Registry_MachineID_Queried",
if(is_wmic_uuid=1, "WMIC_UUID_Serial_Enum",
if(is_wmi_hw=1, "WMI_Hardware_Serial_Query", "Unknown"))))
| eval SuspicionScore = is_wmi_hw + is_wmic_uuid + is_registry_machineid + is_dpapi_ps
| fields _messageTime, _sourceHost, lowerImage, lowerCmd, lowerTarget, DetectionMethod, SuspicionScore
| rename lowerImage as Image, lowerCmd as CommandLine, lowerTarget as RegistryTarget
| sort by _messageTime desc Sumo Logic CSE detection for T1480.001 Environmental Keying — flags hardware fingerprinting via WMI/wmic serial queries, registry MachineGuid and ProductId reads by non-system processes, and DPAPI abuse via PowerShell, which together indicate payload key derivation for environmentally-keyed execution.
Data Sources
Required Tables
False Positives & Tuning
- Enterprise software deployment tools querying hardware serials for license binding
- Windows Update or telemetry services reading MachineGuid during update cycles
- Custom IT admin scripts using DPAPI for secure credential storage in automated pipelines
Other platforms for T1480.001
Testing Methodology
Validate this detection against 4 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are available with Pro.
- Test 1Volume Serial Number Query via WMIC (PowerPunch/Ninja Pattern)
Expected signal: Sysmon Event ID 1: Process Create with Image=wmic.exe, CommandLine containing 'logicaldisk' and 'VolumeSerialNumber'. Security Event ID 4688 (if command line auditing enabled) with ProcessCommandLine showing the full query. WMI activity log in Microsoft-Windows-WMI-Activity/Operational.
- Test 2Machine GUID Registry Read via PowerShell (Environmental Key Seed Collection)
Expected signal: Sysmon Event ID 1: Process Create with Image=powershell.exe, CommandLine containing 'HKLM' and 'MachineGuid'. Sysmon Event ID 13 (RegistryValueSet) or equivalent registry read event in Microsoft-Windows-Security-Auditing if object access auditing is enabled. PowerShell ScriptBlock Log Event ID 4104 showing the full script.
- Test 3DPAPI Encrypt and Decrypt Simulation (APT41/InvisiMole Pattern)
Expected signal: Sysmon Event ID 1: Process Create with Image=powershell.exe, CommandLine containing 'ProtectedData', 'Protect', and 'Unprotect'. Sysmon Event ID 7 (ImageLoad): dpapi.dll and crypt32.dll loaded by powershell.exe. PowerShell ScriptBlock Log Event ID 4104 with the full ProtectedData usage. Microsoft-Windows-Crypto-DPAPI/Operational Event IDs 12288 and 12290 for protect/unprotect operations.
- Test 4Multi-Identifier Environmental Fingerprinting (Combined Key Material Collection)
Expected signal: Sysmon Event ID 1: Process Create with Image=powershell.exe, CommandLine containing 'Win32_LogicalDisk', 'VolumeSerialNumber', 'MachineGuid', and 'Win32_ComputerSystem'. PowerShell ScriptBlock Log Event ID 4104 with full multi-identifier collection script. Registry read events for MachineGuid. WMI activity events for both WMI object queries.
References (10)
- https://attack.mitre.org/techniques/T1480/001/
- https://media.kasperskycontenthub.com/wp-content/uploads/sites/43/2018/03/20134940/kaspersky-lab-gauss.pdf
- https://github.com/Genetic-Malware/Ebowla/blob/master/Eko_2016_Morrow_Pitts_Master.pdf
- https://www.proofpoint.com/us/threat-insight/post/home-routers-under-attack-malvertising-windows-android-devices
- https://www.schneier.com/academic/paperfiles/paper-clueless-agents.pdf
- https://github.com/nccgroup/demiguise/blob/master/examples/virginkey.js
- https://learn.microsoft.com/en-us/windows/win32/api/dpapi/nf-dpapi-cryptprotectdata
- https://learn.microsoft.com/en-us/dotnet/api/system.security.cryptography.protecteddata
- https://learn.microsoft.com/en-us/defender-endpoint/advanced-hunting-deviceregistryevents-table
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1480.001/T1480.001.md
Unlock Pro Content
Get the full detection package for T1480.001 including response playbook, investigation guide, and atomic red team tests.