name: DNS Query Length Outliers - MLTK
id: 85fbcfe8-9718-4911-adf6-7000d077a3a9
version: 2
date: '2020-01-22'
author: Rico Valdez, Splunk
type: batch
datamodel:
- Network_Resolution
description: This search allows you to identify DNS requests that are unusually large
  for the record type being requested in your environment.
search: '| tstats `security_content_summariesonly` count min(_time) as start_time
  max(_time) as end_time values(DNS.src) as src values(DNS.dest) as dest from datamodel=Network_Resolution
  by DNS.query DNS.record_type | search DNS.record_type=* |  `drop_dm_object_name(DNS)`
  | `security_content_ctime(firstTime)` | `security_content_ctime(lastTime)` | eval
  query_length = len(query) | apply dns_query_pdfmodel threshold=0.01 | rename "IsOutlier(query_length)"
  as isOutlier | search isOutlier > 0 | sort -query_length | table start_time end_time
  query record_type count src dest query_length | `dns_query_length_outliers___mltk_filter` '
how_to_implement: 'To successfully implement this search, you will need to ensure
  that DNS data is populating the Network_Resolution data model. In addition, the
  Machine Learning Toolkit (MLTK) version 4.2 or greater must be installed on your
  search heads, along with any required dependencies. Finally, the support search
  "Baseline of DNS Query Length - MLTK" must be executed before this detection search,
  because it builds a machine-learning (ML) model over the historical data used by
  this search. It is important that this search is run in the same app context as
  the associated support search, so that the model created by the support search is
  available for use. You should periodically re-run the support search to rebuild
  the model with the latest data available in your environment.\

  This search produces fields (`query`,`query_length`,`count`) that are not yet supported
  by ES Incident Review and therefore cannot be viewed when a notable event is raised.
  These fields contribute additional context to the notable. To see the additional
  metadata, add the following fields, if not already present, to Incident Review -
  Event Attributes (Configure > Incident Management > Incident Review Settings > Add
  New Entry):\\n1. **Label:** DNS Query, **Field:** query\

  1. \

  1. **Label:** DNS Query Length, **Field:** query_length\

  1. \

  1. **Label:** Number of events, **Field:** count\

  Detailed documentation on how to create a new field within Incident Review may be
  found here: `https://docs.splunk.com/Documentation/ES/5.3.0/Admin/Customizenotables#Add_a_field_to_the_notable_event_details`'
known_false_positives: If you are seeing more results than desired, you may consider
  reducing the value for threshold in the search. You should also periodically re-run
  the support search to re-build the ML model on the latest data.
references: []
tags:
  analytic_story:
  - Hidden Cobra Malware
  - Suspicious DNS Traffic
  - Command and Control
  asset_type: Endpoint
  cis20:
  - CIS 8
  - CIS 12
  kill_chain_phases:
  - Command and Control
  mitre_attack_id:
  - T1071.004
  nist:
  - PR.PT
  - DE.AE
  - DE.CM
  product:
  - Splunk Enterprise
  - Splunk Enterprise Security
  - Splunk Cloud
  required_fields:
  - _time
  - DNS.src
  - DNS.dest
  - DNS.query
  - DNS.record_type
  security_domain: network
