Code Monkey home page Code Monkey logo

detection-rules's Introduction

Supported Python versions Unit Tests Chat ATT&CK navigator coverage

Detection Rules

Detection Rules is the home for rules used by Elastic Security. This repository is used for the development, maintenance, testing, validation, and release of rules for Elastic Security’s Detection Engine.

This repository was first announced on Elastic's blog post, Elastic Security opens public detection rules repo. For additional content, see the accompanying webinar, Elastic Security: Introducing the public repository for detection rules.

Table of Contents

Overview of this repository

Detection Rules contains more than just static rule files. This repository also contains code for unit testing in Python and integrating with the Detection Engine in Kibana.

folder description
detection_rules/ Python module for rule parsing, validating and packaging
etc/ Miscellaneous files, such as ECS and Beats schemas
hunting Root directory where threat hunting queries are stored
kibana/ Python library for handling the API calls to Kibana and the Detection Engine
kql/ Python library for parsing and validating Kibana Query Language
rta/ Red Team Automation code used to emulate attacker techniques, used for rule testing
rules/ Root directory where rules are stored
rules_building_block/ Root directory where building block rules are stored
tests/ Python code for unit testing rules

Getting started

Although rules can be added by manually creating .toml files, we don't recommend it. This repository also consists of a python module that aids rule creation and unit testing. Assuming you have Python 3.12+, run the below command to install the dependencies using the makefile:

✗ make
python3.12 -m pip install --upgrade pip setuptools
Looking in indexes: https://pypi.org/simple
Requirement already satisfied: pip in /opt/homebrew/lib/python3.12/site-packages (24.0)
Requirement already satisfied: setuptools in /opt/homebrew/lib/python3.12/site-packages (69.1.1)
python3.12 -m venv ./env/detection-rules-build
./env/detection-rules-build/bin/pip install --upgrade pip setuptools
Looking in indexes: https://pypi.org/simple
Requirement already satisfied: pip in ./env/detection-rules-build/lib/python3.12/site-packages (24.0)
Collecting setuptools
  Using cached setuptools-69.1.1-py3-none-any.whl.metadata (6.2 kB)
Using cached setuptools-69.1.1-py3-none-any.whl (819 kB)
Installing collected packages: setuptools
Successfully installed setuptools-69.1.1
Installing kql and kibana packages...
...

Or install the dependencies using the following command:

$ pip3 install ".[dev]"
Collecting jsl==0.2.4
  Downloading jsl-0.2.4.tar.gz (21 kB)
Collecting jsonschema==3.2.0
  Downloading jsonschema-3.2.0-py2.py3-none-any.whl (56 kB)
     |████████████████████████████████| 56 kB 318 kB/s
Collecting requests==2.22.0
  Downloading requests-2.22.0-py2.py3-none-any.whl (57 kB)
     |████████████████████████████████| 57 kB 1.2 MB/s
Collecting Click==7.0
  Downloading Click-7.0-py2.py3-none-any.whl (81 kB)
     |████████████████████████████████| 81 kB 2.6 MB/s
...

Note: The kibana and kql packages are not available on PyPI and must be installed from the lib directory.

# Install from the repository
pip3 install git+https://github.com/elastic/detection-rules.git#subdirectory=kibana
pip3 install git+https://github.com/elastic/detection-rules.git#subdirectory=kql

# Or locally for development
pip3 install lib/kibana lib/kql

Remember, make sure to activate your virtual environment if you are using one. If installed via make, the associated virtual environment is created in env/detection-rules-build/. If you are having trouble using a Python 3.12 environment, please see the relevant section in our troubleshooting guide.

To confirm that everything was properly installed, run with the --help flag

$  python -m detection_rules --help

Usage: detection_rules [OPTIONS] COMMAND [ARGS]...

  Commands for detection-rules repository.

Options:
  -d, --debug / -n, --no-debug  Print full exception stacktrace on errors
  -h, --help                    Show this message and exit.

Commands:
  create-rule     Create a detection rule.
  dev             Commands for development and management by internal...
  es              Commands for integrating with Elasticsearch.
  import-rules    Import rules from json, toml, or Kibana exported rule...
  kibana          Commands for integrating with Kibana.
  mass-update     Update multiple rules based on eql results.
  normalize-data  Normalize Elasticsearch data timestamps and sort.
  rule-search     Use KQL or EQL to find matching rules.
  test            Run unit tests over all of the rules.
  toml-lint       Cleanup files with some simple toml formatting.
  validate-all    Check if all rules validates against a schema.
  validate-rule   Check if a rule staged in rules dir validates against a...
  view-rule       View an internal rule or specified rule file.

Note:

  • If you are using a virtual environment, make sure to activate it before running the above command.
  • If using Windows, you may have to also run <venv_directory>\Scripts\pywin32_postinstall.py -install depending on your python version.

The contribution guide describes how to use the create-rule and test commands to create and test a new rule when contributing to Detection Rules.

For more advanced command line interface (CLI) usage, refer to the CLI guide.

How to contribute

We welcome your contributions to Detection Rules! Before contributing, please familiarize yourself with this repository, its directory structure, and our philosophy about rule creation. When you're ready to contribute, read the contribution guide to learn how we turn detection ideas into production rules and validate with testing.

Licensing

Everything in this repository — rules, code, RTA, etc. — is licensed under the Elastic License v2. These rules are designed to be used in the context of the Detection Engine within the Elastic Security application. If you’re using our Elastic Cloud managed service or the default distribution of the Elastic Stack software that includes the full set of free features, you’ll get the latest rules the first time you navigate to the detection engine.

Occasionally, we may want to import rules from another repository that already have a license, such as MIT or Apache 2.0. This is welcome, as long as the license permits sublicensing under the Elastic License v2. We keep those license notices in NOTICE.txt and sublicense as the Elastic License v2 with all other rules. We also require contributors to sign a Contributor License Agreement before contributing code to any Elastic repositories.

Questions? Problems? Suggestions?

  • Want to know more about the Detection Engine? Check out the overview in Kibana.
  • This repository includes new and updated rules that have not been released yet. To see the latest set of rules released with the stack, see the Prebuilt rule reference.
  • If you’d like to report a false positive or other type of bug, please create a GitHub issue and check if there's an existing one first.
  • Need help with Detection Rules? Post an issue or ask away in our Security Discuss Forum or the #security-detection-rules channel within Slack workspace.

detection-rules's People

Contributors

aegrah avatar ajosh0504 avatar austinsonger avatar bm11100 avatar brokensound77 avatar defsecsentinel avatar dstepanic avatar eric-forte-elastic avatar github-actions[bot] avatar imays11 avatar lazydk avatar makowish avatar mikaayenson avatar nicpenning avatar nkhristinin avatar peasead avatar randomuserid avatar rw-access avatar samirbous avatar sbousseaden avatar seth-goodwin avatar shashank-elastic avatar sholzhauer avatar skoetting avatar spong avatar susan-shu-c avatar terrancedejesus avatar threat-punter avatar totalknob avatar w0rk3r avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

detection-rules's Issues

[New Rule] Elastic Endpoint and External Alerts

Description

In support of elastic/kibana#65942 to create two new pre-packaged rules that will enable Elastic Endpoint Alerts and External Alerts to be used in investigations.

Required Info

  • Eventing Sources: Elastic Endpoint and all external sources where event.kind:alert
  • Target Operating Systems: All
  • Platforms: All
  • Target ECS Version: 1.5.0
  • New fields required in ECS for this? Associated issue/PR: n/a

Optional Info

[New Rule] Possible FIN7 Command and Control Behavior

Description

This rule detects a known command and control pattern in network events. The FIN7 threat group is known to use this
command and control technique, while maintaining persistence in their target's network.

Required Info

  • Eventing Sources:
    Packetbeat

  • Target Operating Systems:
    NA

  • Platforms
    NA

  • Target ECS Version: 1.5.0

  • New fields required in ECS for this? Associated issue/PR: NA

Optional Info

Example Data

image
image
HTTP

{
  "_index": "packetbeat-7.8.0-2020.06.30-000001",
  "_type": "_doc",
  "_id": "18UOJXMBrrfU-yfrPe_i",
  "_version": 1,
  "_score": null,
  "_source": {
    "@timestamp": "2020-07-06T16:55:44.190Z",
    "http": {
      "request": {
        "headers": {
          "content-length": 0
        },
        "method": "get",
        "bytes": 72
      },
      "response": {
        "body": {
          "bytes": 166
        },
        "headers": {
          "content-length": 166,
          "content-type": "text/html"
        },
        "status_phrase": "moved permanently",
        "status_code": 301,
        "bytes": 325
      },
      "version": "1.1"
    },
    "event": {
      "start": "2020-07-06T16:55:44.190Z",
      "end": "2020-07-06T16:55:44.311Z",
      "kind": "event",
      "category": "network_traffic",
      "dataset": "http",
      "duration": 120605000
    },
    "user_agent": {
      "original": "curl/7.64.1"
    },
    "url": {
      "domain": "abcd.top",
      "path": "/",
      "full": "http://abcd.top/",
      "scheme": "http"
    },
    "agent": {
      "type": "packetbeat",
      "version": "7.8.0",
      "hostname": "[redacted].lan",
      "ephemeral_id": "692f5e75-ed6a-4831-ae2c-cbbea587fc49",
      "id": "ab255210-3866-4b07-9579-91f3a78eb996",
      "name": "[redacted].lan"
    },
    "ecs": {
      "version": "1.5.0"
    },
    "destination": {
      "ip": "[redacted]",
      "port": 80,
      "domain": "abcd.top",
      "bytes": 325
    },
    "network": {
      "type": "ipv4",
      "transport": "tcp",
      "protocol": "http",
      "community_id": "1:TrKO4OuPg+btSLBLdaHudUsSBE0=",
      "bytes": 397
    },
    "source": {
      "ip": "192.168.44.144",
      "port": 51788,
      "bytes": 72
    },
    "query": "GET /",
    "method": "get",
    "type": "http",
    "client": {
      "ip": "192.168.44.144",
      "port": 51788,
      "bytes": 72
    },
    "status": "OK",
    "server": {
      "domain": "abcd.top",
      "bytes": 325,
      "ip": "[redacted]",
      "port": 80
    },
    "host": {
      "ip": [
        "fe80::aede:48ff:fe00:1122",
        "192.168.44.144",
        "fe80::80f9:15ff:fea3:de16",
        "fe80::80f9:15ff:fea3:de16",
        "fe80::ee35:843a:f08b:405d",
        "fe80::ae1:df41:6bff:4a07",
        "10.156.0.70"
      ],
      "mac": [
        "ac:de:48:00:11:22",
        "a6:83:e7:ac:3c:98",
        "a4:83:e7:ac:3c:98",
        "82:ae:16:c5:30:00",
        "82:ae:16:c5:30:01",
        "82:ae:16:c5:30:05",
        "82:ae:16:c5:30:04",
        "82:ae:16:c5:30:01",
        "06:83:e7:ac:3c:98",
        "82:f9:15:a3:de:16",
        "82:f9:15:a3:de:16"
      ],
      "hostname": "[redacted].local",
      "name": "[redacted].lan",
      "architecture": "x86_64",
      "os": {
        "platform": "darwin",
        "version": "10.15.5",
        "family": "darwin",
        "name": "Mac OS X",
        "kernel": "19.5.0",
        "build": "19F101"
      },
      "id": "7A1239AF-8E8B-5928-A112-24FDC1718CF9"
    }
  },
  "fields": {
    "tls.server_certificate.not_before": [],
    "tls.detailed.client_certificate.not_after": [],
    "file.created": [],
    "process.parent.start": [],
    "tls.server_certificate.not_after": [],
    "event.end": [
      "2020-07-06T16:55:44.311Z"
    ],
    "file.ctime": [],
    "tls.client_certificate.not_after": [],
    "tls.client.not_after": [],
    "event.ingested": [],
    "@timestamp": [
      "2020-07-06T16:55:44.190Z"
    ],
    "tls.client_certificate.not_before": [],
    "file.mtime": [],
    "event.created": [],
    "file.accessed": [],
    "tls.server.not_before": [],
    "package.installed": [],
    "tls.client.not_before": [],
    "tls.detailed.server_certificate.not_after": [],
    "event.start": [
      "2020-07-06T16:55:44.190Z"
    ],
    "tls.server.not_after": [],
    "tls.detailed.server_certificate.not_before": [],
    "process.start": [],
    "tls.detailed.client_certificate.not_before": []
  },
  "highlight": {
    "event.category": [
      "@kibana-highlighted-field@network_traffic@/kibana-highlighted-field@"
    ],
    "destination.domain": [
      "@[email protected]@/kibana-highlighted-field@"
    ],
    "type": [
      "@kibana-highlighted-field@http@/kibana-highlighted-field@"
    ],
    "network.transport": [
      "@kibana-highlighted-field@tcp@/kibana-highlighted-field@"
    ]
  },
  "sort": [
    1594054544190
  ]
}

TLS

