# Risk Analytics for UEBA

Supported in:

This document provides an overview of the rule sets in the Risk Analytics for UEBA category, the
required data, and configuration you can use to tune the alerts generated
by each rule set. These rule sets help identify threats by evaluating the
supported log sources.

> [!CAUTION]
> **Caution:** Dashboards don't support Risk Analytics for UEBA rules.

## Rule set descriptions

The following rule sets are available in the Risk Analytics for UEBA category and are
grouped by the type of patterns detected:

### Authentication

- **New Login by User to Device**: a user logged in to a new device.
- **Anomalous Authentication Events by User**: a single user entity had anomalous authentication events recently, compared to historical usage.
- **Failed Authentications by Device**: a single-device entity had many failed login attempts recently, compared to historical usage.
- **Failed Authentications by User**: a single-user entity had many failed login attempts recently, compared to historical usage.

### Network traffic analysis

- **Anomalous Inbound Bytes by Device**: significant amount of data recently uploaded to single device entity, compared to historical usage.
- **Anomalous Outbound Bytes by Device**: significant amount of data recently downloaded from a single device entity, compared to historical usage.
- **Anomalous Total Bytes by Device**: a device entity recently uploaded and downloaded a significant amount of data, compared to historical usage.
- **Anomalous Inbound Bytes by User**: a single-user entity recently downloaded a significant amount of data, compared to historical usage.
- **Anomalous Total Bytes by User**: a user entity recently uploaded and downloaded a significant amount of data recently, compared to historical usage.
- **Brute Force then Successful Login by User**: a single-user entity from one IP address had several failed authentication attempts to a certain application before successfully logging in.

### Peer group-based detections

- **Anomalous or Excessive Logins for a Newly Created User**: anomalous or excessive
  authentication activity for a recently created user. This uses creation time from
  AD Context data.

- **Anomalous or Excessive Suspicious Actions for a Newly Created User**:
  anomalous or excessive activity (including, but not limited to, HTTP telemetry,
  process execution, and group modification) for a recently created
  user. This uses creation time from AD Context data.

### Suspicious actions

- **Excessive Account Creation by Device**: a device entity created several new user accounts.
- **Excessive Alerts by User** : a large number of security alerts from an antivirus or endpoint device (for example, *connection was blocked* , *malware was detected* ) were reported about a user entity, which was much greater than historical patterns. These are events where the `security_result.action` UDM field is set to `BLOCK`.

### Data loss prevention-based detections

- **Anomalous or Excessive Processes with Data Exfiltration Capabilities**: anomalous or excessive activity for processes associated with data exfiltration capabilities such as keyloggers, screenshots, and remote access. This uses file metadata enrichment from VirusTotal.

## Required data needed by Risk Analytics for UEBA category

