Skip to content
Threat Feed
medium advisory

Detection of Malicious Process Execution from Windows Temporary Directories

Adversaries frequently abuse the Windows %temp% directory to execute malicious payloads, including droppers and RATs, to evade security controls and achieve persistence without requiring administrative privileges.

Adversaries leverage the Windows temporary directory (%temp%) as a common staging ground for executing malicious code. Because this directory is writable by low-privileged users, it allows attackers to bypass security restrictions that might prevent execution from system-protected folders. This technique is observed across a broad spectrum of malware, including ransomware such as Ryuk and various remote access trojans (RATs) like AsyncRAT, AgentTesla, and NjRAT. Defenders should monitor for binary execution originating from this specific path as a high-fidelity signal of potential compromise. When identified, this behavior often precedes secondary stages of an attack chain, such as payload delivery, system discovery, or credential theft. The technique is frequently associated with defense evasion and masquerading, as malicious binaries attempt to blend in with legitimate temporary files generated by applications and update processes.

Attack Chain

  1. Initial access is established through phishing or exploitation of a public-facing application.
  2. The threat actor drops a malicious downloader or dropper into a temporary user directory (e.g., %temp%).
  3. The adversary executes the dropper to initiate the second stage of the attack.
  4. The process spawns from the %temp% folder, attempting to avoid detection by security solutions monitoring standard program directories.
  5. The malicious binary initiates C2 communication to download secondary payloads or additional modules.
  6. The adversary establishes persistence by modifying registry keys or creating scheduled tasks.
  7. Final objectives, such as data exfiltration or ransomware encryption, are executed on the compromised host.

Impact

Execution from the temporary directory is a precursor to system compromise, data theft, and ransomware deployment. Failure to detect this activity can lead to a full network breach, loss of intellectual property, and significant downtime. Observed campaigns involving this technique include the targeting of critical infrastructure by advanced actors and widespread automated malware distribution.

Recommendation

  1. Enable Sysmon (Event ID 1) or Windows Security Log (Event ID 4688) on all endpoints to capture process creation events, specifically including the 'process_path' and 'original_file_name' fields.
  2. Implement the Sigma rule below to flag process creation where the binary image path contains the string 'temp'.
  3. Establish an allowlist for known legitimate applications that are required to execute from temporary directories and tune out these processes to reduce noise.
  4. Integrate EDR telemetry into a centralized SIEM and map the data to the Endpoint 'Processes' data model as per the CIM specification.
  5. Conduct routine hunting for parent processes spawning binaries within the temp directory to identify unusual execution patterns or anomalous parent-child relationships.

Immediate actions

Deploy Sigma detection rule to environment to monitor for temp directory executions.

Detection Engineering 48h

Threat Hunt

Identify all parent processes that spawn children within %temp% directory paths.

T1036.005 high high confidence hunt now

Data: Process creation events (Event ID 1)

Mitigations

Enforce software restriction policies to limit execution from user-writable directories.

medium_term IT Operations

T1036.005

Detection coverage 1

Detect Process Execution from Windows Temporary Directory

medium

Detects processes running from within the %temp% directory, a common technique for defense evasion and malicious payload execution.

sigma tactics: defense_evasion, execution techniques: T1036.005 sources: process_creation, windows

Detection queries are available on the platform. Get full rules →