{
  "_index": "packetbeat-7.8.0-2020.06.30-000001",
  "_type": "_doc",
  "_id": "3cUOJXMBrrfU-yfrPe_i",
  "_version": 1,
  "_score": null,
  "_source": {
    "@timestamp": "2020-07-06T16:55:46.219Z",
    "type": "tls",
    "tls": {
      "resumed": false,
      "cipher": "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
      "next_protocol": "h2",
      "client": {
        "ja3": "3faa4ad39f690c4ef1c3160caa375465",
        "server_name": "abcd.us",
        "supported_ciphers": [
          "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
          "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
          "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384",
          "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384",
          "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA",
          "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA",
          "TLS_DHE_RSA_WITH_AES_256_GCM_SHA384",
          "TLS_DHE_RSA_WITH_AES_256_CBC_SHA256",
          "TLS_DHE_RSA_WITH_AES_256_CBC_SHA",
          "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256",
          "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256",
          "TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256",
          "(unknown:0xff85)",
          "TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256",
          "TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA",
          "TLS_GOSTR341001_WITH_28147_CNT_IMIT",
          "TLS_RSA_WITH_AES_256_GCM_SHA384",
          "TLS_RSA_WITH_AES_256_CBC_SHA256",
          "TLS_RSA_WITH_AES_256_CBC_SHA",
          "TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256",
          "TLS_RSA_WITH_CAMELLIA_256_CBC_SHA",
          "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
          "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
          "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256",
          "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256",
          "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
          "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA",
          "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256",
          "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256",
          "TLS_DHE_RSA_WITH_AES_128_CBC_SHA",
          "TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256",
          "TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA",
          "TLS_RSA_WITH_AES_128_GCM_SHA256",
          "TLS_RSA_WITH_AES_128_CBC_SHA256",
          "TLS_RSA_WITH_AES_128_CBC_SHA",
          "TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256",
          "TLS_RSA_WITH_CAMELLIA_128_CBC_SHA",
          "TLS_ECDHE_RSA_WITH_RC4_128_SHA",
          "TLS_ECDHE_ECDSA_WITH_RC4_128_SHA",
          "TLS_RSA_WITH_RC4_128_SHA",
          "TLS_RSA_WITH_RC4_128_MD5",
          "TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA",
          "TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA",
          "TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA",
          "TLS_RSA_WITH_3DES_EDE_CBC_SHA",
          "TLS_EMPTY_RENEGOTIATION_INFO_SCSV"
        ]
      },
      "server": {
        "subject": "CN=abcd.us",
        "issuer": "CN=Encryption Everywhere DV TLS CA - G1,OU=www.digicert.com,O=DigiCert Inc,C=US",
        "not_before": "2019-11-15T00:00:00.000Z",
        "not_after": "2020-11-15T12:00:00.000Z",
        "hash": {
          "sha1": "85483664FCE4F4863C321BD9A632108ABCA4AD4A"
        }
      },
      "detailed": {
        "version": "TLS 1.2",
        "client_hello": {
          "version": "3.3",
          "supported_compression_methods": [
            "NULL"
          ],
          "extensions": {
            "signature_algorithms": [
              "rsa_pkcs1_sha512",
              "ecdsa_secp521r1_sha512",
              "(unknown:0xefef)",
              "rsa_pkcs1_sha384",
              "ecdsa_secp384r1_sha384",
              "rsa_pkcs1_sha256",
              "ecdsa_secp256r1_sha256",
              "(unknown:0xeeee)",
              "(unknown:0xeded)",
              "(unknown:0x0301)",
              "(unknown:0x0303)",
              "rsa_pkcs1_sha1",
              "ecdsa_sha1"
            ],
            "application_layer_protocol_negotiation": [
              "h2",
              "http/1.1"
            ],
            "server_name_indication": [
              "abcd.us"
            ],
            "ec_points_formats": [
              "uncompressed"
            ],
            "supported_groups": [
              "x25519",
              "secp256r1",
              "secp384r1"
            ]
          }
        },
        "server_hello": {
          "version": "3.3",
          "selected_compression_method": "NULL",
          "extensions": {
            "application_layer_protocol_negotiation": [
              "h2"
            ],
            "_unparsed_": [
              "renegotiation_info"
            ]
          }
        },
        "server_certificate": {
          "version": 3,
          "public_key_size": 2048,
          "signature_algorithm": "SHA256-RSA",
          "serial_number": "18491524053030834926156519665066902696",
          "alternative_names": [
            "abcd.us",
            "*.abcd.us"
          ],
          "public_key_algorithm": "RSA",
          "not_after": "2020-11-15T12:00:00.000Z",
          "issuer": {
            "organization": "DigiCert Inc",
            "organizational_unit": "www.digicert.com",
            "common_name": "Encryption Everywhere DV TLS CA - G1",
            "country": "US"
          },
          "subject": {
            "common_name": "abcd.us"
          },
          "not_before": "2019-11-15T00:00:00.000Z"
        },
        "server_certificate_chain": [
          {
            "subject": {
              "country": "US",
              "organization": "DigiCert Inc",
              "organizational_unit": "www.digicert.com",
              "common_name": "Encryption Everywhere DV TLS CA - G1"
            },
            "public_key_size": 2048,
            "signature_algorithm": "SHA256-RSA",
            "public_key_algorithm": "RSA",
            "not_after": "2027-11-27T12:46:10.000Z",
            "version": 3,
            "issuer": {
              "common_name": "DigiCert Global Root CA",
              "country": "US",
              "organization": "DigiCert Inc",
              "organizational_unit": "www.digicert.com"
            },
            "not_before": "2017-11-27T12:46:10.000Z",
            "serial_number": "3290217995900168375215973871519570865"
          },
          {
            "version": 3,
            "issuer": {
              "organizational_unit": "www.digicert.com",
              "common_name": "DigiCert Global Root CA",
              "country": "US",
              "organization": "DigiCert Inc"
            },
            "not_before": "2006-11-10T00:00:00.000Z",
            "public_key_size": 2048,
            "signature_algorithm": "SHA1-RSA",
            "subject": {
              "common_name": "DigiCert Global Root CA",
              "country": "US",
              "organization": "DigiCert Inc",
              "organizational_unit": "www.digicert.com"
            },
            "serial_number": "10944719598952040374951832963794454346",
            "not_after": "2031-11-10T00:00:00.000Z",
            "public_key_algorithm": "RSA"
          }
        ],
        "client_certificate_requested": false
      },
      "version": "1.2",
      "established": true,
      "version_protocol": "tls"
    },
    "source": {
      "ip": "192.168.44.144",
      "port": 51793
    },
    "client": {
      "ip": "192.168.44.144",
      "port": 51793
    },
    "ecs": {
      "version": "1.5.0"
    },
    "host": {
      "hostname": "[redacted].local",
      "architecture": "x86_64",
      "name": "[redacted].lan",
      "os": {
        "version": "10.15.5",
        "family": "darwin",
        "name": "Mac OS X",
        "kernel": "19.5.0",
        "build": "19F101",
        "platform": "darwin"
      },
      "id": "7A1239AF-8E8B-5928-A112-24FDC1718CF9",
      "ip": [
        "fe80::aede:48ff:fe00:1122",
        "192.168.44.144",
        "fe80::80f9:15ff:fea3:de16",
        "fe80::80f9:15ff:fea3:de16",
        "fe80::ee35:843a:f08b:405d",
        "fe80::ae1:df41:6bff:4a07",
        "10.156.0.70"
      ],
      "mac": [
        "ac:de:48:00:11:22",
        "a6:83:e7:ac:3c:98",
        "a4:83:e7:ac:3c:98",
        "82:ae:16:c5:30:00",
        "82:ae:16:c5:30:01",
        "82:ae:16:c5:30:05",
        "82:ae:16:c5:30:04",
        "82:ae:16:c5:30:01",
        "06:83:e7:ac:3c:98",
        "82:f9:15:a3:de:16",
        "82:f9:15:a3:de:16"
      ]
    },
    "agent": {
      "hostname": "[redacted].lan",
      "ephemeral_id": "692f5e75-ed6a-4831-ae2c-cbbea587fc49",
      "id": "ab255210-3866-4b07-9579-91f3a78eb996",
      "name": "[redacted].lan",
      "type": "packetbeat",
      "version": "7.8.0"
    },
    "server": {
      "ip": "[redacted]",
      "port": 443,
      "domain": "abcd.us"
    },
    "network": {
      "transport": "tcp",
      "protocol": "tls",
      "community_id": "1:8yX8D4MdmNgYbbyIF4oMg0yRX6k=",
      "type": "ipv4"
    },
    "event": {
      "dataset": "tls",
      "duration": 253945000,
      "start": "2020-07-06T16:55:46.219Z",
      "end": "2020-07-06T16:55:46.473Z",
      "kind": "event",
      "category": "network_traffic"
    },
    "status": "OK",
    "destination": {
      "ip": "[redacted]",
      "port": 443,
      "domain": "abcd.us"
    }
  },
  "fields": {
    "tls.server_certificate.not_before": [
      "2019-11-15T00:00:00.000Z"
    ],
    "tls.detailed.client_certificate.not_after": [],
    "file.created": [],
    "process.parent.start": [],
    "tls.server_certificate.not_after": [
      "2020-11-15T12:00:00.000Z"
    ],
    "event.end": [
      "2020-07-06T16:55:46.473Z"
    ],
    "file.ctime": [],
    "tls.client_certificate.not_after": [],
    "tls.client.not_after": [],
    "event.ingested": [],
    "@timestamp": [
      "2020-07-06T16:55:46.219Z"
    ],
    "tls.client_certificate.not_before": [],
    "file.mtime": [],
    "event.created": [],
    "file.accessed": [],
    "tls.server.not_before": [
      "2019-11-15T00:00:00.000Z"
    ],
    "package.installed": [],
    "tls.client.not_before": [],
    "tls.detailed.server_certificate.not_after": [
      "2020-11-15T12:00:00.000Z"
    ],
    "event.start": [
      "2020-07-06T16:55:46.219Z"
    ],
    "tls.server.not_after": [
      "2020-11-15T12:00:00.000Z"
    ],
    "tls.detailed.server_certificate.not_before": [
      "2019-11-15T00:00:00.000Z"
    ],
    "process.start": [],
    "tls.detailed.client_certificate.not_before": []
  },
  "highlight": {
    "event.category": [
      "@kibana-highlighted-field@network_traffic@/kibana-highlighted-field@"
    ],
    "destination.domain": [
      "@[email protected]@/kibana-highlighted-field@"
    ],
    "type": [
      "@kibana-highlighted-field@tls@/kibana-highlighted-field@"
    ],
    "network.transport": [
      "@kibana-highlighted-field@tcp@/kibana-highlighted-field@"
    ]
  },
  "sort": [
    1594054546219
  ]
}

[FR] Track schemas.py across stack versions

Is your feature request related to a problem? Please describe.
When working on #48, I noticed that the rule is rejected by Kibana < 7.9. This was because the author and license field were unknown and it has strict schema handling (it's a good thing). Maybe we could have some way of tracking rules that are

Describe the solution you'd like
I'm not totally sure the ideal approach. Maybe in JSL, we add something like a version_added attribute to each field? Or we play around with scoping? Or even a class based approach, where we make a hierarchy with 7.8 -> 7.9 -> 7.10 and each time you add a few fields. Or maybe a mixin. I'm not sure what's ideal.

Describe alternatives you've considered
The alternative would be for Kibana to have better future compatibility, but that's a hard ask without a psychic on retainer.
If we do, I recommend this classy pair:

image

Additional context

for key in ("author", "license"):
payload.pop(key)

[New Rule] Attempt to Modify or Delete Okta Application

Description

An adversary may attempt to modify, deactivate, or delete an Okta application in order to weaken an organization's security controls or disrupt its business operations.

Required Info

  • Eventing Sources:

filebeat-*

  • Target Operating Systems:
  • Platforms

Okta

  • Target ECS Version: 1.5.0
  • New fields required in ECS for this? No Associated issue/PR: N/A

Optional Info

Example Data

image

[New Rule] Attempts to Brute Force an Okta User Account

Description

Identifies attempts to brute force an Okta user account. An adversary may attempt a brute force or password spraying attack to obtain unauthorized access to user accounts. The default Okta authentication policy ensures that a user account is locked out after 10 failed authentication attempts. This rule detects when an Okta user account is locked out 3 times within a 3 hour period.

event.module:okta and event.dataset:okta.system and event.action:user.account.lock

This will be a threshold rule type that aggregates events by the Okta username value (okta.actor.id) with a count of 3 and a lookback value of 180 minutes.

Required Info

  • Eventing Sources:

filebeat-*

  • Platforms

Okta

  • Target ECS Version: 1.5.0
  • New fields required in ECS for this? No
  • Related issues or PRs N/A

Optional Info

Example Data

image

[CLI] Add better support for nested structures

Describe the bug
The create-rule prompt loop and rule build loop were initially built to support a flat schema, but as the schema has expanded and added nested objects, they can no longer support this. Additionally, the function to detect unneeded default fields is also prone to miss nested data as well.

We will need to refactor the full schema_prompt to be able to recursively prompt for nested data. There is a chance that there could be other pieces of code which also miss the nested structure of rules as well, and so we should review and refactor as needed.

Additional context
@rw-access has some working code to move some of the prompt logic to within click, but we may need to expand nested support.

Add ATT&CK subtechniques

ATT&CK subtechniques are official.

We should update our rules to use them, and figure out the optimal schema for ECS and the detection engine. We also need to improve our rule.threat mappings and use the latest information in ATT&CK since some techniques became subtechniques and others split. ATT&CK has subtechniques-crosswalk.json to track these changes

There's an ECS issue here:
elastic/ecs#867

When we have a good structure in mind for the schema, create an issue for Kibana to add support to the detection engine. We can start with the API first and they can add UI support after.

[Rule Tuning] Add Packetbeat Index to Network Rules

Description

The Packetbeat Index needs to be added to network SIEM rules.

Filebeat was originally used to take advantage of the Zeek and Suricata network data modules. While Packetbeat is not a full-fledged protocol analyzer like Zeek, or even Suricata, it can act as a data source for these rules.

Example Data

Existing Index designation: index = ["filebeat-*"]
Suggested Index designation: index = ["filebeat-*", "packetbeat-*"]

[FR] Multi-line KQL formatting

Is your feature request related to a problem? Please describe.
With elastic/kibana#70140, we'll have multi-line support for KQL in Kibana. More complex and/or logic is hard to read on a single line.

