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"
  5min_stack_comments = "New fields added: required_fields, related_integrations, setup"
  6min_stack_version = "8.3.0"
  7updated_date = "2024/01/11"
  8
  9[rule]
 10author = ["Elastic"]
 11description = """
 12Detects a file being made immutable using the chattr binary. Making a file immutable means it cannot be deleted or
 13renamed, no link can be created to this file, most of the file's metadata can not be modified, and the file can not be
 14opened in write mode. Threat actors will commonly utilize this to prevent tampering or modification of their malicious
 15files or any system files they have modified for purposes of persistence (e.g .ssh, /etc/passwd, etc.).
 16"""
 17from = "now-9m"
 18index = ["auditbeat-*", "logs-endpoint.events.*", "endgame-*"]
 19language = "eql"
 20license = "Elastic License v2"
 21max_signals = 33
 22name = "File made Immutable by Chattr"
 23risk_score = 47
 24rule_id = "968ccab9-da51-4a87-9ce2-d3c9782fd759"
 25setup = """## Setup
 26
 27This rule requires data coming in from one of the following integrations:
 28- Elastic Defend
 29- Auditbeat
 30
 31### Elastic Defend Integration Setup
 32Elastic 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.
 33
 34#### Prerequisite Requirements:
 35- Fleet is required for Elastic Defend.
 36- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
 37
 38#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
 39- Go to the Kibana home page and click "Add integrations".
 40- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
 41- Click "Add Elastic Defend".
 42- Configure the integration name and optionally add a description.
 43- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
 44- 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).
 45- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
 46- 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.
 47For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
 48- Click "Save and Continue".
 49- 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.
 50For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
 51
 52### Auditbeat Setup
 53Auditbeat 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.
 54
 55#### The following steps should be executed in order to add the Auditbeat on a Linux System:
 56- Elastic provides repositories available for APT and YUM-based distributions. Note that we provide binary packages, but no source packages.
 57- 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).
 58- 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).
 59- 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).
 60- 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).
 61
 62#### Custom Ingest Pipeline
 63For 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).
 64"""
 65severity = "medium"
 66tags = [
 67        "Domain: Endpoint",
 68        "OS: Linux",
 69        "Use Case: Threat Detection",
 70        "Tactic: Defense Evasion",
 71        "Data Source: Elastic Endgame",
 72        "Data Source: Elastic Defend"
 73        ]
 74timestamp_override = "event.ingested"
 75type = "eql"
 76
 77query = '''
 78process where host.os.type == "linux" and event.type == "start" and user.id == "0" and
 79  process.executable : "/usr/bin/chattr" and process.args : ("-*i*", "+*i*") and
 80  not process.parent.executable: ("/lib/systemd/systemd", "/usr/local/uems_agent/bin/*", "/usr/lib/systemd/systemd") and
 81  not process.parent.name in ("systemd", "cf-agent", "ntpdate", "xargs", "px", "preinst", "auth")
 82'''
 83
 84[[rule.threat]]
 85framework = "MITRE ATT&CK"
 86
 87[[rule.threat.technique]]
 88id = "T1222"
 89name = "File and Directory Permissions Modification"
 90reference = "https://attack.mitre.org/techniques/T1222/"
 91
 92[[rule.threat.technique.subtechnique]]
 93id = "T1222.002"
 94name = "Linux and Mac File and Directory Permissions Modification"
 95reference = "https://attack.mitre.org/techniques/T1222/002/"
 96
 97[rule.threat.tactic]
 98id = "TA0005"
 99name = "Defense Evasion"
100reference = "https://attack.mitre.org/tactics/TA0005/"

Related rules

to-top