Linux Restricted Shell Breakout via flock Shell evasion

Identifies Linux binary flock abuse to break out from restricted environments by spawning an interactive system shell. The flock utility allows users to manage advisory file locks in shell scripts or on the command line. The activity of spawning a shell is not a standard use of this binary by a user or system administrator. It indicates a potentially malicious actor attempting to improve the capabilities or stability of their access.

Elastic rule (View on GitHub)

 1[metadata]
 2creation_date = "2022/03/22"
 3deprecation_date = "2022/05/09"
 4maturity = "deprecated"
 5updated_date = "2022/05/09"
 6
 7[rule]
 8author = ["Elastic"]
 9description = """
10Identifies Linux binary flock abuse to break out from restricted environments by spawning an interactive system shell.
11The flock utility allows users to manage advisory file locks in shell scripts or on the command line. The activity of
12spawning a shell is not a standard use of this binary by a user or system administrator. It indicates a potentially
13malicious actor attempting to improve the capabilities or stability of their access.
14"""
15from = "now-9m"
16index = ["logs-endpoint.events.*"]
17language = "eql"
18license = "Elastic License v2"
19name = "Linux Restricted Shell Breakout via flock Shell evasion"
20references = ["https://gtfobins.github.io/gtfobins/flock/"]
21risk_score = 47
22rule_id = "f52362cd-baf1-4b6d-84be-064efc826461"
23severity = "medium"
24tags = ["Elastic", "Host", "Linux", "Threat Detection", "Execution", "GTFOBins"]
25timestamp_override = "event.ingested"
26type = "eql"
27
28query = '''
29process where event.type == "start" and process.parent.name == "flock" and process.parent.args == "-u" and process.parent.args == "/" and process.parent.args in ("/bin/sh", "/bin/bash", "/bin/dash", "sh", "bash", "dash") and process.name in ("bash", "dash", "sh")
30'''
31
32
33[[rule.threat]]
34framework = "MITRE ATT&CK"
35[[rule.threat.technique]]
36id = "T1059"
37name = "Command and Scripting Interpreter"
38reference = "https://attack.mitre.org/techniques/T1059/"
39[[rule.threat.technique.subtechnique]]
40id = "T1059.004"
41name = "Unix Shell"
42reference = "https://attack.mitre.org/techniques/T1059/004/"
43
44
45
46[rule.threat.tactic]
47id = "TA0002"
48name = "Execution"
49reference = "https://attack.mitre.org/tactics/TA0002/"

References

Related rules

to-top