Describe the solution you'd like
Some type of auto-formatter for KQL, with the usual ".render()" method. It should be multi-line aware.
Generate something like this (also found a bug here:

event.action:(executed or process_started) and (process.name:service and process.args:stop or process.name:chkconfig and process.args:off) and process.args:(ip6tables or iptables or firewalld) or process.name:systemctl and process.args:((firewalld or iptables or ip6tables) and (disable or stop or kill))

This would help us find these bugs better

event.category:process and event.action:(executed or process_started) and (
  (process.name:service and process.args:stop) or
  (process.name:chkconfig and process.args:off) or
  (process.name:systemctl and process.args:(disable or stop or kill))
) and process.args:(ip6tables or iptables or firewalld)

[New Rule] Attempt to Modify or Delete Okta Application Sign On Policy

Description

An adversary may attempt to modify or delete the sign on policy for an Okta application in order to remove or weaken an organization's security controls.

Required Info

  • Eventing Sources:

filebeat-*

  • Target Operating Systems:
  • Platforms

Okta

  • Target ECS Version: 1.5.0
  • New fields required in ECS for this? No Associated issue/PR: N/A

Optional Info

Example Data

image

[FR] Modify threat URLs format

The references for the ATT&CK threat info in a rule requires a trailing / in all of the rules

MITRE_URL_PATTERN = r'https://attack.mitre.org/{type}/T[A-Z0-9]+/'

However, when a rule is created via Kibana as a custom rule, the default behavior is to _
not_ have a trailing /:

[
  {
    "framework": "MITRE ATT&CK",
    "tactic": {
      "id": "TA0002",
      "reference": "https://attack.mitre.org/tactics/TA0002",
      "name": "Execution"
    },
    "technique": [
      {
        "id": "T1064",
        "name": "Scripting",
        "reference": "https://attack.mitre.org/techniques/T1064"
      }
    ]
  }
]

This causes validation issues when pulling a rule from Kibana. For consistency and simplification, the schema should not allow a trailing / and all rules should be updated to strip it

[Rule Tuning] Rules should be without index hardcoded

Description

I've been working in big data tools and ELK for quite some time and when the dataset grows, index names will start growing and custom index names will start to emerge. Hence it is NOT a good idea to hardcode the index in the rules, but should be abstracted out

Example Data

For example index = ["auditbeat-*"] may not be the ONLY index which will contain the unix audit as some of the data will come via syslog and may require a custom index = ["xyz-audit-*"] and so on.

Suggestion

  • suggestion: is to have a new concept of eventtypes field in rules. This eventtypes will be an abstraction of multiple datasources or indexes or expressions or ecs schema itself

an example will look like..

[rule]
author = ["Elastic"]
description = """
some description
"""
eventtypes = ["linux_auditevents", "skybox_audit", "ecs_schema_audit"]
...

the eventtypes will be instead of index
and in a new configuration, various datasets should be linked to the eventtypes

[Bug] Trojan detected in /rta/bin/Installer.msi

Describe the bug
A Win32/Occamy.AA torojan is detected in the /rta/bin/Installer.msi file when scanning with Microsoft AV.

To Reproduce
Steps to reproduce the behavior:

  1. download the installer.msi file
  2. scan with Microsoft defender antivirus
  3. See the alert.

Screenshots
image

[New Rule] AWS Management Console Attempted Root Login Brute Force

Description

Identifies a high number of failed attempts to login to the AWS management console as the Root user identity. An adversary may attempt to brute force the Root credentials, as the Root account will have complete access to all AWS services and resources.

This rule will use aggregations to look for a spike in failures over a short time period.

Required Info

  • Eventing Sources:
    filebeat-*

  • Platform
    AWS CloudTrail

  • Target ECS Version: 1.5.0

  • New fields required in ECS for this? no

  • Related issues or PRs n/a

Optional Info

Example Query

event.action:ConsoleLogin and event.dataset:aws.cloudtrail and event.provider:signin.amazonaws.com and aws.cloudtrail.user_identity.type:Root and event.outcome:failure

[New Rule] Hosts File Modified

Description

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

Required Info

  • Eventing Sources:
    Auditbeat

  • Target Operating Systems:
    Linux (Ubuntu & RHEL), macOS, and Windows

  • Platforms
    NA

  • Target ECS Version: 1.5.0

  • New fields required in ECS for this? Associated issue/PR: NA

Optional Info

  • References:

Example Data

image
image

CentOS

{
  "_index": "auditbeat-7.8.0-2020.07.07",
  "_type": "_doc",
  "_id": "JxmqKXMBpYSg_Jq8_rEZ",
  "_version": 1,
  "_score": null,
  "_source": {
    "@timestamp": "2020-07-07T14:25:29.237Z",
    "host": {
      "id": "b97c1797f883eb5f3d72134d451d0384",
      "mac": [
        "42:01:0a:80:00:1e",
        "42:01:0a:0a:08:02"
      ],
      "architecture": "x86_64",
      "name": "[redacted]",
      "hostname": "[redacted]",
      "os": {
        "codename": "Core",
        "platform": "centos",
        "version": "7 (Core)",
        "name": "CentOS Linux",
        "family": "redhat",
        "kernel": "3.10.0-1127.13.1.el7.x86_64"
      },
      "containerized": false,
      "ip": [
        "10.10.8.2"
      ]
    },
    "@version": "1",
    "file": {
      "path": "/etc/hosts"
    },
    "fields": {
      "labels": {
        "responsible_human": "[redacted]"
      }
    },
    "service": {
      "type": "file_integrity"
    },
    "agent": {
      "type": "auditbeat",
      "ephemeral_id": "06db1f12-0606-4e12-9044-752bf0fdb95c",
      "version": "7.8.0",
      "name": "[redacted]",
      "hostname": "[redacted]",
      "id": "24c3c24f-4114-497b-8148-f0189407029c"
    },
    "ecs": {
      "version": "1.5.0"
    },
    "event": {
      "type": [
        "change"
      ],
      "kind": "event",
      "category": [
        "file"
      ],
      "dataset": "file",
      "module": "file_integrity",
      "action": [
        "moved"
      ]
    },
    "tags": [
      "beats_input_raw_event"
    ]
  },
  "fields": {
    "file.created": [],
    "system.audit.package.installtime": [],
    "process.parent.start": [],
    "event.end": [],
    "file.ctime": [],
    "tls.client.not_after": [],
    "system.audit.user.password.last_changed": [],
    "event.ingested": [],
    "@timestamp": [
      "2020-07-07T14:25:29.237Z"
    ],
    "file.mtime": [],
    "event.created": [],
    "file.accessed": [],
    "system.audit.host.boottime": [],
    "tls.server.not_before": [],
    "package.installed": [],
    "tls.client.not_before": [],
    "event.start": [],
    "tls.server.not_after": [],
    "process.start": []
  },
  "highlight": {
    "file.path": [
      "@kibana-highlighted-field@/etc/hosts@/kibana-highlighted-field@"
    ],
    "event.category": [
      "@kibana-highlighted-field@file@/kibana-highlighted-field@"
    ],
    "event.type": [
      "@kibana-highlighted-field@change@/kibana-highlighted-field@"
    ],
    "agent.version": [
      "@[email protected]@/kibana-highlighted-field@"
    ]
  },
  "sort": [
    1594131929237
  ]
}

Ubuntu

{
  "_index": "auditbeat-7.8.0-2020.06.18-000001",
  "_type": "_doc",
  "_id": "T_OoKXMBrrfU-yfro_do",
  "_version": 1,
  "_score": null,
  "_source": {
    "@timestamp": "2020-07-07T14:23:03.446Z",
    "cloud": {
      "machine": {
        "type": "n1-standard-1"
      },
      "project": {
        "id": "[redacted]"
      },
      "provider": "gcp",
      "availability_zone": "us-central1-a",
      "instance": {
        "name": "[redacted]",
        "id": "5070623776091015145"
      }
    },
    "hash": {
      "sha1": "123a15a4b4abca52cb9da17574fe67b519154cbc"
    },
    "file": {
      "owner": "root",
      "size": 279,
      "uid": "0",
      "mode": "0644",
      "mtime": "2020-07-07T14:23:03.433Z",
      "inode": "13920",
      "gid": "0",
      "path": "/etc/hosts",
      "ctime": "2020-07-07T14:23:03.437Z",
      "type": "file",
      "group": "root",
      "hash": {
        "sha1": "123a15a4b4abca52cb9da17574fe67b519154cbc"
      }
    },
    "event": {
      "module": "file_integrity",
      "dataset": "file",
      "kind": "event",
      "category": [
        "file"
      ],
      "type": [
        "change"
      ],
      "action": [
        "moved"
      ]
    },
    "service": {
      "type": "file_integrity"
    },
    "host": {
      "hostname": "[redacted]",
      "architecture": "x86_64",
      "os": {
        "family": "debian",
        "name": "Ubuntu",
        "kernel": "4.15.0-1036-gcp",
        "codename": "bionic",
        "platform": "ubuntu",
        "version": "18.04.4 LTS (Bionic Beaver)"
      },
      "id": "d34db77d59e4bff23ff418db1336a6a6",
      "name": "[redacted]",
      "containerized": false,
      "ip": [
        "10.128.0.13",
        "fe80::4001:aff:fe80:d",
        "fe80::38ae:4aff:fe00:b967"
      ],
      "mac": [
        "42:01:0a:80:00:0d",
        "3a:ae:4a:00:b9:67"
      ]
    },
    "agent": {
      "hostname": "[redacted]",
      "ephemeral_id": "65aab5cb-52e6-4078-8ab8-a2501b914f0a",
      "id": "a9619787-11ba-4f97-a476-f0f20aaa286d",
      "name": "[redacted]",
      "type": "auditbeat",
      "version": "7.8.0"
    },
    "ecs": {
      "version": "1.5.0"
    }
  },
  "fields": {
    "file.created": [],
    "system.audit.package.installtime": [],
    "process.parent.start": [],
    "event.end": [],
    "file.ctime": [
      "2020-07-07T14:23:03.437Z"
    ],
    "tls.client.not_after": [],
    "system.audit.user.password.last_changed": [],
    "event.ingested": [],
    "@timestamp": [
      "2020-07-07T14:23:03.446Z"
    ],
    "file.mtime": [
      "2020-07-07T14:23:03.433Z"
    ],
    "event.created": [],
    "file.accessed": [],
    "system.audit.host.boottime": [],
    "tls.server.not_before": [],
    "package.installed": [],
    "tls.client.not_before": [],
    "event.start": [],
    "tls.server.not_after": [],
    "process.start": []
  },
  "highlight": {
    "file.path": [
      "@kibana-highlighted-field@/etc/hosts@/kibana-highlighted-field@"
    ],
    "event.category": [
      "@kibana-highlighted-field@file@/kibana-highlighted-field@"
    ],
    "event.type": [
      "@kibana-highlighted-field@change@/kibana-highlighted-field@"
    ],
    "agent.version": [
      "@[email protected]@/kibana-highlighted-field@"
    ]
  },
  "sort": [
    1594131783446
  ]
}

macOS

{
  "_index": "auditbeat-7.8.0-2020.06.18-000001",
  "_type": "_doc",
  "_id": "cucsC3MBpYSg_Jq8tud0",
  "_version": 1,
  "_score": null,
  "_source": {
    "@timestamp": "2020-07-01T16:19:05.374Z",
    "agent": {
      "id": "5d637140-43d7-4703-a184-14cf0935acf3",
      "name": "[redacted]",
      "type": "auditbeat",
      "version": "7.8.0",
      "hostname": "[redacted].lan",
      "ephemeral_id": "9c86abf0-2bc1-421a-b700-755030402aaa"
    },
    "hash": {
      "sha1": "774e692ef2d4b361a83645163b855c953c9eb784"
    },
    "event": {
      "action": [
        "moved"
      ],
      "module": "file_integrity",
      "dataset": "file",
      "kind": "event",
      "category": [
        "file"
      ],
      "type": [
        "change"
      ]
    },
    "service": {
      "type": "file_integrity"
    },
    "file": {
      "type": "file",
      "gid": "0",
      "hash": {
        "sha1": "774e692ef2d4b361a83645163b855c953c9eb784"
      },
      "inode": "18430329",
      "ctime": "2020-07-01T16:19:05.351Z",
      "size": 440,
      "owner": "root",
      "path": "/private/etc/hosts",
      "mode": "0644",
      "mtime": "2020-07-01T16:19:05.351Z",
      "group": "wheel",
      "uid": "0"
    },
    "ecs": {
      "version": "1.5.0"
    },
    "host": {
      "hostname": "[redacted].local",
      "architecture": "x86_64",
      "os": {
        "kernel": "19.5.0",
        "build": "19F101",
        "platform": "darwin",
        "version": "10.15.5",
        "family": "darwin",
        "name": "Mac OS X"
      },
      "id": "7A1239AF-8E8B-5928-A112-24FDC1718CF9",
      "name": "[redacted]",
      "ip": [
        "fe80::aede:48ff:fe00:1122",
        "192.168.158.141",
        "fe80::8897:16ff:fe26:4adc",
        "fe80::8897:16ff:fe26:4adc",
        "fe80::7a58:640d:54c9:582b",
        "fe80::1c29:ae02:3755:4761",
        "fe80::95e2:9d1:58c1:3663",
        "fe80::5c66:70c2:b21c:8e2a",
        "fe80::e87c:124a:867d:d757",
        "fe80::3b40:c943:ef9c:e9a6"
      ],
      "mac": [
        "ac:de:48:00:11:22",
        "a6:83:e7:ac:3c:98",
        "a4:83:e7:ac:3c:98",
        "82:ae:16:c5:30:01",
        "82:ae:16:c5:30:00",
        "82:ae:16:c5:30:05",
        "82:ae:16:c5:30:04",
        "82:ae:16:c5:30:01",
        "06:83:e7:ac:3c:98",
        "8a:97:16:26:4a:dc",
        "8a:97:16:26:4a:dc"
      ]
    }
  },
  "fields": {
    "file.created": [],
    "system.audit.package.installtime": [],
    "process.parent.start": [],
    "event.end": [],
    "file.ctime": [
      "2020-07-01T16:19:05.351Z"
    ],
    "tls.client.not_after": [],
    "system.audit.user.password.last_changed": [],
    "event.ingested": [],
    "@timestamp": [
      "2020-07-01T16:19:05.374Z"
    ],
    "file.mtime": [
      "2020-07-01T16:19:05.351Z"
    ],
    "event.created": [],
    "file.accessed": [],
    "system.audit.host.boottime": [],
    "tls.server.not_before": [],
    "package.installed": [],
    "tls.client.not_before": [],
    "event.start": [],
    "tls.server.not_after": [],
    "process.start": []
  },
  "highlight": {
    "file.path": [
      "@kibana-highlighted-field@/private/etc/hosts@/kibana-highlighted-field@"
    ],
    "event.category": [
      "@kibana-highlighted-field@file@/kibana-highlighted-field@"
    ],
    "event.type": [
      "@kibana-highlighted-field@change@/kibana-highlighted-field@"
    ],
    "agent.version": [
      "@[email protected]@/kibana-highlighted-field@"
    ]
  },
  "sort": [
    1593620345374
  ]
}

Windows

{
  "_index": "auditbeat-7.8.0-2020.06.18-000001",
  "_type": "_doc",
  "_id": "SpTxzHIBrrfU-yfroJmi",
  "_version": 1,
  "_score": null,
  "_source": {
    "@timestamp": "2020-06-19T14:18:05.780Z",
    "host": {
      "id": "5907f390-9809-47ea-973c-1f4202199ba6",
      "ip": [
        "fe80::f162:c81d:49cb:8aa0",
        "10.0.2.15"
      ],
      "mac": [
        "08:00:27:b7:f8:e7"
      ],
      "hostname": "DESKTOP-[redacted]",
      "architecture": "x86_64",
      "name": "DESKTOP-[redacted]",
      "os": {
        "name": "Windows 10 Home",
        "kernel": "10.0.17763.1282 (WinBuild.160101.0800)",
        "build": "17763.1282",
        "platform": "windows",
        "version": "10.0",
        "family": "windows"
      }
    },
    "event": {
      "module": "file_integrity",
      "dataset": "file",
      "kind": "event",
      "category": [
        "file"
      ],
      "type": [
        "change"
      ],
      "action": [
        "updated"
      ]
    },
    "service": {
      "type": "file_integrity"
    },
    "file": {
      "path": "C:\\Windows\\System32\\drivers\\etc\\hosts",
      "type": "file",
      "ctime": "2018-09-15T07:31:36.585Z",
      "size": 806,
      "mtime": "2020-06-19T14:18:05.779Z",
      "inode": "281474976752119",
      "drive_letter": "C",
      "uid": "S-1-5-18",
      "hash": {
        "sha1": "9820fbd5cdae3f54855021cffea9c0716876e8ea"
      },
      "owner": "NT AUTHORITY\\SYSTEM"
    },
    "hash": {
      "sha1": "9820fbd5cdae3f54855021cffea9c0716876e8ea"
    },
    "agent": {
      "hostname": "DESKTOP-[redacted]",
      "ephemeral_id": "d4d06c6e-6bd3-4d4a-a0d3-509a59f9898a",
      "id": "12263842-4868-4cfb-9d96-47d304d4762c",
      "name": "DESKTOP-[redacted]",
      "type": "auditbeat",
      "version": "7.8.0"
    },
    "ecs": {
      "version": "1.5.0"
    }
  },
  "fields": {
    "file.created": [],
    "system.audit.package.installtime": [],
    "process.parent.start": [],
    "event.end": [],
    "file.ctime": [
      "2018-09-15T07:31:36.585Z"
    ],
    "tls.client.not_after": [],
    "system.audit.user.password.last_changed": [],
    "event.ingested": [],
    "@timestamp": [
      "2020-06-19T14:18:05.780Z"
    ],
    "file.mtime": [
      "2020-06-19T14:18:05.779Z"
    ],
    "event.created": [],
    "file.accessed": [],
    "system.audit.host.boottime": [],
    "tls.server.not_before": [],
    "package.installed": [],
    "tls.client.not_before": [],
    "event.start": [],
    "tls.server.not_after": [],
    "process.start": []
  },
  "highlight": {
    "file.path": [
      "@kibana-highlighted-field@C:\\Windows\\System32\\drivers\\etc\\hosts@/kibana-highlighted-field@"
    ],
    "event.category": [
      "@kibana-highlighted-field@file@/kibana-highlighted-field@"
    ],
    "event.type": [
      "@kibana-highlighted-field@change@/kibana-highlighted-field@"
    ],
    "agent.version": [
      "@[email protected]@/kibana-highlighted-field@"
    ]
  },
  "sort": [
    1592576285780
  ]
}

[New Rule] Screen Capture Using XWD

Required Info

Screenshots taken from a compromised computer can provide hackers with access to private emails, photographs, and information found in sensitive documents. This data can be used by the attackers to build profiles of a target for social engineering attacks and blackmail or even just to release the information out in the wild.

This rule leverages Auditbeat to detect the screen capture utility xwd, commonly used by adversaries to collect screenshots on Linux.

  • Eventing Sources:
    Auditbeat

  • Target Operating Systems:
    Linux

  • Platforms
    NA

  • Target ECS Version: 1.5.0

  • New fields required in ECS for this? Associated issue/PR:
    NA

Optional Info

Example Data

{
  "_index": "auditbeat-7.8.0-2020.06.18-000001",
  "_type": "_doc",
  "_id": "QN73BXMBpYSg_Jq8uffi",
  "_version": 1,
  "_score": null,
  "_source": {
    "@timestamp": "2020-06-30T16:03:07.136Z",
    "event": {
      "category": [
        "process"
      ],
      "type": [
        "start"
      ],
      "action": "process_started",
      "module": "system",
      "dataset": "process",
      "kind": "event"
    },
    "process": {
      "start": "2020-06-30T16:03:06.159Z",
      "hash": {
        "sha1": "d002477f778056ec80f8e4424bce253fcbe65f71"
      },
      "entity_id": "VDbHkqaGbUTO+cH8",
      "ppid": 3436,
      "working_directory": "/home",
      "name": "xwd",
      "executable": "/usr/bin/xwd",
      "args": [
        "xwd",
        "-out",
        "test4.png"
      ],
      "pid": 3438
    },
    "message": "Process xwd (PID: 3438) by user root STARTED",
    "user": {
      "group": {
        "id": "0",
        "name": "root"
      },
      "effective": {
        "id": "0",
        "group": {
          "id": "0"
        }
      },
      "saved": {
        "id": "0",
        "group": {
          "id": "0"
        }
      },
      "name": "root",
      "id": "0"
    },
    "service": {
      "type": "system"
    },
    "agent": {
      "version": "7.8.0",
      "hostname": "auditbeat-tester",
      "ephemeral_id": "9bf49f86-b72c-48cc-b9fb-073608742ef3",
      "id": "7ee015fc-77a7-4213-87de-8bf401c2ee4f",
      "name": "centos-elastic-virtualbox-text",
      "type": "auditbeat"
    },
    "ecs": {
      "version": "1.5.0"
    },
    "host": {
      "containerized": false,
      "ip": [
        "10.0.2.15",
        "fe80::a00:27ff:fe9a:2194",
        "192.168.122.1"
      ],
      "mac": [
        "08:00:27:9a:21:94",
        "52:54:00:34:32:1e",
        "52:54:00:34:32:1e"
      ],
      "name": "centos-elastic-virtualbox-text",
      "hostname": "auditbeat-tester",
      "architecture": "x86_64",
      "os": {
        "codename": "Core",
        "platform": "centos",
        "version": "7 (Core)",
        "family": "redhat",
        "name": "CentOS Linux",
        "kernel": "3.10.0-1127.10.1.el7.x86_64"
      },
      "id": "5fb6114516ea5841a72f076b9e15c758"
    }
  },
  "fields": {
    "file.created": [],
    "system.audit.package.installtime": [],
    "process.parent.start": [],
    "event.end": [],
    "file.ctime": [],
    "tls.client.not_after": [],
    "system.audit.user.password.last_changed": [],
    "event.ingested": [],
    "@timestamp": [
      "2020-06-30T16:03:07.136Z"
    ],
    "file.mtime": [],
    "event.created": [],
    "file.accessed": [],
    "system.audit.host.boottime": [],
    "tls.server.not_before": [],
    "package.installed": [],
    "tls.client.not_before": [],
    "event.start": [],
    "tls.server.not_after": [],
    "process.start": [
      "2020-06-30T16:03:06.159Z"
    ]
  },
  "highlight": {
    "process.name": [
      "@kibana-highlighted-field@xwd@/kibana-highlighted-field@"
    ],
    "event.category": [
      "@kibana-highlighted-field@process@/kibana-highlighted-field@"
    ],
    "event.type": [
      "@kibana-highlighted-field@start@/kibana-highlighted-field@"
    ]
  },
  "sort": [
    1593532987136
  ]
}

image
image
image

[New Rule] Cobalt Strike C2 Beacon

Description

Cobalt Strike is a threat emulation platform commonly modified and used by adversaries to conduct network attack and
exploitation campaigns. This rule detects a network activity algorithm leveraged by Cobalt Strike implant beacons for
command and control.

Required Info

  • Eventing Sources:
    Packetbeat

  • Target Operating Systems:
    Windows, Linux, macOS

  • Platforms
    NA

  • Target ECS Version: 1.5.0

  • New fields required in ECS for this? Associated issue/PR: NA

Optional Info

Example Data

image
image

{
  "_index": "packetbeat-7.8.0-2020.06.30-000001",
  "_type": "_doc",
  "_id": "YBCVJXMBpYSg_Jq84Ubn",
  "_version": 1,
  "_score": null,
  "_source": {
    "@timestamp": "2020-07-06T19:24:05.122Z",
    "query": "GET /",
    "http": {
      "response": {
        "headers": {
          "content-length": 221,
          "content-type": "text/html; charset=utf-8"
        },
        "status_phrase": "found",
        "status_code": 302,
        "bytes": 553,
        "body": {
          "bytes": 221
        }
      },
      "version": "1.1",
      "request": {
        "method": "get",
        "bytes": 99,
        "headers": {
          "content-length": 0
        }
      }
    },
    "ecs": {
      "version": "1.5.0"
    },
    "host": {
      "name": "-.lan",
      "architecture": "x86_64",
      "os": {
        "kernel": "19.5.0",
        "build": "19F101",
        "platform": "darwin",
        "version": "10.15.5",
        "family": "darwin",
        "name": "Mac OS X"
      },
      "id": "7A1239AF-8E8B-5928-A112-24FDC1718CF9",
      "ip": [
        "fe80::aede:48ff:fe00:1122",
        "192.168.158.141",
        "fe80::d41e:18ff:fe91:769e",
        "fe80::d41e:18ff:fe91:769e",
        "fe80::ee35:843a:f08b:405d",
        "fe80::ae1:df41:6bff:4a07"
      ],
      "mac": [
        "ac:de:48:00:11:22",
        "a6:83:e7:ac:3c:98",
        "a4:83:e7:ac:3c:98",
        "82:ae:16:c5:30:00",
        "82:ae:16:c5:30:01",
        "82:ae:16:c5:30:05",
        "82:ae:16:c5:30:04",
        "82:ae:16:c5:30:01",
        "06:83:e7:ac:3c:98",
        "d6:1e:18:91:76:9e",
        "d6:1e:18:91:76:9e"
      ],
      "hostname": "-.lan"
    },
    "agent": {
      "id": "ab255210-3866-4b07-9579-91f3a78eb996",
      "name": "-.lan",
      "type": "packetbeat",
      "version": "7.8.0",
      "hostname": "-.lan",
      "ephemeral_id": "692f5e75-ed6a-4831-ae2c-cbbea587fc49"
    },
    "source": {
      "ip": "192.168.158.141",
      "port": 53399,
      "bytes": 99
    },
    "event": {
      "kind": "event",
      "category": "network_traffic",
      "dataset": "http",
      "duration": 209673000,
      "start": "2020-07-06T19:24:05.122Z",
      "end": "2020-07-06T19:24:05.332Z"
    },
    "type": "http",
    "client": {
      "ip": "192.168.158.141",
      "port": 53399,
      "bytes": 99
    },
    "user_agent": {
      "original": "curl/7.64.1"
    },
    "url": {
      "full": "http://aaa.stage.14919005.www1.-.com/",
      "scheme": "http",
      "domain": "aaa.stage.14919005.www1.-.com",
      "path": "/"
    },
    "destination": {
      "bytes": 553,
      "ip": "x.x.x.x",
      "port": 80,
      "domain": "aaa.stage.14919005.www1.-.com"
    },
    "server": {
      "bytes": 553,
      "ip": "x.x.x.x",
      "port": 80,
      "domain": "aaa.stage.14919005.www1.-.com"
    },
    "network": {
      "direction": "outbound",
      "community_id": "1:P/8uuFDtZC3d/6E9UfxeQNYqwW0=",
      "bytes": 652,
      "type": "ipv4",
      "transport": "tcp",
      "protocol": "http"
    },
    "status": "OK",
    "method": "get"
  },
  "fields": {
    "tls.server_certificate.not_before": [],
    "tls.detailed.client_certificate.not_after": [],
    "file.created": [],
    "process.parent.start": [],
    "tls.server_certificate.not_after": [],
    "event.end": [
      "2020-07-06T19:24:05.332Z"
    ],
    "file.ctime": [],
    "tls.client_certificate.not_after": [],
    "tls.client.not_after": [],
    "event.ingested": [],
    "@timestamp": [
      "2020-07-06T19:24:05.122Z"
    ],
    "tls.client_certificate.not_before": [],
    "file.mtime": [],
    "event.created": [],
    "file.accessed": [],
    "tls.server.not_before": [],
    "package.installed": [],
    "tls.client.not_before": [],
    "tls.detailed.server_certificate.not_after": [],
    "event.start": [
      "2020-07-06T19:24:05.122Z"
    ],
    "tls.server.not_after": [],
    "tls.detailed.server_certificate.not_before": [],
    "process.start": [],
    "tls.detailed.client_certificate.not_before": []
  },
  "highlight": {
    "event.category": [
      "@kibana-highlighted-field@network_traffic@/kibana-highlighted-field@"
    ],
    "destination.domain": [
      "@[email protected]@/kibana-highlighted-field@"
    ],
    "type": [
      "@kibana-highlighted-field@http@/kibana-highlighted-field@"
    ]
  },
  "sort": [
    1594063445122
  ]
}

[New Rule] High Number of Okta User Password Reset or Unlock Attempts

Description

Identifies a high number of Okta user password reset or account unlock attempts. An adversary may attempt to obtain unauthorized access to an account using these methods in order to blend in with normal activity in their target's environment and evade detection.

event.module:okta and event.dataset:okta.system and event.action:(system.email.account_unlock.sent_message or system.email.password_reset.sent_message or system.sms.send_account_unlock_message or system.sms.send_password_reset_message or system.voice.send_account_unlock_call or system.voice.send_password_reset_call or user.account.unlock_token)

This will be a threshold rule type that aggregates events by the Okta username field (okta.actor.id) with a count of 5 and a lookback value of 120 minutes.

Required Info

  • Eventing Sources:

filebeat-*

  • Platforms

Okta

  • Target ECS Version: 1.5.0
  • New fields required in ECS for this? No
  • Related issues or PRs N/A

Optional Info

Example Data

image

[FR] Add command to upload a rule from TOML to Kibana

Is your feature request related to a problem? Please describe.
We should be able to upload rules from this repository directly to the detection engine without needing to wait for the next release. This command will help users that want to try rules out without upgrading their stack, and

Related to #17

Describe the solution you'd like
We should have a simple command to do this. Give it the path to the TOML (or a rule ID, not sure which is better) and take any additional arguments needed to communicate with the stack.

There are a few edge cases to consider, and make sure we handle well:

  • what if the rule already exists in the detection engine?
    we should show an error, and return a non-zero exit code
  • what if a rule doesn't work with that version of Kibana?
    we might need to add more information to [metadata], such as the minimum stack version. or we assume that the API validation will handle this correctly
  • what if we upload a rule as a custom rule, then later it retrieves the same rule from a stack update?
    will the rule uuid clash? will things break? do we raise an error message?

Describe alternatives you've considered
N/A

Additional context
Just #17. Meta issue coming soon

Question: How risk score is calculated?

Hi folks, first off, thanks for making this repository open source.

Second, had I been paying attention, I would have noticed that each rule has a risk rating associated to it, may I ask how is that risk calculation being created? or is it part of the secret sauce?

Thanks.

[Question] Need assistance in generating rules for Nginx logs

Hi Elastic Team,

We are trying to write new rules based on our research. We have been successful in writing rules from the Kibana SIEM dashboard, however on exporting the rules we get them in ndjson format. However, on writing a rule with the same query using detection_rules python module, it errors out.

Example: Rule for a vulnerability on Nginx

  • On shipping the logs with filebeat nginx module, there are fields which are not in ECS.
  • How should I go about writing rules for them using detection_rules module, as it errors out on using non-ECS fields?

Command: rlwrap python3 -m detection_rules create-rule ../nginx_rules/"testing".toml
Error log:

query (required): log.file.path: "/var/log/nginx/error.log" AND message: "checking"                                                                      
ecs_version (multi, comma separated): 1.5.0                                                                                                              
Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/cyber/research/detection-rules/detection_rules/__main__.py", line 28, in <module>
    main()
  File "/home/cyber/research/detection-rules/detection_rules/__main__.py", line 25, in main
    root(prog_name="detection_rules")
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  • Is there a possibility to export the rules in TOML format from Kibana instead of ndjson?
  • How can we import rules in TOML format into Kibana?

[Rule Tuning] Local Service Commands

Description

The "Local Service Commands" can be very noisy and is a little too broad. We could tighten it down by adding checks for binPath= or other more suspicious arguments. We could also remove start.

query = '''
event.category:process and event.type:(start or process_started) and
process.name:sc.exe and
process.args:(config or create or failure or start)
'''

Could this rule be broken down into additional sub-rules? What's our current workflow for removing rules?
Some better rule ideas that are better tuned to suspicious behaviors and a little more FP resistant:

  • Service Escalation with sc.exe: look for user.name != "system"
  • Service Modification: look for binPath or the other known fields in the command line, confirm that \\ isn't in it
  • Remove Service Execution: look for an arg starting with double backslashes \\ and start
  • Remove Service Creation or Modification: look for an arg starting with double backslashes \\ and one of the other non-start commands that's already in our list

Example Data

[Rule Tuning] Update Cloud rules with note field

Description

The current cloud rules for Okta and AWS require a module to be enabled within Filebeat. This may not be abundantly clear to the user, so thanks to @peasead review on PR #67, it was determined the notes field would be a good spot to inform the user of this necessity in order for the cloud rules to trigger on events as intended.

Example

Addition to AWS rule:
note = "The AWS Filebeat module must be enabled to use this rule."

Addition to each Okta rule:
note = "The Okta Filebeat module must be enabled to use this rule."

[Bug] Kibana commit needs to update NOTICE.txt

Describe the bug
Pre-commit hook not working and NOTICE.txt not updated.
I think we need to run a few yarn commands. We could also add a toggle to suppress this behavior, so we can skip this, because yarn isn't always set up.

Context: elastic/kibana#71332 (comment) from @spong

@rw-access @brokensound77 -- needed to run node scripts/notice from kibana root to regenerate the NOTICE.txt. I missed this as part of #32 as I was thinking it happened during the build, but looks like it needs to be done manually after updating any notice.ts (similar to i18n behavior). I'll defer to you for where this command fits in with your existing rules workflow, but would it be fine to add as part of the generation of this PR?

To Reproduce
See https://github.com/elastic/kibana/pull/71332/commits

Expected behavior
NOTICE.txt populated correctly

Screenshots
N/A

[Rule tuning] disable iptables rule can be bypassed

Description

i noticed that the rule regarding the deactivation of iptables service is lacking a case when systemctl is being used to stop iptables instead of firewalld, as shown here: https://support.rackspace.com/how-to/use-iptables-with-centos-7/

event.action:(executed or process_started) and (process.name:service and process.args:stop or process.name:chkconfig and process.args:off) and process.args:(ip6tables or iptables) or process.name:systemctl and process.args:(firewalld and (disable or stop or kill))

Example Data

the command not being captured by current rules is:

systemctl (stop|kill|disable) ip(6)tables

Edit (by @rw-access): switched to issue template and updated title

[FR] Add support for threshold rules

Is your feature request related to a problem? Please describe.
N/A

Describe the solution you'd like
Our 7.9 release will provide support for threshold rules in the SIEM's detection engine. We need to add support to the detection-rules CLI for threshold rules.

Describe alternatives you've considered
N/A

Additional context
Below is an email threshold rule that I exported from the SIEM. Please note that including a value for field is not mandatory.

Example threshold rule
{
    "author": [],
    "actions": [],
    "created_at": "2020-07-15T03:55:01.873Z",
    "updated_at": "2020-07-15T13:23:49.678Z",
    "created_by": "threatpunter",
    "description": "Identifies a high number of failed Okta user authentication attempts from a single IP address, which could be indicative of a brute force or password spraying attack. An adversary may attempt a brute force or password spraying attack to obtain unauthorized access to user accounts.",
    "enabled": true,
    "false_positives": [],
    "filters": [],
    "from": "now-360s",
    "id": "a216c36f-1e60-49d7-b452-e6c0c0011929",
    "immutable": false,
    "index": [
        "filebeat-*"
    ],
    "interval": "5m",
    "rule_id": "db2efd83-4e17-4fd8-a56c-13c526722540",
    "language": "kuery",
    "license": "",
    "output_index": ".siem-signals-username-default",
    "max_signals": 100,
    "risk_score": 47,
    "risk_score_mapping": [],
    "name": "Okta Brute Force or Password Spraying Attack",
    "query": "event.module:okta and event.dataset:okta.system and event.category:authentication and event.outcome:failure",
    "references": [],
    "meta": {
        "from": "1m",
        "kibana_siem_app_url": "http://localhost:5603/jyr/app/security/detections"
    },
    "severity": "medium",
    "severity_mapping": [],
    "updated_by": "threatpunter",
    "tags": [
        "Elastic",
        "Okta"
    ],
    "to": "now",
    "type": "threshold",
    "threat": [],
    "threshold": {
        "field": "source.ip",
        "value": 25
    },
    "throttle": "no_actions",
    "version": 2,
    "exceptions_list": []
}

[Rule Tuning] Logic bug for iptables disable rule

Description

Noticed a bug with the iptables rule after merging #5.

The existing and/or logic didn't properly account for precedence, and parts of the query were missing parentheses.

event.action:(executed or process_started) and (process.name:service and process.args:stop or process.name:chkconfig and process.args:off) and process.args:(ip6tables or iptables or firewalld) or process.name:systemctl and process.args:((firewalld or iptables or ip6tables) and (disable or stop or kill))

I believe the recommended change should be this

event.category:process and event.action:(executed or process_started) and (
  (process.name:service and process.args:stop) or
  (process.name:chkconfig and process.args:off) or
  (process.name:systemctl and process.args:(disable or stop or kill))
) and process.args:(ip6tables or iptables or firewalld)

[Rule Tuning] Detection Network/Firewall Rules should ignore events with an outcome of denied/deny

Description

As initially reported in elastic/kibana#71374 by @BenB196

Describe the feature:
The SIEM detection rules for network events for "event.action : firewall-rules" should not create signals for "event.outcome : (deny or denied)" values.

Describe a specific use case for the feature:
These are all false positive results as the firewall is doing its job and preventing these connections. In high traffic firewalls, 10s or 100s of thousands of signals can be generated within 24 hours, that are all false positives.

[Question] How to import rules from this repository in Kibana?

Hi Elastic, thanks you for opening this repository to the public.

I was wondering if it was possible to fork this repository, add some of our environment specific rules and import them in our Kibana instance.

It would improve our workflow:

  • We could write tests for our rules
  • We would keep a history of our rules
  • We could frequently update Elastic's rules (only need to pull from upstream)

I see there is a build-release command, but I'm not sure if I can import the generated package in Kibana or if it's only when you release a new version of Kibana

Thanks.

[FR] Make the schema prompting less verbose

Is your feature request related to a problem? Please describe.
The create-rule command prompts for a lot of metadata. Most of the time, I just automatically press <enter>.

Describe the solution you'd like
Instead, we could have another prompt: "set additional values?" or something and ask for any non-required fields there.

Describe alternatives you've considered
None

Additional context
None

[Bug] Add support for CLI to handle rule ndjson files with extra metadata

Describe the bug
Exported rules which are in ndjson format have extra metadata which causes importing to fail for several CLI commands.

  • create-rule -c
  • load-from-file
  • view-rule
{"actions":[],"created_at":"2020-07-21T13:52:18.527Z","updated_at":"2020-07-21T13:52:18.544Z","created_by":"elastic","description":"This is a demo of an example rule","enabled":false,"false_positives":["Sometimes cmd is benign :)"],"filters":[],"from":"now-360s","id":"90f6cdcb-6211-4985-ab75-c6253fcdd868","immutable":false,"index":["winlogbeat-*"],"interval":"5m","rule_id":"6b9d2af4-84c8-4e38-a697-2d5d455a9e86","language":"kuery","output_index":".siem-signals-default","max_signals":100,"risk_score":50,"name":"Example Custom Rule","query":"process.name:cmd.exe and process.args:\"-c\"","references":["https://google.com"],"meta":{"from":"1m","kibana_siem_app_url":"https://703efb61c6ee4b14b36f7f4a9674a5ea.us-west-2.aws.found.io:9243/app/siem"},"severity":"low","updated_by":"elastic","tags":["Windows"],"to":"now","type":"query","threat":[{"framework":"MITRE ATT&CK","tactic":{"id":"TA0002","reference":"https://attack.mitre.org/tactics/TA0002","name":"Execution"},"technique":[{"id":"T1064","name":"Scripting","reference":"https://attack.mitre.org/techniques/T1064"}]}],"throttle":"no_actions","note":"## Triage\nWhy are they executing `cmd.exe`?","version":1}
{"exported_count":1,"missing_rules":[],"missing_rules_count":0}

To Reproduce
Steps to reproduce the behavior:

  1. export a rule from kibana
  2. python -m detection_rules -c export.ndjson new_rule.toml --required-only

Expected behavior
The CLI should be updated to be able to understand importing the ndjson formatted rules and ignore extra data. It currently has the ability to parse json, toml, and yaml.

Rules will still need to be able to validate against the schema to be accepted

Additional context
related to #76

Add multiple tactics to ATT&CK mappings

Once elastic/kibana#69166 merges, we'll be able to map tactics -> techniques with a many-many relationship. This will let us map rules to tactics without requiring a technique, and will give us better control over the relationships. We'll be able to express relationships like this:

  • Privilege Escalation, Persistence
    • New Service
    • Scheduled Task
  • Execution
    • Service Execution
  • Lateral Movement

We need to:

  1. update the schema
  2. add tactics to rules that are missing one because they don't use a specific technique
  3. find other cases where we can add more techniques/tactics or improve rule.threat in other ATT&CK related ways

[FR] Add command to check the version-lock

Is your feature request related to a problem? Please describe.
For automation/CI, we should have a command that returns a non-zero exit code if the versions have drifted from the locked .json file.

Describe the solution you'd like
Use ctx.exit(1) if the version hashes don't match. Maybe a new command called check-locked-versions or something.

Describe alternatives you've considered
n/a

Additional context
n/a

[New Rule] AWS IAM Assume Role Brute Force

Description

Identifies a high number of failed attempts to assume an AWS IAM role. IAM roles are used to delegate access to users or services. An adversary may attempt to enumerate IAM roles in order to determine whether a role exists or not before attempting to assume or hijack the discovered role.

I'm creating this issue to document a draft threshold rule based on @bm11100's existing research.

Like other AWS IAM policies, the AssumeRole permissions are very flexible and, if misconfigured, could lead to unintended consequences, like a confused-deputy attack.

There is a module in Pacu that enumerates roles against a target account. By default, it comes with a 1100+ word wordlist with some common/generic role names. When a role is discovered, the script will alert you. If one is discovered and it is misconfigured to allow role-assumption from a wide group, the script is capable of automatically assuming the discovered role and outputting the issued credentials.

event.module:aws and event.dataset:aws.cloudtrail and event.provider:iam.amazonaws.com and event.action:UpdateAssumeRolePolicy and aws.cloudtrail.error_code:MalformedPolicyDocumentException and event.outcome:failure

We need to decide on a suitable threshold value and whether we want to aggregate events by the source.ip field. Adversaries can execute this attack through a fragmented set of nodes and accounts, so we may not want to aggregate by this field.

image

image

Required Info

  • Eventing Sources:
    filebeat-*

  • Platforms

AWS CloudTrail

  • Target ECS Version: 1.5.0
  • New fields required in ECS for this? No
  • Related issues or PRs N/A

Optional Info

Example Data

[FR] Autogenerate index.ts file for Kibana rules

Is your feature request related to a problem? Please describe.
Simplifying packaging to Kibana

Describe the solution you'd like
Autogenerate kibana rules index.ts file at package generation.

Describe alternatives you've considered
N/A

Additional context
related to #36
related to #32

[Question] How to write rules with multiple queries

Hi Elastic team,
What's the best way to rules with multiple queries?
Example:
KQL query: log.file.path : "/var/log/testing/testing.log" and message : "keyword1" or message : "keyword2" or message : "keyword3 or message : "keyword4"
Is there any limitation on query length and what is the recommended way to write rules with multiple queries?

Authentication Failed Events detection rule not in concordance with ECS

Describe the bug
The detection rule Authentication Failed Events is not using an allowed value for event.outcome

It is defined as
event.category : "authentication" and event.outcome: _failed"
and should be
event.category : "authentication" and event.outcome: "failure"

Acording to ECS Documentation
image

Desktop (please complete the following information):

  • OS: All
  • Version: All

Additional context
Add any other context about the problem here.

[FR] Add kql.to_dsl() method

Is your feature request related to a problem? Please describe.
There doesn't seem to be an API exposed from Kibana to convert KQL to query DSL.
We should integrate this functionality.

Describe the solution you'd like
This should be fairly straightforward, use the Walker class and convert the AST to a dict.
We should also make sure to use match and match_phrase consistently with Kibana.

Describe alternatives you've considered
Kibana exposes an API.

Additional context
None

[New Rule] Halfbaked C2 Beacon

Description

Halfbaked is a malware family leveraged to establish persistence in a contested network. This rule detects a network activity algorithm leveraged by Halfbaked implant beacons for
command and control.

Required Info

  • Eventing Sources:
    Packetbeat

  • Target Operating Systems:
    Windows

  • Platforms
    NA

  • Target ECS Version: 1.5.0

  • New fields required in ECS for this? Associated issue/PR: NA

Optional Info

Example Data

image
image

{
  "_index": "packetbeat-7.8.0-2020.06.30-000001",
  "_type": "_doc",
  "_id": "cOg9C3MBrrfU-yfrYvP9",
  "_version": 1,
  "_score": null,
  "_source": {
    "@timestamp": "2020-07-01T16:37:17.418Z",
    "http": {
      "response": {
        "headers": {
          "content-type": "text/html; charset=utf-8",
          "content-length": 9115
        },
        "status_phrase": "not found",
        "status_code": 404,
        "bytes": 9705,
        "body": {
          "bytes": 9115
        }
      },
      "version": "1.1",
      "request": {
        "method": "get",
        "bytes": 81,
        "headers": {
          "content-length": 0
        }
      }
    },
    "status": "Error",
    "url": {
      "domain": "x.x.x.x",
      "path": "/cd",
      "full": "http://x.x.x.x/cd",
      "scheme": "http"
    },
    "ecs": {
      "version": "1.5.0"
    },
    "type": "http",
    "user_agent": {
      "original": "curl/7.64.1"
    },
    "network": {
      "community_id": "1:eLS6+Rc1Np7We/6AZZJDlhByOEY=",
      "bytes": 9786,
      "type": "ipv4",
      "transport": "tcp",
      "protocol": "http",
      "direction": "outbound"
    },
    "host": {
      "ip": [
        "fe80::aede:48ff:fe00:1122",
        "192.168.158.141",
        "fe80::8897:16ff:fe26:4adc",
        "fe80::8897:16ff:fe26:4adc",
        "fe80::7a58:640d:54c9:582b",
        "fe80::1c29:ae02:3755:4761",
        "fe80::95e2:9d1:58c1:3663",
        "fe80::5c66:70c2:b21c:8e2a",
        "fe80::e87c:124a:867d:d757",
        "fe80::3b40:c943:ef9c:e9a6"
      ],
      "mac": [
        "ac:de:48:00:11:22",
        "a6:83:e7:ac:3c:98",
        "a4:83:e7:ac:3c:98",
        "82:ae:16:c5:30:01",
        "82:ae:16:c5:30:00",
        "82:ae:16:c5:30:05",
        "82:ae:16:c5:30:04",
        "82:ae:16:c5:30:01",
        "06:83:e7:ac:3c:98",
        "8a:97:16:26:4a:dc",
        "8a:97:16:26:4a:dc"
      ],
      "name": "x.local",
      "hostname": "x.local",
      "architecture": "x86_64",
      "os": {
        "platform": "darwin",
        "version": "10.15.5",
        "family": "darwin",
        "name": "Mac OS X",
        "kernel": "19.5.0",
        "build": "19F101"
      },
      "id": "7A1239AF-8E8B-5928-A112-24FDC1718CF9"
    },
    "method": "get",
    "source": {
      "ip": "192.168.158.141",
      "port": 53429,
      "bytes": 81
    },
    "destination": {
      "bytes": 9705,
      "ip": "x.x.x.x",
      "port": 80
    },
    "query": "GET /cd",
    "event": {
      "end": "2020-07-01T16:37:17.612Z",
      "kind": "event",
      "category": "network_traffic",
      "dataset": "http",
      "duration": 194069000,
      "start": "2020-07-01T16:37:17.418Z"
    },
    "client": {
      "ip": "x.x.x.x",
      "port": 53429,
      "bytes": 81
    },
    "server": {
      "bytes": 9705,
      "ip": "x.x.x.x",
      "port": 80
    },
    "agent": {
      "version": "7.8.0",
      "hostname": "x.local",
      "ephemeral_id": "80323dae-a9ec-48f1-8d08-0e09bb9f8a9e",
      "id": "ab255210-3866-4b07-9579-91f3a78eb996",
      "name": "x.local",
      "type": "packetbeat"
    }
  },
  "fields": {
    "tls.server_certificate.not_before": [],
    "tls.detailed.client_certificate.not_after": [],
    "file.created": [],
    "process.parent.start": [],
    "tls.server_certificate.not_after": [],
    "event.end": [
      "2020-07-01T16:37:17.612Z"
    ],
    "file.ctime": [],
    "tls.client_certificate.not_after": [],
    "tls.client.not_after": [],
    "event.ingested": [],
    "@timestamp": [
      "2020-07-01T16:37:17.418Z"
    ],
    "tls.client_certificate.not_before": [],
    "file.mtime": [],
    "event.created": [],
    "file.accessed": [],
    "tls.server.not_before": [],
    "package.installed": [],
    "tls.client.not_before": [],
    "tls.detailed.server_certificate.not_after": [],
    "event.start": [
      "2020-07-01T16:37:17.418Z"
    ],
    "tls.server.not_after": [],
    "tls.detailed.server_certificate.not_before": [],
    "process.start": [],
    "tls.detailed.client_certificate.not_before": []
  },
  "highlight": {
    "event.category": [
      "@kibana-highlighted-field@network_traffic@/kibana-highlighted-field@"
    ],
    "type": [
      "@kibana-highlighted-field@http@/kibana-highlighted-field@"
    ],
    "url.full": [
      "@kibana-highlighted-field@http://x.x.x.x/cd@/kibana-highlighted-field@"
    ],
    "event.dataset": [
      "@kibana-highlighted-field@http@/kibana-highlighted-field@"
    ],
    "network.transport": [
      "@kibana-highlighted-field@tcp@/kibana-highlighted-field@"
    ]
  },
  "sort": [
    1593621437418
  ]
}

[New Rule] Detect SIGRed DNS Exploit

Description

SIGRed (CVE-2020-1350) is a wormable, critical vulnerability (CVSS base score of 10.0) in the Windows DNS server that affects Windows Server versions 2003 to 2019, and can be triggered by a malicious DNS response. As the service is running in elevated privileges (SYSTEM), if exploited successfully, an attacker is granted Domain Administrator rights, effectively compromising the entire corporate infrastructure.

Required Info

  • Eventing Sources:
    Filebeat, Packetbeat

  • Target Operating Systems:
    Windows

  • Platforms
    Network

  • Target ECS Version: 1.5.0

  • New fields required in ECS for this? NA

  • Related issues or PRs

Optional Info

Example Data

image
image
Filebeat

{
  "_index": "filebeat-7.8.0-2020.07.14-000001",
  "_id": "NCn-V3MB7Zv7jX8-0gtP",
  "_version": 1,
  "_score": null,
  "_source": {
    "agent": {
      "hostname": "rock01",
      "name": "rock01",
      "id": "56b26c0c-3752-43d3-8fe4-3e552cbb3257",
      "type": "filebeat",
      "ephemeral_id": "cdf408d0-1d8d-4d95-b167-58d5af04fc3e",
      "version": "7.8.0",
      "user": {
        "name": "rock_logstash_writer"
      }
    },
    "log": {
      "file": {
        "path": "/data/suricata/eve.json"
      },
      "offset": 17725766
    },
    "destination": {
      "geo": {
        "continent_name": "North America",
        "country_iso_code": "US",
        "location": {
          "lon": -97.822,
          "lat": 37.751
        }
      },
      "as": {
        "number": 15169,
        "organization": {
          "name": "Google LLC"
        }
      },
      "address": "8.8.8.8",
      "port": 53,
      "bytes": 68638,
      "ip": "8.8.8.8",
      "packets": 47
    },
    "source": {
      "address": "192.168.1.183",
      "port": 54149,
      "bytes": 112,
      "ip": "192.168.1.183",
      "packets": 1
    },
    "fileset": {
      "name": "eve"
    },
    "network": {
      "community_id": "1:bNYowsrr3kqUGA9OqGSRMpg8wSc=",
      "bytes": 68750,
      "transport": "tcp",
      "packets": 48
    },
    "tags": [
      "suricata",
      "beats_input_raw_event"
    ],
    "input": {
      "type": "log"
    },
    "@timestamp": "2020-07-16T14:19:21.000Z",
    "related": {
      "ip": [
        "192.168.1.183",
        "8.8.8.8"
      ]
    },
    "ecs": {
      "version": "1.5.0"
    },
    "service": {
      "type": "suricata"
    },
    "host": {
      "hostname": "rock01",
      "os": {
        "kernel": "3.10.0-1127.13.1.el7.x86_64",
        "codename": "Core",
        "name": "CentOS Linux",
        "family": "redhat",
        "version": "7 (Core)",
        "platform": "centos"
      },
      "ip": [
        "10.10.8.2"
      ],
      "containerized": false,
      "name": "rock01",
      "id": "b97c1797f883eb5f3d72134d451d0384",
      "mac": [
        "42:01:0a:80:00:1e",
        "42:01:0a:0a:08:02"
      ],
      "architecture": "x86_64"
    },
    "@version": "1",
    "suricata": {
      "eve": {
        "in_iface": "eth0",
        "tcp": {
          "tcp_flags_ts": "00",
          "tcp_flags_tc": "00",
          "tcp_flags": "00"
        },
        "community_id": "1:bNYowsrr3kqUGA9OqGSRMpg8wSc=",
        "event_type": "flow",
        "flow_id": 2301593654278,
        "flow": {
          "reason": "timeout",
          "alerted": false,
          "state": "new",
          "age": 0
        }
      }
    },
    "event": {
      "duration": 93000000,
      "original": "{\"timestamp\":\"2020-07-16T14:19:21.000191+0000\",\"flow_id\":2301593654278,\"in_iface\":\"eth0\",\"event_type\":\"flow\",\"src_ip\":\"192.168.1.183\",\"src_port\":54149,\"dest_ip\":\"8.8.8.8\",\"dest_port\":53,\"proto\":\"TCP\",\"flow\":{\"pkts_toserver\":1,\"pkts_toclient\":47,\"bytes_toserver\":112,\"bytes_toclient\":68638,\"start\":\"2020-07-16T14:18:20.070662+0000\",\"end\":\"2020-07-16T14:18:20.163675+0000\",\"age\":0,\"state\":\"new\",\"reason\":\"timeout\",\"alerted\":false},\"community_id\":\"1:bNYowsrr3kqUGA9OqGSRMpg8wSc=\",\"tcp\":{\"tcp_flags\":\"00\",\"tcp_flags_ts\":\"00\",\"tcp_flags_tc\":\"00\"}}",
      "created": "2020-07-16T14:19:21.864Z",
      "kind": "event",
      "module": "suricata",
      "start": "2020-07-16T14:18:20.070Z",
      "end": "2020-07-16T14:18:20.163Z",
      "type": [
        "connection",
        "start"
      ],
      "category": [
        "network"
      ],
      "dataset": "suricata.eve"
    }
  },
  "fields": {
    "event.start": [
      "2020-07-16T14:18:20.070Z"
    ],
    "event.end": [
      "2020-07-16T14:18:20.163Z"
    ],
    "@timestamp": [
      "2020-07-16T14:19:21.000Z"
    ],
    "event.created": [
      "2020-07-16T14:19:21.864Z"
    ],
    "suricata.eve.flow.start": [
      "2020-07-16T14:18:20.070Z"
    ],
    "suricata.eve.timestamp": [
      "2020-07-16T14:19:21.000Z"
    ]
  },
  "highlight": {
    "event.category": [
      "@kibana-highlighted-field@network@/kibana-highlighted-field@"
    ],
    "event.type": [
      "@kibana-highlighted-field@connection@/kibana-highlighted-field@"
    ]
  },
  "sort": [
    1594909161000
  ]
}

Packetbeat

{
  "_index": "packetbeat-7.8.0-2020.07.14-000001",
  "_id": "9DpgWHMBM_3LKPKZJgvu",
  "_version": 1,
  "_score": null,
  "_source": {
    "server": {
      "port": 53,
      "bytes": 65517,
      "ip": "10.128.0.8"
    },
    "agent": {
      "hostname": "rock01",
      "name": "rock01",
      "id": "e9258ca9-ba0d-4c4b-b182-0c1b58f8ee63",
      "type": "packetbeat",
      "ephemeral_id": "b0fd4e12-9681-427d-84c5-0b666f2a397a",
      "version": "7.8.0",
      "user": {
        "name": "rock_logstash_writer"
      }
    },
    "method": "QUERY",
    "resource": "9.evilexample.com",
    "query": "class IN, type SIG, 9.evilexample.com",
    "destination": {
      "port": 53,
      "bytes": 65517,
      "ip": "10.128.0.8"
    },
    "dns": {
      "op_code": "QUERY",
      "response_code": "NOERROR",
      "question": {
        "registered_domain": "evilexample.com",
        "top_level_domain": "com",
        "etld_plus_one": "evilexample.com",
        "name": "9.evilexample.com",
        "subdomain": "9",
        "type": "SIG",
        "class": "IN"
      },
      "answers_count": 1,
      "authorities_count": 0,
      "answers": [],
      "flags": {
        "authoritative": false,
        "truncated_response": false,
        "recursion_desired": true,
        "recursion_available": true,
        "checking_disabled": false,
        "authentic_data": true
      },
      "additionals_count": 0,
      "id": 4278,
      "header_flags": [
        "RD",
        "RA",
        "AD"
      ],
      "type": "answer"
    },
    "source": {
      "port": 58623,
      "bytes": 48,
      "ip": "10.5.1.78"
    },
    "type": "dns",
    "network": {
      "protocol": "dns",
      "community_id": "1:GFhCWPY0iIPBD69oYrIoBSYxuSg=",
      "bytes": 65565,
      "transport": "tcp",
      "type": "ipv4"
    },
    "tags": [
      "beats_input_raw_event"
    ],
    "@timestamp": "2020-07-16T16:05:37.019Z",
    "ecs": {
      "version": "1.5.0"
    },
    "host": {
      "hostname": "rock01",
      "os": {
        "kernel": "3.10.0-1127.13.1.el7.x86_64",
        "codename": "Core",
        "name": "CentOS Linux",
        "family": "redhat",
        "version": "7 (Core)",
        "platform": "centos"
      },
      "ip": [
        "10.10.8.2"
      ],
      "containerized": false,
      "name": "rock01",
      "id": "b97c1797f883eb5f3d72134d451d0384",
      "mac": [
        "42:01:0a:80:00:1e",
        "42:01:0a:0a:08:02"
      ],
      "architecture": "x86_64"
    },
    "@version": "1",
    "client": {
      "port": 58623,
      "bytes": 48,
      "ip": "10.5.1.78"
    },
    "event": {
      "duration": 2365987,
      "kind": "event",
      "start": "2020-07-16T16:05:37.019Z",
      "end": "2020-07-16T16:05:37.022Z",
      "category": "network_traffic",
      "dataset": "dns"
    },
    "status": "OK"
  },
  "fields": {
    "event.end": [
      "2020-07-16T16:05:37.022Z"
    ],
    "@timestamp": [
      "2020-07-16T16:05:37.019Z"
    ],
    "event.start": [
      "2020-07-16T16:05:37.019Z"
    ]
  },
  "highlight": {
    "event.category": [
      "@kibana-highlighted-field@network_traffic@/kibana-highlighted-field@"
    ],
    "type": [
      "@kibana-highlighted-field@dns@/kibana-highlighted-field@"
    ]
  },
  "sort": [
    1594915537019,
    65565
  ]
}

[FR] Automatically create Kibana branch/PR

Is your feature request related to a problem? Please describe.
Definitely. DRY!

Describe the solution you'd like
A simple command to python -m detection_rules or make that will generate the Kibana PR for us. Then we don't have to keep doing it.

Describe alternatives you've considered
N/A

Additional context
Related PR for 7.7 for reference elastic/kibana#61903

[New Rule] Okta Brute Force or Password Spraying Attack

Description

Identifies a high number of failed Okta user authentication attempts from a single IP address, which could be indicative of a brute force or password spraying attack. An adversary may attempt a brute force or password spraying attack to obtain unauthorized access to user accounts.

I've been experimenting with the threshold-based rule type that is under development for the detection engine. See issue elastic/kibana#68409 for details on the feature.

The example below searches for 25 failed Okta authentication events during a 5 minute window from a single source.ip. The search results are being aggregated by the source.ip field.

event.module:okta and event.dataset:okta.system and event.category:authentication and event.outcome:failure

Something to think about is that if we could aggregate results by event.module and another field like source.ip, we could have a generic brute force rule type for multiple modules/data sources. E.g. Okta, AWS, Azure, GCP, etc. However, having a single rule versus many could introduce some challenges with tweaking the interval and lookback times, as our users attempt to tune the rule to filter normal behavior in their environment.

image

image

image

Required Info

  • Eventing Sources:

filebeat-*

  • Target Operating Systems

N/A

  • Platforms

Okta

  • Target ECS Version: 1.5.0
  • New fields required in ECS for this? No
  • Associated issue/PR: N/A

Optional Info

  • References:

Example Data

[New Rule] Auditd Login Anomalies

Description

We've been shipping auditd anomaly events via auditbeat for awhile. The official guidance of these events (all of message type ANOM_*) are that they should be forwarded to or handled by an intrusion detection system. I'm currently working on getting some sample events set up with various PAM setups (since various PAM modules emit these). These events are generated using auditbeat 7.8 (will add more as I fumble through my PAM configs):


Too many login failures (AUDIT_ANOM_LOGIN_FAILURES)

{
  "@timestamp": "2020-07-08T00:50:02.295Z",
  "@metadata": {
    "beat": "auditbeat",
    "type": "_doc",
    "version": "7.8.0"
  },
  "event": {
    "action": "failed-log-in-too-many-times-to",
    "outcome": "success",
    "module": "auditd",
    "category": "anomoly"
  },
  "user": {
    "name": "foo",
    "id": "1001",
    "selinux": {
      "role": "unconfined_r",
      "user": "unconfined_u",
      "category": "c0.c1023",
      "domain": "unconfined_t",
      "level": "s0-s0"
    },
    "audit": {
      "id": "1000",
      "name": "vagrant"
    }
  },
  "process": {
    "pid": 7342,
    "executable": "/usr/bin/su"
  },
  "auditd": {
    "session": "6",
    "summary": {
      "actor": {
        "primary": "vagrant",
        "secondary": "foo"
      },
      "object": {
        "primary": "pts/2",
        "secondary": "localhost.localdomain",
        "type": "user-session"
      },
      "how": "/usr/bin/su"
    },
    "message_type": "anom_login_failures",
    "sequence": 2081,
    "result": "success",
    "data": {
      "hostname": "localhost.localdomain",
      "terminal": "pts/2"
    }
  },
  "service": {
    "type": "auditd"
  },
  "ecs": {
    "version": "1.5.0"
  },
  "host": {
    "id": "5c2096907995401eaa49821ba2a7ab78",
    "containerized": false,
    "ip": [
      "10.0.2.15",
      "fe80::5054:ff:fefb:eed0"
    ],
    "mac": [
      "52:54:00:fb:ee:d0"
    ],
    "name": "localhost.localdomain",
    "hostname": "localhost.localdomain",
    "architecture": "x86_64",
    "os": {
      "name": "Fedora",
      "kernel": "5.7.7-200.fc32.x86_64",
      "platform": "fedora",
      "version": "32 (Cloud Edition)",
      "family": "redhat"
    }
  },
  "agent": {
    "version": "7.8.0",
    "hostname": "localhost.localdomain",
    "ephemeral_id": "abee6478-2ce6-4e3e-bafc-3d623cbded08",
    "id": "68306cb1-5efe-473e-88ed-f96e2e671065",
    "name": "localhost.localdomain",
    "type": "auditbeat"
  }
}

Anomalous location (AUDIT_ANOM_LOGIN_LOCATION)

{
  "@timestamp": "2020-07-08T01:59:50.657Z",
  "@metadata": {
    "beat": "auditbeat",
    "type": "_doc",
    "version": "7.8.0"
  },
  "user": {
    "selinux": {
      "category": "c0.c1023",
      "domain": "unconfined_t",
      "level": "s0-s0",
      "role": "unconfined_r",
      "user": "unconfined_u"
    },
    "audit": {
      "id": "1000",
      "name": "vagrant"
    },
    "name": "vagrant",
    "id": "1000"
  },
  "process": {
    "pid": 8294,
    "executable": "/usr/bin/su"
  },
  "auditd": {
    "session": "6",
    "summary": {
      "how": "/usr/bin/su",
      "actor": {
        "secondary": "foo",
        "primary": "vagrant"
      },
      "object": {
        "type": "user-session",
        "primary": "pts/2",
        "secondary": "localhost.localdomain"
      }
    },
    "message_type": "anom_login_location",
    "sequence": 2443,
    "result": "success",
    "data": {
      "acct": "foo",
      "terminal": "pts/2",
      "op": "PAM:pam_access",
      "hostname": "localhost.localdomain"
    }
  },
  "service": {
    "type": "auditd"
  },
  "ecs": {
    "version": "1.5.0"
  },
  "host": {
    "name": "localhost.localdomain",
    "hostname": "localhost.localdomain",
    "architecture": "x86_64",
    "os": {
      "family": "redhat",
      "name": "Fedora",
      "kernel": "5.7.7-200.fc32.x86_64",
      "platform": "fedora",
      "version": "32 (Cloud Edition)"
    },
    "id": "5c2096907995401eaa49821ba2a7ab78",
    "containerized": false,
    "ip": [
      "10.0.2.15",
      "fe80::5054:ff:fefb:eed0"
    ],
    "mac": [
      "52:54:00:fb:ee:d0"
    ]
  },
  "agent": {
    "id": "68306cb1-5efe-473e-88ed-f96e2e671065",
    "name": "localhost.localdomain",
    "type": "auditbeat",
    "version": "7.8.0",
    "hostname": "localhost.localdomain",
    "ephemeral_id": "877aa726-7b66-436b-98dc-6c506ae9be0f"
  },
  "event": {
    "category": "anomoly",
    "action": "attempted-log-in-from-unusual-place-to",
    "outcome": "success",
    "module": "auditd"
  }
}

Too many login sessions (AUDIT_ANOM_LOGIN_SESSIONS)

{
  "@timestamp": "2020-07-08T02:06:10.457Z",
  "@metadata": {
    "beat": "auditbeat",
    "type": "_doc",
    "version": "7.8.0"
  },
  "ecs": {
    "version": "1.5.0"
  },
  "host": {
    "os": {
      "platform": "fedora",
      "version": "32 (Cloud Edition)",
      "family": "redhat",
      "name": "Fedora",
      "kernel": "5.7.7-200.fc32.x86_64"
    },
    "id": "5c2096907995401eaa49821ba2a7ab78",
    "containerized": false,
    "ip": [
      "10.0.2.15",
      "fe80::5054:ff:fefb:eed0"
    ],
    "mac": [
      "52:54:00:fb:ee:d0"
    ],
    "hostname": "localhost.localdomain",
    "name": "localhost.localdomain",
    "architecture": "x86_64"
  },
  "agent": {
    "ephemeral_id": "877aa726-7b66-436b-98dc-6c506ae9be0f",
    "id": "68306cb1-5efe-473e-88ed-f96e2e671065",
    "name": "localhost.localdomain",
    "type": "auditbeat",
    "version": "7.8.0",
    "hostname": "localhost.localdomain"
  },
  "event": {
    "category": "anomoly",
    "action": "opened-too-many-sessions-to",
    "outcome": "failure",
    "module": "auditd"
  },
  "user": {
    "selinux": {
      "category": "c0.c1023",
      "domain": "sshd_t",
      "level": "s0-s0",
      "role": "system_r",
      "user": "system_u"
    },
    "audit": {
      "id": "1001",
      "name": "foo"
    },
    "name": "root",
    "id": "0"
  },
  "process": {
    "pid": 8476,
    "executable": "/usr/sbin/sshd"
  },
  "auditd": {
    "message_type": "anom_login_sessions",
    "sequence": 2520,
    "result": "fail",
    "data": {
      "terminal": "ssh",
      "hostname": "::1",
      "addr": "::1",
      "acct": "foo",
      "op": "PAM:pam_limits"
    },
    "session": "16",
    "summary": {
      "actor": {
        "primary": "foo",
        "secondary": "foo"
      },
      "object": {
        "secondary": "::1",
        "type": "user-session",
        "primary": "ssh"
      },
      "how": "/usr/sbin/sshd"
    }
  },
  "service": {
    "type": "auditd"
  }
}

Anomalous time (AUDIT_ANOM_LOGIN_TIME)

{
  "@timestamp": "2020-07-08T02:30:44.475Z",
  "@metadata": {
    "beat": "auditbeat",
    "type": "_doc",
    "version": "7.8.0"
  },
  "process": {
    "pid": 8974,
    "executable": "/usr/bin/su"
  },
  "auditd": {
    "session": "6",
    "summary": {
      "actor": {
        "primary": "vagrant",
        "secondary": "foo"
      },
      "object": {
        "primary": "pts/2",
        "secondary": "localhost.localdomain",
        "type": "user-session"
      },
      "how": "/usr/bin/su"
    },
    "message_type": "anom_login_time",
    "sequence": 2773,
    "result": "fail",
    "data": {
      "terminal": "pts/2",
      "op": "PAM:pam_time",
      "acct": "foo",
      "hostname": "localhost.localdomain"
    }
  },
  "service": {
    "type": "auditd"
  },
  "event": {
    "category": "anomoly",
    "action": "attempted-log-in-during-unusual-hour-to",
    "outcome": "failure",
    "module": "auditd"
  },
  "user": {
    "name": "vagrant",
    "id": "1000",
    "selinux": {
      "category": "c0.c1023",
      "domain": "unconfined_t",
      "level": "s0-s0",
      "role": "unconfined_r",
      "user": "unconfined_u"
    },
    "audit": {
      "id": "1000",
      "name": "vagrant"
    }
  },
  "ecs": {
    "version": "1.5.0"
  },
  "host": {
    "mac": [
      "52:54:00:fb:ee:d0"
    ],
    "hostname": "localhost.localdomain",
    "name": "localhost.localdomain",
    "architecture": "x86_64",
    "os": {
      "kernel": "5.7.7-200.fc32.x86_64",
      "platform": "fedora",
      "version": "32 (Cloud Edition)",
      "family": "redhat",
      "name": "Fedora"
    },
    "id": "5c2096907995401eaa49821ba2a7ab78",
    "containerized": false,
    "ip": [
      "10.0.2.15",
      "fe80::5054:ff:fefb:eed0"
    ]
  },
  "agent": {
    "hostname": "localhost.localdomain",
    "ephemeral_id": "877aa726-7b66-436b-98dc-6c506ae9be0f",
    "id": "68306cb1-5efe-473e-88ed-f96e2e671065",
    "name": "localhost.localdomain",
    "type": "auditbeat",
    "version": "7.8.0"
  }
}

[New Rule] RAR and PowerShell Downloaded from the Internet

Description

Detects a Roshal Archive (RAR) or PowerShell script downloaded from the internet by an internal client. Gaining initial
access to a system and then downloading encoded or encrypted tools to move laterally is a common practice for
adversaries as a way to protect their more valuable tools and TTPs. This may be atypical behavior for a managed network
and can be indicative of malware, exfiltration, or command and control.

Required Info

  • Eventing Sources:
    Packetbeat

  • Target Operating Systems:
    NA

  • Platforms
    NA

  • Target ECS Version: 1.5.0

  • New fields required in ECS for this? Associated issue/PR: NA

Optional Info

Example Data

image
image

Powershell

{
  "_index": "packetbeat-7.8.0-2020.06.30-000001",
  "_type": "_doc",
  "_id": "3smxJHMBpYSg_Jq86urB",
  "_version": 1,
  "_score": null,
  "_source": {
    "@timestamp": "2020-07-06T15:15:05.753Z",
    "http": {
      "request": {
        "bytes": 117,
        "headers": {
          "content-length": 0
        },
        "method": "get"
      },
      "response": {
        "status_code": 200,
        "bytes": 37999,
        "body": {
          "bytes": 37303
        },
        "headers": {
          "content-length": 37303,
          "content-type": "text/plain"
        },
        "status_phrase": "ok"
      },
      "version": "1.1"
    },
    "method": "get",
    "query": "GET /projects/[redacted]/[redacted].ps1",
    "ecs": {
      "version": "1.5.0"
    },
    "user_agent": {
      "original": "curl/7.64.1"
    },
    "url": {
      "scheme": "http",
      "domain": "www.[redacted].com",
      "path": "/projects/[redacted]/[redacted].ps1",
      "full": "http://www.[redacted].com/projects/[redacted]/[redacted].ps1"
    },
    "server": {
      "ip": "[redacted]",
      "port": 80,
      "domain": "www.[redacted].com",
      "bytes": 37999
    },
    "client": {
      "port": 50673,
      "bytes": 117,
      "ip": "192.168.158.141"
    },
    "host": {
      "hostname": "[redacted].lan",
      "architecture": "x86_64",
      "os": {
        "kernel": "19.5.0",
        "build": "19F101",
        "platform": "darwin",
        "version": "10.15.5",
        "family": "darwin",
        "name": "Mac OS X"
      },
      "id": "7A1239AF-8E8B-5928-A112-24FDC1718CF9",
      "name": "[redacted].lan",
      "ip": [
        "fe80::aede:48ff:fe00:1122",
        "192.168.158.141",
        "fe80::80f9:15ff:fea3:de16",
        "fe80::80f9:15ff:fea3:de16",
        "fe80::ee35:843a:f08b:405d",
        "fe80::ae1:df41:6bff:4a07"
      ],
      "mac": [
        "ac:de:48:00:11:22",
        "a6:83:e7:ac:3c:98",
        "a4:83:e7:ac:3c:98",
        "82:ae:16:c5:30:00",
        "82:ae:16:c5:30:01",
        "82:ae:16:c5:30:05",
        "82:ae:16:c5:30:04",
        "82:ae:16:c5:30:01",
        "06:83:e7:ac:3c:98",
        "82:f9:15:a3:de:16",
        "82:f9:15:a3:de:16"
      ]
    },
    "agent": {
      "name": "[redacted].lan",
      "type": "packetbeat",
      "version": "7.8.0",
      "hostname": "[redacted].lan",
      "ephemeral_id": "692f5e75-ed6a-4831-ae2c-cbbea587fc49",
      "id": "ab255210-3866-4b07-9579-91f3a78eb996"
    },
    "type": "http",
    "destination": {
      "ip": "[redacted]",
      "port": 80,
      "domain": "www.[redacted].com",
      "bytes": 37999
    },
    "network": {
      "direction": "outbound",
      "community_id": "1:oY9hTfrPAkVgjhNSH100KELpjf0=",
      "bytes": 38116,
      "type": "ipv4",
      "transport": "tcp",
      "protocol": "http"
    },
    "source": {
      "port": 50673,
      "bytes": 117,
      "ip": "192.168.158.141"
    },
    "event": {
      "start": "2020-07-06T15:15:05.753Z",
      "end": "2020-07-06T15:15:05.806Z",
      "kind": "event",
      "category": "network_traffic",
      "dataset": "http",
      "duration": 53073000
    },
    "status": "OK"
  },
  "fields": {
    "tls.server_certificate.not_before": [],
    "tls.detailed.client_certificate.not_after": [],
    "file.created": [],
    "process.parent.start": [],
    "tls.server_certificate.not_after": [],
    "event.end": [
      "2020-07-06T15:15:05.806Z"
    ],
    "file.ctime": [],
    "tls.client_certificate.not_after": [],
    "tls.client.not_after": [],
    "event.ingested": [],
    "@timestamp": [
      "2020-07-06T15:15:05.753Z"
    ],
    "tls.client_certificate.not_before": [],
    "file.mtime": [],
    "event.created": [],
    "file.accessed": [],
    "tls.server.not_before": [],
    "package.installed": [],
    "tls.client.not_before": [],
    "tls.detailed.server_certificate.not_after": [],
    "event.start": [
      "2020-07-06T15:15:05.753Z"
    ],
    "tls.server.not_after": [],
    "tls.detailed.server_certificate.not_before": [],
    "process.start": [],
    "tls.detailed.client_certificate.not_before": []
  },
  "highlight": {
    "url.path": [
      "@kibana-highlighted-field@/projects/ps_html5/Invoke-PSHtml5.ps1@/kibana-highlighted-field@"
    ],
    "event.category": [
      "@kibana-highlighted-field@network_traffic@/kibana-highlighted-field@"
    ],
    "type": [
      "@kibana-highlighted-field@http@/kibana-highlighted-field@"
    ]
  },
  "sort": [
    1594048505753
  ]
}

RAR

{
  "_index": "packetbeat-7.8.0-2020.06.30-000001",
  "_type": "_doc",
  "_id": "Nwf1KnMBrrfU-yfrtUSQ",
  "_version": 1,
  "_score": null,
  "_source": {
    "@timestamp": "2020-07-07T20:26:49.260Z",
    "user_agent": {
      "original": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36"
    },
    "method": "get",
    "url": {
      "full": "http://www.[redacted].ru/download/[redacted].rar",
      "scheme": "http",
      "domain": "www.[redacted].ru",
      "path": "/download/[redacted].rar",
      "query": "[redacted]"
    },
    "server": {
      "ip": "[redacted]",
      "port": 80,
      "domain": "www.[redacted].ru",
      "bytes": 722682
    },
    "agent": {
      "version": "7.8.0",
      "hostname": "[redacted].lan",
      "ephemeral_id": "692f5e75-ed6a-4831-ae2c-cbbea587fc49",
      "id": "ab255210-3866-4b07-9579-91f3a78eb996",
      "name": "[redacted].lan",
      "type": "packetbeat"
    },
    "ecs": {
      "version": "1.5.0"
    },
    "status": "OK",
    "type": "http",
    "host": {
      "mac": [
        "ac:de:48:00:11:22",
        "a6:83:e7:ac:3c:98",
        "a4:83:e7:ac:3c:98",
        "82:ae:16:c5:30:00",
        "82:ae:16:c5:30:01",
        "82:ae:16:c5:30:05",
        "82:ae:16:c5:30:04",
        "82:ae:16:c5:30:01",
        "06:83:e7:ac:3c:98",
        "5e:42:d5:e2:1d:ca",
        "5e:42:d5:e2:1d:ca"
      ],
      "hostname": "[redacted].local",
      "architecture": "x86_64",
      "os": {
        "name": "Mac OS X",
        "kernel": "19.5.0",
        "build": "19F101",
        "platform": "darwin",
        "version": "10.15.5",
        "family": "darwin"
      },
      "id": "7A1239AF-8E8B-5928-A112-24FDC1718CF9",
      "name": "[redacted].lan",
      "ip": [
        "fe80::aede:48ff:fe00:1122",
        "192.168.158.141",
        "fe80::5c42:d5ff:fee2:1dca",
        "fe80::5c42:d5ff:fee2:1dca",
        "fe80::ee35:843a:f08b:405d",
        "fe80::ae1:df41:6bff:4a07",
        "fe80::a658:8eb:19fa:e319",
        "fe80::469d:d24c:caab:c8d4",
        "fe80::fa3b:aa83:10ef:3341",
        "fe80::1a99:a3d3:ef7c:c96c"
      ]
    },
    "source": {
      "ip": "192.168.158.141",
      "port": 62612,
      "bytes": 529
    },
    "event": {
      "end": "2020-07-07T20:26:49.434Z",
      "kind": "event",
      "category": "network_traffic",
      "dataset": "http",
      "duration": 173661000,
      "start": "2020-07-07T20:26:49.260Z"
    },
    "query": "GET /download/[redacted].rar",
    "destination": {
      "ip": "[redacted]",
      "port": 80,
      "domain": "www.[redacted].ru",
      "bytes": 722682
    },
    "client": {
      "port": 62612,
      "bytes": 529,
      "ip": "192.168.158.141"
    },
    "network": {
      "direction": "outbound",
      "community_id": "1:lX7e06BBU2p0nuAzLu288A7UCUE=",
      "bytes": 723211,
      "type": "ipv4",
      "transport": "tcp",
      "protocol": "http"
    },
    "http": {
      "request": {
        "referrer": "https://www.google.com/",
        "bytes": 529,
        "headers": {
          "content-length": 0
        },
        "method": "get"
      },
      "response": {
        "status_code": 200,
        "bytes": 722682,
        "body": {
          "bytes": 722356
        },
        "headers": {
          "content-length": 722356,
          "content-type": "application/x-rar-compressed"
        },
        "status_phrase": "ok"
      },
      "version": "1.1"
    }
  },
  "fields": {
    "tls.server_certificate.not_before": [],
    "tls.detailed.client_certificate.not_after": [],
    "file.created": [],
    "process.parent.start": [],
    "tls.server_certificate.not_after": [],
    "event.end": [
      "2020-07-07T20:26:49.434Z"
    ],
    "file.ctime": [],
    "tls.client_certificate.not_after": [],
    "tls.client.not_after": [],
    "event.ingested": [],
    "@timestamp": [
      "2020-07-07T20:26:49.260Z"
    ],
    "tls.client_certificate.not_before": [],
    "file.mtime": [],
    "event.created": [],
    "file.accessed": [],
    "tls.server.not_before": [],
    "package.installed": [],
    "tls.client.not_before": [],
    "tls.detailed.server_certificate.not_after": [],
    "event.start": [
      "2020-07-07T20:26:49.260Z"
    ],
    "tls.server.not_after": [],
    "tls.detailed.server_certificate.not_before": [],
    "process.start": [],
    "tls.detailed.client_certificate.not_before": []
  },
  "highlight": {
    "url.path": [
      "@kibana-highlighted-field@/download/proekt_osk.rar@/kibana-highlighted-field@"
    ],
    "event.category": [
      "@kibana-highlighted-field@network_traffic@/kibana-highlighted-field@"
    ],
    "type": [
      "@kibana-highlighted-field@http@/kibana-highlighted-field@"
    ]
  },
  "sort": [
    1594153609260
  ]
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.