Detect Environmental Keying in Google Chronicle
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/
YARA-L Detection Query
rule t1480_001_environmental_keying {
meta:
author = "Argus Detection Engineering"
description = "Detects T1480.001 Environmental Keying — hardware fingerprinting via WMI serial queries, registry MachineGuid reads, DPAPI PowerShell abuse, and wmic UUID enumeration used for payload key derivation."
mitre_attack_tactic = "Defense Evasion"
mitre_attack_technique = "T1480.001"
severity = "HIGH"
confidence = "MEDIUM"
created = "2026-04-13"
events:
(
// Branch 1: WMI hardware serial query via suspicious caller or PowerShell
$e1.metadata.event_type = "PROCESS_LAUNCH"
and (
re.regex($e1.principal.process.file.full_path, `(?i)(wscript\.exe|cscript\.exe|mshta\.exe|regsvr32\.exe|rundll32\.exe|msiexec\.exe|certutil\.exe|wmic\.exe|powershell\.exe|pwsh\.exe)$`)
)
and re.regex($e1.target.process.command_line, `(?i)(Win32_DiskDrive|Win32_LogicalDisk|Win32_Volume|SerialNumber|VolumeSerialNumber|Win32_ComputerSystemProduct|UUID|IdentifyingNumber)`)
)
or
(
// Branch 2: wmic UUID/serial enumeration
$e1.metadata.event_type = "PROCESS_LAUNCH"
and re.regex($e1.target.process.file.full_path, `(?i)wmic\.exe$`)
and re.regex($e1.target.process.command_line, `(?i)(bios|baseboard|csproduct|computersystemproduct|uuid|serialnumber|identifyingnumber)`)
)
or
(
// Branch 3: Registry MachineGuid/ProductId read by non-system process
$e1.metadata.event_type = "REGISTRY_READ"
and re.regex($e1.target.registry.registry_key, `(?i)(Microsoft\\Cryptography.*MachineGuid|Windows NT\\CurrentVersion.*(ProductId|DigitalProductId))`)
and not re.regex($e1.principal.process.file.full_path, `(?i)(svchost\.exe|WmiPrvSE\.exe|lsass\.exe|SearchIndexer\.exe|MsMpEng\.exe|SgrmBroker\.exe|spoolsv\.exe|services\.exe|RuntimeBroker\.exe|taskhostw\.exe)$`)
)
or
(
// Branch 4: DPAPI PowerShell keying
$e1.metadata.event_type = "PROCESS_LAUNCH"
and re.regex($e1.target.process.file.full_path, `(?i)(powershell\.exe|pwsh\.exe)$`)
and re.regex($e1.target.process.command_line, `(?i)(CryptProtectData|CryptUnprotectData|ProtectedData|System\.Security\.Cryptography\.ProtectedData|Unprotect\(|\[dpapi\]|DPAPI)`)
)
condition:
$e1 Chronicle YARA-L 2.0 rule for T1480.001 Environmental Keying, detecting hardware fingerprinting behaviors across four branches: WMI hardware serial queries by suspicious callers, wmic UUID/serial enumeration, registry MachineGuid/ProductId access by non-system processes, and DPAPI PowerShell abuse indicative of environmentally-keyed payload key derivation.
Data Sources
Required Tables
False Positives & Tuning
- Asset management or inventory tools performing WMI hardware queries for CMDB population
- Software licensing systems that bind licenses to hardware serials via MachineGuid reads
- PowerShell runbooks in automation pipelines using ProtectedData for credential management
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.