Detect it by alerting on executables, scripts, or dropped payloads launched from /tmp, especially when they are newly created or have random names. Correlate execution with downloads, archive extraction, and permission changes. Since /tmp is writable by many users, prioritise binaries running with elevated privileges or as unusual service accounts.
What makes /tmp execution suspicious on Linux?
Execution from /tmp is suspicious because that directory is typically writable and transient, so it is a common place for dropped payloads, staging files, and short-lived scripts. The signal is strongest when the file was created moments before execution, has a random or misleading name, or was launched by a process that would not normally use /tmp for code.
Good detection logic treats /tmp as a context signal, not a verdict by itself. Legitimate software can use temporary storage, so the key is to combine pathname, freshness, file type, parent process, user context, and privilege level before you decide whether the event is benign or malicious.
Which execution patterns deserve the most attention?
The highest-value detections focus on binaries, shell scripts, or interpreted payloads started directly from /tmp, especially when the file appears shortly before process start or has execute permissions added immediately beforehand. That pattern often indicates download-and-run tradecraft, archive extraction, or a staged dropper rather than normal application behaviour. Correlation with command lines, child processes, and network activity helps separate one-off admin work from an intrusion path.
Also watch for execution paths that blend in through symbolic links, copied filenames, or renamed files under temporary directories. Attackers often try to make the process tree look ordinary, so a useful rule looks beyond the pathname alone and asks whether the parent process, user session, and execution timing make sense for the host.
How should you reduce false positives while keeping coverage high?
Start by baselining the hosts and user groups that legitimately execute from temporary locations, then carve out those known behaviours before you turn on broad alerting. On Linux, there is a practical difference between a developer workstation, a build system, and a production server, so the same /tmp execution event may carry very different meaning depending on the asset role.
For stronger triage, check whether the file was created by a downloader, archive utility, browser, or scripting interpreter; whether it was made executable; and whether it immediately spawned a network connection or credential-access activity. Those relationships are more informative than filename patterns alone, and they help distinguish a temporary helper script from a staged payload.
Risk and Threat Considerations
Linux Detection and Response Guide is useful here because /tmp execution is a classic telemetry problem in Linux detection and response, not just a file-path heuristic. Suspicious execution often signals a dropped payload, privilege abuse, or a short-lived foothold that can disappear before manual review.
Failure mechanism: An attacker writes code to a writable temporary directory, flips permissions, and launches it before defenders notice. Because /tmp is noisy and expected to change frequently, weak monitoring can miss the chain from download to execution to follow-on activity.
Impact: Missed detection can let malware establish persistence, spawn lateral movement, or run with elevated privileges or under a service account that broadens blast radius. The consequence is not just execution in a temporary directory, but faster compromise progression and weaker forensic visibility.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
MITRE ATT&CK addresses the attack and risk surface, while NIST CSF 2.0, CIS Controls v8 and NIST SP 800-53 Rev 5 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| MITRE ATT&CK | T1059 — Command and Scripting Interpreter | Covers script and interpreter-driven execution from writable temp locations. |
| T1105 — Ingress Tool Transfer | Relevant when /tmp execution follows a download or staged payload transfer. | |
| Recommendation — Map /tmp-launched scripts to T1059 and hunt for parent-child process chains that indicate staged execution. Correlate downloads with temp-file creation and execution to detect staged payload delivery. | ||
| NIST CSF 2.0 | DE.CM-01 — Continuous Monitoring | Continuous monitoring is central to spotting abnormal temporary-directory execution on Linux hosts. |
| DE.AE-03 — Anomalous Activity Detected | Suspicious /tmp execution is an anomalous host activity pattern needing alerting and triage. | |
| Recommendation — Add detection coverage for executions originating from writable temporary directories. Flag process launches from /tmp when the timing, privilege, or parent process is unusual. | ||
| CIS Controls v8 | CIS-8 — Audit Log Management | File creation, permission changes, and process launches require log visibility for this detection. |
| Recommendation — Centralise Linux audit and process logs so temp-file execution chains are searchable. | ||
| NIST SP 800-53 Rev 5 | AU-12 — Audit Record Generation | This detection depends on generating records for file, process, and permission events. |
| SI-4 — System Monitoring | Monitoring host behaviour is the primary control for catching suspicious execution from /tmp. | |
| Recommendation — Enable audit generation for process starts, file writes, and permission changes in temp paths. Monitor Linux hosts for execution from writable temporary directories and alert on abnormal context. | ||
Practitioner Guidance
What to verify: Confirm whether the executable was newly created, whether execute bits changed immediately before launch, and whether the parent process makes sense for the host role. A good alert is one that ties file creation, permission change, and process start into a single story rather than treating each event separately.
Decision rule: If the process launched from /tmp is running as root, a privileged admin account, or an unusual service account, treat it as materially higher risk and escalate faster. That combination changes the question from “odd location” to “potentially high-impact code execution path.”
Practitioner takeaway: The most reliable detections combine ephemeral-file behaviour with execution context, because /tmp alone is only a weak signal, but /tmp plus fresh creation, permission change, and abnormal privilege is a strong compromise indicator.
Related resources from NHI Mgmt Group
Deepen Your Knowledge
Free weekly newsletter
Subscribe to the NHI & AI Identity Journal
The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.
Bonus 33% off our NHI Course when you subscribe.
Reviewed and updated by the NHIMG editorial team on October 20, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org