This section details the data required by each rule set category for optimal
performance. While UEBA detections are designed to work with all supported default
parsers, using the following specific data types maximizes their benefit.
For a complete list of supported default parsers, see
[Supported log types and default parsers](https://docs.cloud.google.com/chronicle/docs/ingestion/parser-list/supported-default-parsers).

### Authentication

To use any of these rule sets, collect log data from either
Azure AD Directory Audit (`AZURE_AD_AUDIT`) or Windows Event (`WINEVTLOG`).

For `WINEVTLOG`, you must configure your data collection configuration to include the following Windows `Event IDs` in the `Security` event log `Channel`.
These events map directly to the `Event types` (for example, `USER_LOGIN` or `PROCESS_LAUNCH`) used by the detection engine.

#### Windows Event ID requirements

| Event type | Windows Event ID |
|---|---|
| USER_LOGIN | `529, 4624, 4625, 4626, 4648, 4672, 4768, 4769, 4770, 4771, 4777, 4820, 4821, 4964` |
| USER_CREATION | `4720` |
| NETWORK_CONNECTION | `4096, 4097, 4321, 5156, 5632, 5633, 5157` |
| GROUP_MODIFICATION | `4728, 4729, 4732, 4733, 4735, 4737, 4745, 4746, 4747, 4750, 4751, 4752, 4755, 4756, 4757, 4760, 4761, 4762, 4764, 4784, 4785, 4786, 4787, 4788, 4791` |
| PROCESS_LAUNCH | `4688` |
| PROCESS_OPEN | `4663, 4670, 4691, 8002` |

### Network traffic analysis

To use any of these rule sets, collect log data that captures network activity.
For example, from devices such as FortiGate (`FORTINET_FIREWALL`),
Check Point (`CHECKPOINT_FIREWALL`), Zscaler (`ZSCALER_WEBPROXY`), CrowdStrike Falcon (`CS_EDR`),
or Carbon Black (`CB_EDR`).

### Peer group-based detections

To use any of these rule sets, collect log data from either
Azure AD Directory Audit (`AZURE_AD_AUDIT`) or Windows Event (`WINEVTLOG`).

### Suspicious actions

Rule sets in this group each use a different type of data.

#### Excessive Account Creation by Device rule set

To use this rule set, collect log data from either
Azure AD Directory Audit (`AZURE_AD_AUDIT`) or Windows Event (`WINEVTLOG`).

#### Excessive Alerts by User rule set

To use this rule set, collect log data that captures endpoint activities or
audit data, such as that recorded by CrowdStrike Falcon (`CS_EDR`),
Carbon Black (`CB_EDR`), or Azure AD Directory Audit (`AZURE_AD_AUDIT`).

### Data loss prevention-based detections

To use any of these rule sets, collect log data that captures process and file activities,
such as that recorded by CrowdStrike Falcon (`CS_EDR`), Carbon Black (`CB_EDR`),
or SentinelOne EDR (`SENTINEL_EDR`).

## Field dependencies

This section describes the metrics and dimension fields that Google SecOps UEBA rules use.

### Metric dependencies

The following table lists the metrics and the corresponding UDM search queries that define the events that contribute to each metric.

| Metric | UDM search query for events contributing to the metric |
|---|---|
| `AUTH_ATTEMPTS_FAIL` | `metadata.event_type = "USER_LOGIN" AND security_result.action != "UNKNOWN_ACTION" AND security_result.action != "ALLOW"` |
| `AUTH_ATTEMPTS_SUCCESS` | `metadata.event_type = "USER_LOGIN" AND (security_result.action = "UNKNOWN_ACTION" OR security_result.action = "ALLOW")` |
| `AUTH_ATTEMPTS_TOTAL` | `metadata.event_type = "USER_LOGIN" AND security_result.action >= "UNKNOWN_ACTION"` |
| `DNS_BYTES_OUTBOUND` | `network.sent_bytes > 0 AND (network.ip_protocol = "UDP" AND target.port = 53) OR (network.ip_protocol = "TCP" AND (target.port = 53 OR target.port=3000))` |
| `DNS_QUERIES_FAIL` | `network.dns.id > 0 AND network.dns.response_code != 0` |
| `DNS_QUERIES_SUCCESS` | `network.dns.id > 0 AND network.dns.response_code = 0` |
| `DNS_QUERIES_TOTAL` | `network.dns.id > 0` |
| `FILE_EXECUTIONS_FAIL` | `metadata.event_type = "PROCESS_LAUNCH" AND security_result.action != "ALLOW"` |
| `FILE_EXECUTIONS_SUCCESS` | `metadata.event_type = "PROCESS_LAUNCH" AND security_result.action = "ALLOW"` |
| `FILE_EXECUTIONS_TOTAL` | `metadata.event_type = "PROCESS_LAUNCH"` |
| `HTTP_QUERIES_FAIL` | `network.http.method != "" AND (network.http.response_code >= 400 OR network.http.response_code = 0)` |
| `HTTP_QUERIES_SUCCESS` | `network.http.method != "" AND network.http.response_code < 400` |
| `HTTP_QUERIES_TOTAL` | `network.http.method != ""` |
| `NETWORK_BYTES_INBOUND` | `network.received_bytes > 0 AND network.received_bytes < 1000000000000000` |
| `NETWORK_BYTES_OUTBOUND` | `network.sent_bytes > 0 AND network.sent_bytes < 1000000000000000` |
| `NETWORK_BYTES_TOTAL` | `(network.received_bytes > 0 AND network.received_bytes < 1000000000000000) OR (network.sent_bytes > 0 AND network.sent_bytes < 1000000000000000)` |
| `NETWORK_FLOWS_INBOUND` | `network.received_bytes > 0 AND network.received_bytes < 1000000000000000` |
| `NETWORK_FLOWS_OUTBOUND` | `network.sent_bytes > 0 AND network.sent_bytes < 1000000000000000` |
| `NETWORK_FLOWS_TOTAL` | `(network.received_bytes > 0 AND network.received_bytes < 1000000000000000) OR (network.sent_bytes > 0 AND network.sent_bytes < 1000000000000000)` |
| `RESOURCE_READ_FAIL` | `(metadata.event_type = "FILE_OPEN" OR metadata.event_type = "RESOURCE_READ") AND security_result.action != "UNKNOWN_ACTION" AND security_result.action != "ALLOW"` |
| `RESOURCE_READ_SUCCESS` | `(metadata.event_type = "FILE_OPEN" OR metadata.event_type = "RESOURCE_READ") AND (security_result.action = "UNKNOWN_ACTION" OR security_result.action = "ALLOW")` |
| `RESOURCE_READ_TOTAL` | `(metadata.event_type = "FILE_OPEN" OR metadata.event_type = "RESOURCE_READ")` |
| `RESOURCE_WRITTEN_FAIL` | `(metadata.event_type = "FILE_CREATION" OR metadata.event_type = "RESOURCE_CREATION") AND security_result.action != "UNKNOWN_ACTION" AND security_result.action != "ALLOW"` |
| `RESOURCE_WRITTEN_SUCCESS` | `(metadata.event_type = "FILE_CREATION" OR metadata.event_type = "RESOURCE_CREATION") AND (security_result.action = "UNKNOWN_ACTION" OR security_result.action = "ALLOW")` |
| `RESOURCE_WRITTEN_TOTAL` | `(metadata.event_type = "FILE_CREATION" OR metadata.event_type = "RESOURCE_CREATION")` |

### Dimension dependencies

The following table lists the dimensions and the corresponding UDM field options available for filtering or grouping.

| Dimension | Field options |
|---|---|
| Principal Device | `principal.asset.asset_id` `principal.asset.hostname` `principal.asset.ip` `principal.asset.mac` `principal.asset.product_object_id` |
| Target Device | `target.asset.asset_id` `target.asset.hostname` `target.asset.ip` `target.asset.mac` `target.asset.product_object_id` |
| Principal User | `principal.user.email_addresses` `principal.user.employee_id` `principal.user.product_object_id` `principal.user.userid` `principal.user.windows_sid` |
| Target User | `target.user.email_addresses` `target.user.employee_id` `target.user.product_object_id` `target.user.userid` `target.user.windows_sid` |
| Target Service | `target.application` |
| Target IP | `target.ip` |
| Principal Process File Path | `principal.process.file.full_path` |
| Principal Process File Hash | `principal.process.file.sha256` |
| Principal File Hash | `principal.file.sha256` |
| Principal Country | `principal.ip_geo_artifact.location.country_or_region` |
| Security Category | `security_result.category` |
| Principal Network Organization Name | `principal.ip_geo_artifact.network.organization_name` |
| Target Network Organization Name | `target.ip_geo_artifact.network.organization_name` |
| Client Certificate Hash | `network.tls.client.certificate.sha256` |
| DNS Query Type | `network.dns.questions.type` |
| DNS Domain | `network.dns_domain` |
| HTTP User Agent | `network.http.user_agent` |
| Event Type | `metadata.event_type` |
| Operating System | `principal.platform` |

## Tuning alerts returned by rule sets in this category

You can reduce the number of detections a rule or rule set generates using
[rule exclusions](https://docs.cloud.google.com/chronicle/docs/investigation/alert-suppression#suppress-rule-exclusions).

A rule exclusion defines the criteria used to exclude an event from being evaluated by
the rule set, or by specific rules in the rule set. Create one or more rule exclusions
to help reduce the volume of detections. For more information, see
[Configure alert suppression](https://docs.cloud.google.com/chronicle/docs/investigation/alert-suppression).

## Example of a rule for Risk Analytics for UEBA category

The following example shows how to create a rule to generate detections on
any entity hostname whose risk score is greater than `100`:

    rule EntityRiskScore {
      meta:
      events:
        $e1.principal.hostname != ""
        $e1.principal.hostname = $hostname

        $e2.graph.entity.hostname = $hostname
        $e2.graph.risk_score.risk_window_size.seconds = 86400 // 24 hours
        $e2.graph.risk_score.risk_score >= 100

        // Run deduplication across the risk score.
        $rscore = $e2.graph.risk_score.risk_score

      match:
        // Dedup on hostname and risk score across a 4 hour window.
        $hostname, $rscore over 4h

      outcome:
        // Force these risk score based rules to have a risk score of zero to
        // prevent self feedback loops.
        $risk_score = 0

      condition:
        $e1 and $e2
    }

This example rule also performs a self deduplication using the match
section. If a rule detection might trigger, but the hostname and risk score
remain unchanged within a 4-hour window, no new detections are created.

The only possible risk windows for entity risk score rules are either 24 hours
or 7 days (86,400 or 604,800 seconds respectively). If you don't include the
risk window size in the rule, the rule returns inaccurate results.

Entity risk score data is stored separately from entity context data. To use
both in a rule, the rule must have two separate entity events, one for the
entity context and one for the entity risk score, as shown as in the following
example:

    rule EntityContextAndRiskScore {
      meta:
      events:
        $log_in.metadata.event_type = "USER_LOGIN"
        $log_in.principal.hostname = $host

        $context.graph.entity.hostname = $host
        $context.graph.metadata.entity_type = "ASSET"

        $risk_score.graph.entity.hostname = $host
        $risk_score.graph.risk_score.risk_window_size.seconds = 604800

      match:
        $host over 2m

      outcome:
        $entity_risk_score = max($risk_score.graph.risk_score.normalized_risk_score)

      condition:
        $log_in and $context and $risk_score and $entity_risk_score > 100
    }

## What's next

- [Investigate risk using the Risk Analytics dashboard](https://docs.cloud.google.com/chronicle/docs/detection/risk-analytics-dashboard)

**Need more help?** [Get answers from Community members and Google SecOps professionals.](https://security.googlecloudcommunity.com/)