Potential Shell via Wildcard Injection Detected
This rule monitors for the execution of a set of linux binaries, that are potentially vulnerable to wildcard injection, with suspicious command line flags followed by a shell spawn event. Linux wildcard injection is a type of security vulnerability where attackers manipulate commands or input containing wildcards (e.g., *, ?, []) to execute unintended operations or access sensitive data by tricking the system into interpreting the wildcard characters in unexpected ways.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2023/07/28"
3integration = ["endpoint", "sentinel_one_cloud_funnel"]
4maturity = "production"
5min_stack_version = "8.13.0"
6min_stack_comments = "Breaking change at 8.13.0 for SentinelOne Integration."
7updated_date = "2025/01/15"
8
9[rule]
10author = ["Elastic"]
11description = """
12This rule monitors for the execution of a set of linux binaries, that are potentially vulnerable to wildcard injection,
13with suspicious command line flags followed by a shell spawn event. Linux wildcard injection is a type of security
14vulnerability where attackers manipulate commands or input containing wildcards (e.g., *, ?, []) to execute unintended
15operations or access sensitive data by tricking the system into interpreting the wildcard characters in unexpected ways.
16"""
17from = "now-9m"
18index = ["logs-endpoint.events.*", "logs-sentinel_one_cloud_funnel.*"]
19language = "eql"
20license = "Elastic License v2"
21name = "Potential Shell via Wildcard Injection Detected"
22references = ["https://www.exploit-db.com/papers/33930"]
23risk_score = 47
24rule_id = "0b803267-74c5-444d-ae29-32b5db2d562a"
25setup = """## Setup
26
27This rule requires data coming in from Elastic Defend.
28
29### Elastic Defend Integration Setup
30Elastic 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.
31
32#### Prerequisite Requirements:
33- Fleet is required for Elastic Defend.
34- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
35
36#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
37- Go to the Kibana home page and click "Add integrations".
38- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
39- Click "Add Elastic Defend".
40- Configure the integration name and optionally add a description.
41- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
42- 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).
43- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
44- 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.
45For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
46- Click "Save and Continue".
47- 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.
48For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
49"""
50severity = "medium"
51tags = [
52 "Domain: Endpoint",
53 "OS: Linux",
54 "Use Case: Threat Detection",
55 "Tactic: Privilege Escalation",
56 "Tactic: Execution",
57 "Data Source: Elastic Defend",
58 "Data Source: SentinelOne",
59 "Resources: Investigation Guide",
60]
61type = "eql"
62
63query = '''
64sequence by host.id with maxspan=1s
65 [process where host.os.type == "linux" and event.type == "start" and event.action in ("exec", "start") and (
66 (process.name == "tar" and process.args : "--checkpoint=*" and process.args : "--checkpoint-action=*") or
67 (process.name == "rsync" and process.args : "-e*") or
68 (process.name == "zip" and process.args == "--unzip-command")
69 ) and not process.executable : "/tmp/newroot/*"
70 ] by process.entity_id
71 [process where host.os.type == "linux" and event.type == "start" and event.action in ("exec", "start") and
72 process.parent.name : ("tar", "rsync", "zip") and
73 process.name : ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish")
74 ] by process.parent.entity_id
75'''
76note = """## Triage and analysis
77
78> **Disclaimer**:
79> This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.
80
81### Investigating Potential Shell via Wildcard Injection Detected
82
83Wildcard injection exploits vulnerabilities in Linux command-line utilities by manipulating wildcard characters to execute unauthorized commands. Adversaries leverage this to escalate privileges or execute arbitrary code. The detection rule identifies suspicious use of vulnerable binaries like `tar`, `rsync`, and `zip` followed by shell execution, indicating potential exploitation attempts.
84
85### Possible investigation steps
86
87- Review the process details to identify the specific command executed, focusing on the process name and arguments, especially those involving `tar`, `rsync`, or `zip` with suspicious flags like `--checkpoint=*`, `-e*`, or `--unzip-command`.
88- Examine the parent process information to determine if a shell process (e.g., `bash`, `sh`, `zsh`) was spawned, indicating potential exploitation.
89- Check the process execution path to ensure it does not match the exclusion pattern `/tmp/newroot/*`, which might indicate a benign operation.
90- Investigate the host's recent activity logs to identify any other suspicious or related events that might indicate a broader attack or compromise.
91- Correlate the alert with any other security events or alerts from the same host to assess if this is part of a larger attack pattern or campaign.
92- Assess the user account associated with the process execution to determine if it has the necessary privileges and if the activity aligns with expected behavior for that account.
93
94### False positive analysis
95
96- Legitimate use of tar, rsync, or zip with wildcard-related flags in automated scripts or backup processes can trigger false positives. Review the context of these processes and consider excluding specific scripts or directories from monitoring if they are verified as safe.
97- System administrators or maintenance scripts may use shell commands following tar, rsync, or zip for legitimate purposes. Identify these routine operations and create exceptions for known safe parent processes or specific command patterns.
98- Development environments or testing scenarios might involve intentional use of wildcard characters for testing purposes. Exclude these environments from the rule or adjust the rule to ignore specific user accounts or process paths associated with development activities.
99- Scheduled tasks or cron jobs that involve the use of these binaries with wildcard flags can be mistaken for malicious activity. Verify the legitimacy of these tasks and exclude them based on their schedule or specific command line arguments.
100- Security tools or monitoring solutions that simulate attacks for testing or validation purposes might trigger this rule. Ensure these tools are recognized and excluded from monitoring to prevent unnecessary alerts.
101
102### Response and remediation
103
104- Immediately isolate the affected host from the network to prevent further unauthorized access or lateral movement.
105- Terminate any suspicious processes identified in the alert, particularly those involving the execution of shell commands following the use of `tar`, `rsync`, or `zip`.
106- Conduct a thorough review of the affected system's logs to identify any additional indicators of compromise or unauthorized access attempts.
107- Restore the affected system from a known good backup if any unauthorized changes or malicious activities are confirmed.
108- Apply security patches and updates to the affected system to address any vulnerabilities that may have been exploited.
109- Implement file integrity monitoring on critical systems to detect unauthorized changes to system binaries or configuration files.
110- Escalate the incident to the security operations team for further investigation and to assess the potential impact on other systems within the network."""
111
112[[rule.threat]]
113framework = "MITRE ATT&CK"
114
115[[rule.threat.technique]]
116id = "T1068"
117name = "Exploitation for Privilege Escalation"
118reference = "https://attack.mitre.org/techniques/T1068/"
119
120[rule.threat.tactic]
121id = "TA0004"
122name = "Privilege Escalation"
123reference = "https://attack.mitre.org/tactics/TA0004/"
124
125[[rule.threat]]
126framework = "MITRE ATT&CK"
127
128[[rule.threat.technique]]
129id = "T1059"
130name = "Command and Scripting Interpreter"
131reference = "https://attack.mitre.org/techniques/T1059/"
132
133[rule.threat.tactic]
134id = "TA0002"
135name = "Execution"
136reference = "https://attack.mitre.org/tactics/TA0002/"
Triage and analysis
Disclaimer: This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.
Investigating Potential Shell via Wildcard Injection Detected
Wildcard injection exploits vulnerabilities in Linux command-line utilities by manipulating wildcard characters to execute unauthorized commands. Adversaries leverage this to escalate privileges or execute arbitrary code. The detection rule identifies suspicious use of vulnerable binaries like tar
, rsync
, and zip
followed by shell execution, indicating potential exploitation attempts.
Possible investigation steps
- Review the process details to identify the specific command executed, focusing on the process name and arguments, especially those involving
tar
,rsync
, orzip
with suspicious flags like--checkpoint=*
,-e*
, or--unzip-command
. - Examine the parent process information to determine if a shell process (e.g.,
bash
,sh
,zsh
) was spawned, indicating potential exploitation. - Check the process execution path to ensure it does not match the exclusion pattern
/tmp/newroot/*
, which might indicate a benign operation. - Investigate the host's recent activity logs to identify any other suspicious or related events that might indicate a broader attack or compromise.
- Correlate the alert with any other security events or alerts from the same host to assess if this is part of a larger attack pattern or campaign.
- Assess the user account associated with the process execution to determine if it has the necessary privileges and if the activity aligns with expected behavior for that account.
False positive analysis
- Legitimate use of tar, rsync, or zip with wildcard-related flags in automated scripts or backup processes can trigger false positives. Review the context of these processes and consider excluding specific scripts or directories from monitoring if they are verified as safe.
- System administrators or maintenance scripts may use shell commands following tar, rsync, or zip for legitimate purposes. Identify these routine operations and create exceptions for known safe parent processes or specific command patterns.
- Development environments or testing scenarios might involve intentional use of wildcard characters for testing purposes. Exclude these environments from the rule or adjust the rule to ignore specific user accounts or process paths associated with development activities.
- Scheduled tasks or cron jobs that involve the use of these binaries with wildcard flags can be mistaken for malicious activity. Verify the legitimacy of these tasks and exclude them based on their schedule or specific command line arguments.
- Security tools or monitoring solutions that simulate attacks for testing or validation purposes might trigger this rule. Ensure these tools are recognized and excluded from monitoring to prevent unnecessary alerts.
Response and remediation
- Immediately isolate the affected host from the network to prevent further unauthorized access or lateral movement.
- Terminate any suspicious processes identified in the alert, particularly those involving the execution of shell commands following the use of
tar
,rsync
, orzip
. - Conduct a thorough review of the affected system's logs to identify any additional indicators of compromise or unauthorized access attempts.
- Restore the affected system from a known good backup if any unauthorized changes or malicious activities are confirmed.
- Apply security patches and updates to the affected system to address any vulnerabilities that may have been exploited.
- Implement file integrity monitoring on critical systems to detect unauthorized changes to system binaries or configuration files.
- Escalate the incident to the security operations team for further investigation and to assess the potential impact on other systems within the network.
References
Related rules
- At Job Created or Modified
- BPF filter applied using TC
- Cron Job Created or Modified
- Cupsd or Foomatic-rip Shell Execution
- Dynamic Linker (ld.so) Creation