File made Immutable by Chattr

Detects a file being made immutable using the chattr binary. Making a file immutable means it cannot be deleted or renamed, no link can be created to this file, most of the file's metadata can not be modified, and the file can not be opened in write mode. Threat actors will commonly utilize this to prevent tampering or modification of their malicious files or any system files they have modified for purposes of persistence (e.g .ssh, /etc/passwd, etc.).

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2022/07/22"
  3integration = ["endpoint"]
  4maturity = "production"
  5updated_date = "2024/10/17"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10Detects a file being made immutable using the chattr binary. Making a file immutable means it cannot be deleted or
 11renamed, no link can be created to this file, most of the file's metadata can not be modified, and the file can not be
 12opened in write mode. Threat actors will commonly utilize this to prevent tampering or modification of their malicious
 13files or any system files they have modified for purposes of persistence (e.g .ssh, /etc/passwd, etc.).
 14"""
 15from = "now-9m"
 16index = ["auditbeat-*", "logs-endpoint.events.*", "endgame-*"]
 17language = "eql"
 18license = "Elastic License v2"
 19max_signals = 33
 20name = "File made Immutable by Chattr"
 21risk_score = 47
 22rule_id = "968ccab9-da51-4a87-9ce2-d3c9782fd759"
 23setup = """## Setup
 24
 25This rule requires data coming in from one of the following integrations:
 26- Elastic Defend
 27- Auditbeat
 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
 50### Auditbeat Setup
 51Auditbeat is a lightweight shipper that you can install on your servers to audit the activities of users and processes on your systems. For example, you can use Auditbeat to collect and centralize audit events from the Linux Audit Framework. You can also use Auditbeat to detect changes to critical files, like binaries and configuration files, and identify potential security policy violations.
 52
 53#### The following steps should be executed in order to add the Auditbeat on a Linux System:
 54- Elastic provides repositories available for APT and YUM-based distributions. Note that we provide binary packages, but no source packages.
 55- To install the APT and YUM repositories follow the setup instructions in this [helper guide](https://www.elastic.co/guide/en/beats/auditbeat/current/setup-repositories.html).
 56- To run Auditbeat on Docker follow the setup instructions in the [helper guide](https://www.elastic.co/guide/en/beats/auditbeat/current/running-on-docker.html).
 57- To run Auditbeat on Kubernetes follow the setup instructions in the [helper guide](https://www.elastic.co/guide/en/beats/auditbeat/current/running-on-kubernetes.html).
 58- For complete “Setup and Run Auditbeat” information refer to the [helper guide](https://www.elastic.co/guide/en/beats/auditbeat/current/setting-up-and-running.html).
 59
 60#### Custom Ingest Pipeline
 61For versions <8.2, you need to add a custom ingest pipeline to populate `event.ingested` with @timestamp for non-elastic-agent indexes, like auditbeats/filebeat/winlogbeat etc. For more details to add a custom ingest pipeline refer to the [guide](https://www.elastic.co/guide/en/fleet/current/data-streams-pipeline-tutorial.html).
 62"""
 63severity = "medium"
 64tags = [
 65    "Domain: Endpoint",
 66    "OS: Linux",
 67    "Use Case: Threat Detection",
 68    "Tactic: Defense Evasion",
 69    "Data Source: Elastic Endgame",
 70    "Data Source: Elastic Defend",
 71]
 72timestamp_override = "event.ingested"
 73type = "eql"
 74query = '''
 75process where host.os.type == "linux" and event.type == "start" and process.parent.executable != null and
 76process.executable : "/usr/bin/chattr" and process.args : ("-*i*", "+*i*") and not (
 77  process.parent.executable: ("/lib/systemd/systemd", "/usr/local/uems_agent/bin/*", "/usr/lib/systemd/systemd") or
 78  process.parent.name in (
 79    "systemd", "cf-agent", "ntpdate", "xargs", "px", "preinst", "auth", "cf-agent", "dcservice", "dcagentupgrader",
 80    "sudo", "ephemeral-disk-warning"
 81  )
 82)
 83'''
 84
 85[[rule.threat]]
 86framework = "MITRE ATT&CK"
 87
 88[[rule.threat.technique]]
 89id = "T1222"
 90name = "File and Directory Permissions Modification"
 91reference = "https://attack.mitre.org/techniques/T1222/"
 92
 93[[rule.threat.technique.subtechnique]]
 94id = "T1222.002"
 95name = "Linux and Mac File and Directory Permissions Modification"
 96reference = "https://attack.mitre.org/techniques/T1222/002/"
 97
 98[rule.threat.tactic]
 99id = "TA0005"
100name = "Defense Evasion"
101reference = "https://attack.mitre.org/tactics/TA0005/"

Related rules

to-top