Linux Restricted Shell Breakout via env Shell Evasion

Identifies Linux binary env abuse to break out from restricted environments by spawning an interactive system shell. The env utility is a shell command for Unix-like operating systems and is used to print a list of environment variables. The activity of spawning a shell is not a standard use of this binary for 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/02/24"
 3deprecation_date = "2022/05/09"
 4maturity = "deprecated"
 5updated_date = "2022/05/09"
 6
 7[rule]
 8author = ["Elastic"]
 9description = """
10Identifies Linux binary env abuse to break out from restricted environments by spawning an interactive system shell. The
11env utility is a shell command for Unix-like operating systems and is used to print a list of environment variables. The
12activity of spawning a shell is not a standard use of this binary for a user or system administrator. It indicates a
13potentially malicious 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 env Shell Evasion"
20references = ["https://gtfobins.github.io/gtfobins/env/"]
21risk_score = 47
22rule_id = "72d33577-f155-457d-aad3-379f9b750c97"
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.name : "env" and process.args_count == 2 and process.args : ("/bin/sh", "/bin/bash", "sh", "bash")
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