Access Control List Modification via setfacl
This rule detects Linux Access Control List (ACL) modification via the setfacl command.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2024/08/23"
3integration = ["endpoint", "auditd_manager", "crowdstrike", "sentinel_one_cloud_funnel"]
4maturity = "production"
5updated_date = "2025/03/20"
6
7[rule]
8author = ["Elastic"]
9description = "This rule detects Linux Access Control List (ACL) modification via the setfacl command.\n"
10from = "now-9m"
11index = [
12 "auditbeat-*",
13 "endgame-*",
14 "logs-auditd_manager.auditd-*",
15 "logs-crowdstrike.fdr*",
16 "logs-endpoint.events.process*",
17 "logs-sentinel_one_cloud_funnel.*",
18]
19language = "eql"
20license = "Elastic License v2"
21name = "Access Control List Modification via setfacl"
22note = """## Triage and analysis
23
24> **Disclaimer**:
25> 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.
26
27### Investigating Access Control List Modification via setfacl
28
29Access Control Lists (ACLs) in Linux enhance file permission management by allowing more granular access control. The `setfacl` command modifies these ACLs, potentially altering who can access or modify files. Adversaries may exploit `setfacl` to stealthily change permissions, evading detection and maintaining persistence. The detection rule identifies suspicious `setfacl` executions, excluding benign patterns, to flag potential misuse.
30
31### Possible investigation steps
32
33- Review the process details to confirm the execution of the setfacl command, focusing on the process.name and event.type fields to ensure the alert is valid.
34- Examine the process.command_line to understand the specific ACL modifications attempted and identify any unusual or unauthorized changes.
35- Investigate the user account associated with the process execution to determine if the action aligns with their typical behavior or role.
36- Check the process's parent process to identify how the setfacl command was initiated and assess if it was part of a legitimate workflow or a potential compromise.
37- Correlate the event with other security logs or alerts from the same host to identify any related suspicious activities or patterns that might indicate a broader attack.
38
39### False positive analysis
40
41- Routine system maintenance tasks may trigger the rule if they involve legitimate use of setfacl. To manage this, identify and document regular maintenance scripts or processes that use setfacl and create exceptions for these specific command lines.
42- Backup operations that restore ACLs using setfacl can be mistaken for suspicious activity. Exclude these by adding exceptions for command lines that match known backup procedures, such as those using the --restore option.
43- Automated log management tools might use setfacl to manage permissions on log directories like /var/log/journal/. To prevent false positives, exclude these specific directory paths from triggering the rule.
44- Custom applications or services that require dynamic permission changes using setfacl could be flagged. Review these applications and, if deemed safe, add their specific command patterns to the exception list to avoid unnecessary alerts.
45
46### Response and remediation
47
48- Immediately isolate the affected system from the network to prevent further unauthorized access or changes.
49- Review the process execution logs to identify any unauthorized users or processes that executed the `setfacl` command.
50- Revert any unauthorized ACL changes by restoring the original file permissions from a known good backup or configuration.
51- Conduct a thorough scan of the system for any additional signs of compromise, such as unauthorized user accounts or unexpected processes.
52- Update and patch the system to address any vulnerabilities that may have been exploited to gain access.
53- Implement stricter access controls and monitoring on critical systems to detect and prevent unauthorized ACL modifications in the future.
54- Escalate the incident to the security operations team for further investigation and to determine if additional systems are affected."""
55references = [
56 "https://www.uptycs.com/blog/threat-research-report-team/evasive-techniques-used-by-malicious-linux-shell-scripts",
57]
58risk_score = 21
59rule_id = "999565a2-fc52-4d72-91e4-ba6712c0377e"
60severity = "low"
61tags = [
62 "Domain: Endpoint",
63 "OS: Linux",
64 "Use Case: Threat Detection",
65 "Tactic: Defense Evasion",
66 "Data Source: Elastic Defend",
67 "Data Source: Elastic Endgame",
68 "Data Source: Auditd Manager",
69 "Data Source: Crowdstrike",
70 "Data Source: SentinelOne",
71 "Resources: Investigation Guide",
72]
73timestamp_override = "event.ingested"
74type = "eql"
75
76query = '''
77process where host.os.type == "linux" and event.type == "start" and
78event.action in ("exec", "exec_event", "start", "ProcessRollup2", "executed", "process_started") and
79process.name == "setfacl" and not (
80 process.command_line == "/bin/setfacl --restore=-" or
81 process.args == "/var/log/journal/" or
82 process.parent.name in ("stats.pl", "perl", "find") or
83 process.parent.command_line like~ "/bin/sh -c *ansible*"
84)
85'''
86
87
88[[rule.threat]]
89framework = "MITRE ATT&CK"
90[[rule.threat.technique]]
91id = "T1222"
92name = "File and Directory Permissions Modification"
93reference = "https://attack.mitre.org/techniques/T1222/"
94[[rule.threat.technique.subtechnique]]
95id = "T1222.002"
96name = "Linux and Mac File and Directory Permissions Modification"
97reference = "https://attack.mitre.org/techniques/T1222/002/"
98
99
100
101[rule.threat.tactic]
102id = "TA0005"
103name = "Defense Evasion"
104reference = "https://attack.mitre.org/tactics/TA0005/"
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 Access Control List Modification via setfacl
Access Control Lists (ACLs) in Linux enhance file permission management by allowing more granular access control. The setfacl
command modifies these ACLs, potentially altering who can access or modify files. Adversaries may exploit setfacl
to stealthily change permissions, evading detection and maintaining persistence. The detection rule identifies suspicious setfacl
executions, excluding benign patterns, to flag potential misuse.
Possible investigation steps
- Review the process details to confirm the execution of the setfacl command, focusing on the process.name and event.type fields to ensure the alert is valid.
- Examine the process.command_line to understand the specific ACL modifications attempted and identify any unusual or unauthorized changes.
- Investigate the user account associated with the process execution to determine if the action aligns with their typical behavior or role.
- Check the process's parent process to identify how the setfacl command was initiated and assess if it was part of a legitimate workflow or a potential compromise.
- Correlate the event with other security logs or alerts from the same host to identify any related suspicious activities or patterns that might indicate a broader attack.
False positive analysis
- Routine system maintenance tasks may trigger the rule if they involve legitimate use of setfacl. To manage this, identify and document regular maintenance scripts or processes that use setfacl and create exceptions for these specific command lines.
- Backup operations that restore ACLs using setfacl can be mistaken for suspicious activity. Exclude these by adding exceptions for command lines that match known backup procedures, such as those using the --restore option.
- Automated log management tools might use setfacl to manage permissions on log directories like /var/log/journal/. To prevent false positives, exclude these specific directory paths from triggering the rule.
- Custom applications or services that require dynamic permission changes using setfacl could be flagged. Review these applications and, if deemed safe, add their specific command patterns to the exception list to avoid unnecessary alerts.
Response and remediation
- Immediately isolate the affected system from the network to prevent further unauthorized access or changes.
- Review the process execution logs to identify any unauthorized users or processes that executed the
setfacl
command. - Revert any unauthorized ACL changes by restoring the original file permissions from a known good backup or configuration.
- Conduct a thorough scan of the system for any additional signs of compromise, such as unauthorized user accounts or unexpected processes.
- Update and patch the system to address any vulnerabilities that may have been exploited to gain access.
- Implement stricter access controls and monitoring on critical systems to detect and prevent unauthorized ACL modifications in the future.
- Escalate the incident to the security operations team for further investigation and to determine if additional systems are affected.
References
Related rules
- Attempt to Clear Kernel Ring Buffer
- Base16 or Base32 Encoding/Decoding Activity
- ESXI Timestomping using Touch Command
- Kernel Load or Unload via Kexec Detected
- Potential Disabling of AppArmor