Hosts File Modifiededit

The hosts file on endpoints is used to control manual IP address to hostname resolutions. The hosts file is the first point of lookup for DNS hostname resolution so if adversaries can modify the endpoint hosts file, they can route traffic to malicious infrastructure. This rule detects modifications to the hosts file on Microsoft Windows, Linux (Ubuntu or RHEL) and macOS systems.

Rule type: eql

Rule indices:

  • auditbeat-*
  • winlogbeat-*
  • logs-endpoint.events.*
  • logs-windows.*

Severity: medium

Risk score: 47

Runs every: 5 minutes

Searches indices from: now-9m (Date Math format, see also Additional look-back time)

Maximum alerts per execution: 100

References:

Tags:

  • Elastic
  • Host
  • Linux
  • Windows
  • macOS
  • Threat Detection
  • Impact

Version: 9 (version history)

Added (Elastic Stack release): 7.10.0

Last modified (Elastic Stack release): 8.3.0

Rule authors: Elastic

Rule license: Elastic License v2

Investigation guideedit

## Config

For Windows systems using Auditbeat, this rule requires adding `C:/Windows/System32/drivers/etc` as an additional path in the 'file_integrity' module of auditbeat.yml.

If enabling an EQL rule on a non-elastic-agent index (such as beats) for versions <8.2, events will not define `event.ingested` and default fallback for EQL rules was not added until 8.2, so you will need to add a custom pipeline to populate `event.ingested` to @timestamp for this rule to work.

Rule queryedit

any where /* file events for creation; file change events are not
captured by some of the included sources for linux and so may
miss this, which is the purpose of the process + command line args
logic below */ ( event.category == "file" and event.type in
("change", "creation") and file.path : ("/private/etc/hosts",
"/etc/hosts", "?:\\Windows\\System32\\drivers\\etc\\hosts") ) or
/* process events for change targeting linux only */ (
event.category == "process" and event.type in ("start") and
process.name in ("nano", "vim", "vi", "emacs", "echo", "sed") and
process.args : ("/etc/hosts") )

Threat mappingedit

Framework: MITRE ATT&CKTM

Rule version historyedit

Version 9 (8.3.0 release)
  • Formatting only
Version 8 (8.2.0 release)
  • Formatting only
Version 6 (7.16.0 release)
  • Updated query, changed from:

    file where event.type in ("change", "creation") and file.path :
    ("/private/etc/hosts", "/etc/hosts",
    "?:\\Windows\\System32\\drivers\\etc\\hosts")
Version 5 (7.13.0 release)
  • Updated query, changed from:

    event.category:file and event.type:(change or creation) and
    file.path:("/private/etc/hosts" or "/etc/hosts" or
    "C:\Windows\System32\drivers\etc\hosts")
Version 4 (7.12.0 release)
  • Formatting only
Version 3 (7.11.2 release)
  • Formatting only
Version 2 (7.11.0 release)
  • Formatting only