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