Linux User Account Credential Modification
This rule detects Linux user account credential modification events where the echo command is used to directly echo a password into the passwd utility. This technique is used by malware to automate the process of user account credential modification on Linux systems post-infection.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2025/02/21"
3integration = ["endpoint"]
4maturity = "production"
5updated_date = "2025/04/07"
6
7[rule]
8author = ["Elastic"]
9description = """
10This rule detects Linux user account credential modification events where the echo command is
11used to directly echo a password into the passwd utility. This technique is used by malware
12to automate the process of user account credential modification on Linux systems post-infection.
13"""
14from = "now-9m"
15index = ["logs-endpoint.events.process*"]
16language = "eql"
17license = "Elastic License v2"
18name = "Linux User Account Credential Modification"
19note = """ ## Triage and analysis
20
21> **Disclaimer**:
22> 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.
23
24### Investigating Linux User Account Credential Modification
25
26In Linux environments, user account credentials are crucial for system access and management. Adversaries may exploit command-line utilities to modify credentials, often using scripts to automate this process post-infection. The detection rule identifies suspicious use of shell commands that echo passwords into the passwd utility, a technique indicative of unauthorized credential changes, by monitoring specific command patterns and excluding benign processes.
27
28### Possible investigation steps
29
30- Review the process command line to confirm the presence of the suspicious pattern "*echo*passwd*" and assess if it aligns with known malicious activity.
31- Identify the user account associated with the process to determine if it is a legitimate user or potentially compromised.
32- Examine the parent process details, including the command line and executable path, to understand the context of how the suspicious process was initiated.
33- Check for any recent changes to user accounts on the system, focusing on password modifications or new account creations around the time of the alert.
34- Investigate the system for any additional signs of compromise, such as unexpected network connections or other suspicious processes running concurrently.
35- Correlate the event with other security alerts or logs to identify if this activity is part of a broader attack pattern or campaign.
36
37### False positive analysis
38
39- Automated build processes may trigger this rule if they use shell scripts that include echoing passwords for testing or configuration purposes. To handle this, exclude processes with parent command lines or executables related to build tools like make.
40- System administration scripts that automate user account management might use similar command patterns. Review these scripts and exclude them by specifying their parent process or executable paths.
41- Custom user scripts for password management could inadvertently match the rule's criteria. Identify these scripts and add exceptions based on their unique command line or parent process attributes.
42- Some legitimate software installations might use echo and passwd in their setup scripts. Monitor installation logs and exclude known safe installation processes by their parent command line or executable.
43
44### Response and remediation
45
46- Immediately isolate the affected Linux system from the network to prevent further unauthorized access or lateral movement by the adversary.
47- Terminate any suspicious processes identified by the detection rule, particularly those involving the echo command being used with the passwd utility.
48- Change the passwords of any user accounts that may have been compromised, ensuring the use of strong, unique passwords.
49- Review and audit recent user account changes and access logs to identify any unauthorized modifications or access attempts.
50- Restore any affected user accounts to their previous state using backups or system snapshots, if available.
51- Escalate the incident to the security operations team for further investigation and to determine if additional systems are affected.
52- Implement additional monitoring and alerting for similar command patterns to enhance detection and prevent recurrence of this threat.
53"""
54risk_score = 21
55rule_id = "79e7291f-9e3b-4a4b-9823-800daa89c8f9"
56setup = """## Setup
57This rule requires data coming in from Elastic Defend.
58### Elastic Defend Integration Setup
59Elastic 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.
60#### Prerequisite Requirements:
61- Fleet is required for Elastic Defend.
62- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
63#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
64- Go to the Kibana home page and click "Add integrations".
65- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
66- Click "Add Elastic Defend".
67- Configure the integration name and optionally add a description.
68- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
69- 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).
70- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
71- 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.
72For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
73- Click "Save and Continue".
74- 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.
75For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
76"""
77severity = "low"
78tags = [
79 "Domain: Endpoint",
80 "OS: Linux",
81 "Use Case: Threat Detection",
82 "Tactic: Persistence",
83 "Data Source: Elastic Defend",
84 "Resources: Investigation Guide",
85]
86timestamp_override = "event.ingested"
87type = "eql"
88query = '''
89process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and
90process.name in ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish") and
91process.command_line like~ "*echo*passwd*" and
92not (
93 process.parent.command_line == "runc init" or
94 process.parent.executable in ("/usr/bin/make", "/bin/make")
95)
96'''
97
98[[rule.threat]]
99framework = "MITRE ATT&CK"
100
101[[rule.threat.technique]]
102id = "T1098"
103name = "Account Manipulation"
104reference = "https://attack.mitre.org/techniques/T1098/"
105
106[rule.threat.tactic]
107id = "TA0003"
108name = "Persistence"
109reference = "https://attack.mitre.org/tactics/TA0003/"
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 Linux User Account Credential Modification
In Linux environments, user account credentials are crucial for system access and management. Adversaries may exploit command-line utilities to modify credentials, often using scripts to automate this process post-infection. The detection rule identifies suspicious use of shell commands that echo passwords into the passwd utility, a technique indicative of unauthorized credential changes, by monitoring specific command patterns and excluding benign processes.
Possible investigation steps
- Review the process command line to confirm the presence of the suspicious pattern "echopasswd*" and assess if it aligns with known malicious activity.
- Identify the user account associated with the process to determine if it is a legitimate user or potentially compromised.
- Examine the parent process details, including the command line and executable path, to understand the context of how the suspicious process was initiated.
- Check for any recent changes to user accounts on the system, focusing on password modifications or new account creations around the time of the alert.
- Investigate the system for any additional signs of compromise, such as unexpected network connections or other suspicious processes running concurrently.
- Correlate the event with other security alerts or logs to identify if this activity is part of a broader attack pattern or campaign.
False positive analysis
- Automated build processes may trigger this rule if they use shell scripts that include echoing passwords for testing or configuration purposes. To handle this, exclude processes with parent command lines or executables related to build tools like make.
- System administration scripts that automate user account management might use similar command patterns. Review these scripts and exclude them by specifying their parent process or executable paths.
- Custom user scripts for password management could inadvertently match the rule's criteria. Identify these scripts and add exceptions based on their unique command line or parent process attributes.
- Some legitimate software installations might use echo and passwd in their setup scripts. Monitor installation logs and exclude known safe installation processes by their parent command line or executable.
Response and remediation
- Immediately isolate the affected Linux system from the network to prevent further unauthorized access or lateral movement by the adversary.
- Terminate any suspicious processes identified by the detection rule, particularly those involving the echo command being used with the passwd utility.
- Change the passwords of any user accounts that may have been compromised, ensuring the use of strong, unique passwords.
- Review and audit recent user account changes and access logs to identify any unauthorized modifications or access attempts.
- Restore any affected user accounts to their previous state using backups or system snapshots, if available.
- Escalate the incident to the security operations team for further investigation and to determine if additional systems are affected.
- Implement additional monitoring and alerting for similar command patterns to enhance detection and prevent recurrence of this threat.
Related rules
- File Creation in /var/log via Suspicious Process
- Python Path File (pth) Creation
- Python Site or User Customize File Creation
- Uncommon Destination Port Connection by Web Server
- Unusual Command Execution from Web Server Parent