|
| 1 | +[metadata] |
| 2 | +creation_date = "2022/05/11" |
| 3 | +maturity = "production" |
| 4 | +updated_date = "2022/05/12" |
| 5 | + |
| 6 | +[rule] |
| 7 | +author = ["Elastic"] |
| 8 | +description = """ |
| 9 | +Identifies the creation of a Process ID (PID), lock or reboot file created in temporary file storage paradigm (tmpfs) |
| 10 | +directory /var/run. On Linux, the PID files typically hold the process ID to track previous copies running and manage |
| 11 | +other tasks. Certain Linux malware use the /var/run directory for holding data, executables and other tasks, disguising |
| 12 | +itself or these files as legitimate PID files. |
| 13 | +""" |
| 14 | +false_positives = [ |
| 15 | + """ |
| 16 | + False-Positives (FP) can appear if the PID file is legitimate and holding a process ID as intended. To |
| 17 | + differentiate, if the PID file is an executable or larger than 10 bytes, it should be ruled suspicious. |
| 18 | + """, |
| 19 | +] |
| 20 | +from = "now-9m" |
| 21 | +index = ["logs-endpoint.events.*"] |
| 22 | +language = "eql" |
| 23 | +license = "Elastic License v2" |
| 24 | +name = "Abnormal Process ID or Lock File Created" |
| 25 | +note = """## Triage and analysis |
| 26 | +
|
| 27 | +### Investigating Abnormal Process ID or Lock File Created |
| 28 | +Detection alerts from this rule indicate that an unusual PID file was created and could potentially have alternate purposes during an intrusion. Here are some possible avenues of investigation: |
| 29 | +- Run the following in Osquery to quickly identify unsual PID file size: "SELECT f.size, f.uid, f.type, f.path from file f WHERE path like '/var/run/%pid';" |
| 30 | +- Examine the history of this file creation and from which process it was created by using the "lsof" command. |
| 31 | +- Examine the contents of the PID file itself, simply by running the "cat" command to determine if the expected process ID integer exists and if not, the PID file is not legitimate. |
| 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 | +references = [ |
| 34 | + "https://www.sandflysecurity.com/blog/linux-file-masquerading-and-malicious-pids-sandfly-1-2-6-update/", |
| 35 | + "https://twitter.com/GossiTheDog/status/1522964028284411907", |
| 36 | + "https://exatrack.com/public/Tricephalic_Hellkeeper.pdf", |
| 37 | +] |
| 38 | +risk_score = 43 |
| 39 | +rule_id = "cac91072-d165-11ec-a764-f661ea17fbce" |
| 40 | +severity = "medium" |
| 41 | +tags = ["Elastic", "Host", "Linux", "Threat Detection", "Execution", "BPFDoor"] |
| 42 | +timestamp_override = "event.ingested" |
| 43 | +type = "eql" |
| 44 | + |
| 45 | +query = ''' |
| 46 | +/* add file size filters when data is available */ |
| 47 | +file where event.type == "creation" and user.id == "0" and |
| 48 | + file.path regex~ """/var/run/\w+\.(pid|lock|reboot)""" and file.extension in ("pid","lock","reboot") and |
| 49 | +
|
| 50 | + /* handle common legitimate files */ |
| 51 | +
|
| 52 | + not file.name in ( |
| 53 | + "auditd.pid", |
| 54 | + "python*", |
| 55 | + "apport.pid", |
| 56 | + "apport.lock", |
| 57 | + "kworker*", |
| 58 | + "gdm3.pid", |
| 59 | + "sshd.pid", |
| 60 | + "acpid.pid", |
| 61 | + "unattended-upgrades.lock", |
| 62 | + "unattended-upgrades.pid", |
| 63 | + "cmd.pid", |
| 64 | + "cron*.pid" |
| 65 | + ) |
| 66 | +''' |
| 67 | + |
| 68 | + |
| 69 | +[[rule.threat]] |
| 70 | +framework = "MITRE ATT&CK" |
| 71 | +[[rule.threat.technique]] |
| 72 | +id = "T1106" |
| 73 | +name = "Native API" |
| 74 | +reference = "https://attack.mitre.org/techniques/T1106/" |
| 75 | + |
| 76 | + |
| 77 | +[rule.threat.tactic] |
| 78 | +id = "TA0002" |
| 79 | +name = "Execution" |
| 80 | +reference = "https://attack.mitre.org/tactics/TA0002/" |
| 81 | + |
0 commit comments