Environmental Keying
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.
// T1480.001 — Environmental Keying
// Detects hardware fingerprinting behaviors (WMI serial queries, MachineGuid reads, DPAPI abuse)
// that are characteristic of payload key derivation before environmentally-keyed execution.
let SuspiciousCallers = dynamic([
"wscript.exe", "cscript.exe", "mshta.exe", "regsvr32.exe",
"rundll32.exe", "msiexec.exe", "wmic.exe", "certutil.exe"
]);
let HwFingerprintTerms = dynamic([
"Win32_DiskDrive", "Win32_LogicalDisk", "Win32_Volume",
"SerialNumber", "VolumeSerialNumber", "GetVolumeInformation",
"Win32_ComputerSystemProduct", "UUID", "IdentifyingNumber"
]);
// Branch 1: WMI or WMIC queries for hardware serial numbers from suspicious or script-host processes
let WmiHardwareFingerprint = DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName in~ (SuspiciousCallers)
or (FileName in~ ("powershell.exe", "pwsh.exe") and ProcessCommandLine has_any ("Get-WmiObject", "Get-CimInstance", "gwmi", "gcim", "wmic"))
| where ProcessCommandLine has_any (HwFingerprintTerms)
| extend DetectionMethod = "WMI_Hardware_Serial_Query"
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
InitiatingProcessFileName, InitiatingProcessCommandLine, DetectionMethod;
// Branch 2: Registry reads of MachineGuid or ProductId by non-system processes
// (used to derive unique per-machine decryption keys)
let RegistryMachineIdRead = DeviceRegistryEvents
| where Timestamp > ago(24h)
| where RegistryKey has_any (
"SOFTWARE\\Microsoft\\Cryptography",
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"
)
| where RegistryValueName in~ ("MachineGuid", "ProductId", "InstallDate", "DigitalProductId")
| where ActionType =~ "RegistryValueQueried"
| where InitiatingProcessFileName !in~ (
"svchost.exe", "WmiPrvSE.exe", "lsass.exe", "SearchIndexer.exe",
"MsMpEng.exe", "SgrmBroker.exe", "spoolsv.exe", "services.exe",
"RuntimeBroker.exe", "taskhostw.exe"
)
| extend DetectionMethod = "Registry_MachineID_Queried"
| project Timestamp, DeviceName,
AccountName = InitiatingProcessAccountName,
FileName = InitiatingProcessFileName,
ProcessCommandLine = InitiatingProcessCommandLine,
InitiatingProcessFileName = InitiatingProcessParentFileName,
InitiatingProcessCommandLine = InitiatingProcessParentCommandLine,
DetectionMethod;
// Branch 3: DPAPI usage via PowerShell — APT41/InvisiMole pattern
// where payload is bound to specific machine/user using Windows DPAPI
let DpapiPowerShell = DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName in~ ("powershell.exe", "pwsh.exe")
| where ProcessCommandLine has_any (
"CryptProtectData", "CryptUnprotectData", "ProtectedData",
"System.Security.Cryptography.ProtectedData",
"Unprotect(", "[dpapi]", "DPAPI"
)
| extend DetectionMethod = "DPAPI_PowerShell_Keying"
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
InitiatingProcessFileName, InitiatingProcessCommandLine, DetectionMethod;
// Branch 4: wmic.exe querying BIOS, baseboard, or computersystem UUIDs
let WmicUuidQuery = DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName =~ "wmic.exe"
| where ProcessCommandLine has_any (
"bios", "baseboard", "csproduct", "computersystemproduct",
"uuid", "serialnumber", "identifyingnumber"
)
| extend DetectionMethod = "WMIC_UUID_Serial_Enum"
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
InitiatingProcessFileName, InitiatingProcessCommandLine, DetectionMethod;
union WmiHardwareFingerprint, RegistryMachineIdRead, DpapiPowerShell, WmicUuidQuery
| sort by Timestamp desc Data Sources
Required Tables
False Positives
- Software licensing and activation systems that read MachineGuid or volume serial numbers to generate per-seat license keys (e.g., Adobe, Microsoft Office, AutoCAD)
- Hardware inventory and asset management tools (SCCM hardware inventory, Lansweeper, Tanium, Qualys) that enumerate WMI hardware properties including serial numbers and UUIDs
- Telemetry and diagnostics agents that read machine identifiers to correlate crash reports or usage data with specific devices
- Backup software and encryption tools (BitLocker, VeraCrypt) that use machine-specific identifiers for key escrow or binding
- IT deployment scripts that use machine GUIDs for unique endpoint identification in device registration workflows
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.