Memory Swap Modification

This rule detects memory swap modification events on Linux systems. Memory swap modification can be used to manipulate the system's memory and potentially impact the system's performance. This behavior is commonly observed in malware that deploys miner software such as XMRig.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2024/11/04"
  3integration = ["endpoint"]
  4maturity = "production"
  5updated_date = "2024/11/04"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10This rule detects memory swap modification events on Linux systems. Memory swap modification can be used to manipulate
 11the system's memory and potentially impact the system's performance. This behavior is commonly observed in malware that
 12deploys miner software such as XMRig.
 13"""
 14from = "now-9m"
 15index = ["logs-endpoint.events.*"]
 16language = "eql"
 17license = "Elastic License v2"
 18name = "Memory Swap Modification"
 19risk_score = 21
 20rule_id = "5e4023e7-6357-4061-ae1c-9df33e78c674"
 21setup = """## Setup
 22
 23This rule requires data coming in from Elastic Defend.
 24
 25### Elastic Defend Integration Setup
 26Elastic 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.
 27
 28#### Prerequisite Requirements:
 29- Fleet is required for Elastic Defend.
 30- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
 31
 32#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
 33- Go to the Kibana home page and click "Add integrations".
 34- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
 35- Click "Add Elastic Defend".
 36- Configure the integration name and optionally add a description.
 37- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
 38- 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).
 39- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
 40- 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.
 41
 42For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
 43- Click "Save and Continue".
 44- 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.
 45
 46For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
 47"""
 48severity = "low"
 49tags = [
 50    "Domain: Endpoint",
 51    "OS: Linux",
 52    "Use Case: Threat Detection",
 53    "Tactic: Impact",
 54    "Tactic: Execution",
 55    "Data Source: Elastic Defend",
 56]
 57timestamp_override = "event.ingested"
 58type = "eql"
 59query = '''
 60process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and
 61process.parent.executable != null and
 62process.name in ("swapon", "swapoff") or (
 63  process.command_line like ("*vm.swappiness*", "*/proc/sys/vm/swappiness*") and (
 64    (process.name == "sysctl" and process.args like ("*-w*", "*--write*", "*=*")) or
 65    (
 66      process.name in ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish") and process.args == "-c" and
 67      process.command_line like "*echo *"
 68    )
 69  )
 70)
 71'''
 72
 73[[rule.threat]]
 74framework = "MITRE ATT&CK"
 75
 76  [rule.threat.tactic]
 77  name = "Impact"
 78  id = "TA0040"
 79  reference = "https://attack.mitre.org/tactics/TA0040/"
 80
 81  [[rule.threat.technique]]
 82  name = "Resource Hijacking"
 83  id = "T1496"
 84  reference = "https://attack.mitre.org/techniques/T1496/"
 85
 86[[rule.threat]]
 87framework = "MITRE ATT&CK"
 88
 89  [rule.threat.tactic]
 90  name = "Execution"
 91  id = "TA0002"
 92  reference = "https://attack.mitre.org/tactics/TA0002/"
 93
 94  [[rule.threat.technique]]
 95  name = "Command and Scripting Interpreter"
 96  id = "T1059"
 97  reference = "https://attack.mitre.org/techniques/T1059/"
 98
 99    [[rule.threat.technique.subtechnique]]
100    name = "Unix Shell"
101    id = "T1059.004"
102    reference = "https://attack.mitre.org/techniques/T1059/004/"

Related rules

to-top