Process Started from Process ID (PID) File

Identifies a new process starting from a process ID (PID), lock or reboot file within the temporary file storage paradigm (tmpfs) directory /var/run directory. On Linux, the PID files typically hold the process ID to track previous copies running and manage other tasks. Certain Linux malware use the /var/run directory for holding data, executables and other tasks, disguising itself or these files as legitimate PID files.

Elastic rule (View on GitHub)

 1[metadata]
 2creation_date = "2022/05/11"
 3integration = ["endpoint", "auditd_manager"]
 4maturity = "production"
 5min_stack_comments = "New fields added: required_fields, related_integrations, setup"
 6min_stack_version = "8.3.0"
 7updated_date = "2024/02/20"
 8
 9[rule]
10author = ["Elastic"]
11description = """
12Identifies a new process starting from a process ID (PID), lock or reboot file within the temporary file storage
13paradigm (tmpfs) directory /var/run directory. On Linux, the PID files typically hold the process ID to track previous
14copies running and manage other tasks. Certain Linux malware use the /var/run directory for holding data, executables
15and other tasks, disguising itself or these files as legitimate PID files.
16"""
17false_positives = [
18    """
19    False-Positives (FP) should be at a minimum with this detection as PID files are meant to hold process IDs, not
20    inherently be executables that spawn processes.
21    """,
22]
23from = "now-9m"
24index = ["logs-endpoint.events.*", "endgame-*", "auditbeat-*", "logs-auditd_manager.auditd-*"]
25language = "eql"
26license = "Elastic License v2"
27name = "Process Started from Process ID (PID) File"
28note = """## Triage and analysis
29
30### Investigating Process Started from Process ID (PID) File
31Detection alerts from this rule indicate a process spawned from an executable masqueraded as a legitimate PID file which is very unusual and should not occur. Here are some possible avenues of investigation:
32- Examine parent and child process relationships of the new process to determine if other processes are running.
33- Examine the /var/run directory using Osquery to determine other potential PID files with unsually large file sizes, indicative of it being an executable: "SELECT f.size, f.uid, f.type, f.path from file f WHERE path like '/var/run/%%';"
34- Examine the reputation of the SHA256 hash from the PID file in a database like VirusTotal to identify additional pivots and artifacts for investigation.
35"""
36references = [
37    "https://www.sandflysecurity.com/blog/linux-file-masquerading-and-malicious-pids-sandfly-1-2-6-update/",
38    "https://twitter.com/GossiTheDog/status/1522964028284411907",
39    "https://exatrack.com/public/Tricephalic_Hellkeeper.pdf",
40    "https://www.elastic.co/security-labs/a-peek-behind-the-bpfdoor",
41]
42risk_score = 73
43rule_id = "3688577a-d196-11ec-90b0-f661ea17fbce"
44setup = """## Setup
45
46This rule requires data coming in from Elastic Defend.
47
48### Elastic Defend Integration Setup
49Elastic Defend is integrated into the Elastic Agent using Fleet. Upon configuration, the integration allows the Elastic Agent to monitor events on your host and send data to the Elastic Security app.
50
51#### Prerequisite Requirements:
52- Fleet is required for Elastic Defend.
53- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
54
55#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
56- Go to the Kibana home page and click "Add integrations".
57- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
58- Click "Add Elastic Defend".
59- Configure the integration name and optionally add a description.
60- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
61- Select a configuration preset. Each preset comes with different default settings for Elastic Agent, you can further customize these later by configuring the Elastic Defend integration policy. [Helper guide](https://www.elastic.co/guide/en/security/current/configure-endpoint-integration-policy.html).
62- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
63- Enter a name for the agent policy in "New agent policy name". If other agent policies already exist, you can click the "Existing hosts" tab and select an existing policy instead.
64For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
65- Click "Save and Continue".
66- To complete the integration, select "Add Elastic Agent to your hosts" and continue to the next section to install the Elastic Agent on your hosts.
67For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
68"""
69severity = "high"
70tags = [
71        "Domain: Endpoint",
72        "OS: Linux",
73        "Use Case: Threat Detection",
74        "Tactic: Execution",
75        "Threat: BPFDoor",
76        "Data Source: Elastic Endgame",
77        "Data Source: Elastic Defend",
78        "Data Source: Auditd Manager"
79        ]
80timestamp_override = "event.ingested"
81type = "eql"
82
83query = '''
84process where host.os.type == "linux" and event.type == "start" and user.id == "0" and
85  process.executable regex~ """/var/run/\w+\.(pid|lock|reboot)"""
86'''
87
88[[rule.threat]]
89framework = "MITRE ATT&CK"
90
91[[rule.threat.technique]]
92id = "T1059"
93name = "Command and Scripting Interpreter"
94reference = "https://attack.mitre.org/techniques/T1059/"
95
96[rule.threat.tactic]
97id = "TA0002"
98name = "Execution"
99reference = "https://attack.mitre.org/tactics/TA0002/"

Triage and analysis

Investigating Process Started from Process ID (PID) File

Detection alerts from this rule indicate a process spawned from an executable masqueraded as a legitimate PID file which is very unusual and should not occur. Here are some possible avenues of investigation:

  • Examine parent and child process relationships of the new process to determine if other processes are running.
  • Examine the /var/run directory using Osquery to determine other potential PID files with unsually large file sizes, indicative of it being an executable: "SELECT f.size, f.uid, f.type, f.path from file f WHERE path like '/var/run/%%';"
  • Examine the reputation of the SHA256 hash from the PID file in a database like VirusTotal to identify additional pivots and artifacts for investigation.

References

Related rules

to-top