Elastic low stable kql

Unusual File Creation by Web Server

This rule detects unusual file creations from a web server parent process. Adversaries may attempt to create files from a web server parent process to establish persistence, execute malicious scripts, or exfiltrate data. ES|QL rules have limited fields available in its alert documents. Make sure to review the original documents to aid in the investigation of this alert.

View Source

Detection Logic

from logs-endpoint.events.file-* metadata _id, _index, _version

// Ensure event.action values in a list are expanded
| mv_expand event.action
| where
    host.os.type == "linux" and
    event.action == "creation" and (
        process.name in (
            "apache", "nginx", "apache2", "httpd", "lighttpd", "caddy", "mongrel_rails", "gunicorn",
            "uwsgi", "openresty", "cherokee", "h2o", "resin", "puma", "unicorn", "traefik", "tornado", "hypercorn",
            "daphne", "twistd", "yaws", "webfsd", "httpd.worker", "flask", "rails", "mongrel", "php-cgi",
            "php-fcgi", "php-cgi.cagefs", "catalina.sh", "hiawatha", "lswsctrl"
        ) or
        process.name like "php-fpm*" or
        user.name in ("apache", "www-data", "httpd", "nginx", "lighttpd", "tomcat", "tomcat8", "tomcat9") or
        user.id in ("33", "498", "48")
      )
| keep
    @timestamp,
    _id,
    _index,
    _version,
    host.os.type,
    event.action,
    user.name,
    user.id,
    process.name,
    process.executable,
    file.path,
    agent.id,
    host.name,
    event.dataset,
    data_stream.namespace
| stats
    Esql.event_count = count(),
    Esql.agent_id_count_distinct = count_distinct(agent.id),
    Esql.host_name_values = values(host.name),
    Esql.agent_id_values = values(agent.id),
    Esql.event_dataset_values = values(event.dataset),
    Esql.data_stream_namespace_values = values(data_stream.namespace)

  by process.executable, file.path
| where
    Esql.agent_id_count_distinct == 1 and
    Esql.event_count < 5

Field Validations

Loading…

Comments (0)

Loading comments...