Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added solutions/images/security-d4c-metadata-tab.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions solutions/security/cloud.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,8 @@ Helps you monitor and protect your Linux VMs. It uses {{elastic-defend}} to inst

[Read the CWP for VMs docs](/solutions/security/cloud/cloud-workload-protection-for-vms.md).

## Cloud workload protection for Kubernetes

Uses Elastic's Defend for Containers (D4C) integration to provide cloud-native runtime protections for containerized environments by identifying and optionally blocking unexpected system behavior in Kubernetes containers.

[Read the D4C docs](/solutions/security/cloud/d4c/d4c-overview.md).
49 changes: 49 additions & 0 deletions solutions/security/cloud/_snippets/kubernetes-dashboard.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

The Kubernetes dashboard provides insight into Linux process data from your Kubernetes clusters. It shows sessions in detail and in the context of your monitored infrastructure.

## Requirements
* Kubernetes node operating systems must have Linux kernels 5.10.16 or higher.

Check notice on line 5 in solutions/security/cloud/_snippets/kubernetes-dashboard.md

View workflow job for this annotation

GitHub Actions / preview / vale

Elastic.Versions: Use 'or later' instead of 'or higher' when referring to versions.
* This feature is currently available on GKE and EKS using Linux hosts and Kubernetes versions that match [these](/solutions/security/cloud/d4c/d4c-overview.md#_support_matrix) specifications.


:::{image} /solutions/images/security-kubernetes-dashboard.png
:alt: The Kubernetes dashboard
:::

The numbered sections are described below:

1. The charts at the top of the dashboard provide an overview of your monitored Kubernetes infrastructure. You can hide them by clicking **Hide charts**.
2. The tree navigation menu allows you to navigate through your deployments and select the scope of the sessions table to the right. You can select any item in the menu to show its sessions. In Logical view, the menu is organized by Cluster, Namespace, Pod, and Container image. In Infrastructure view, it is organized by Cluster, Node, Pod, and Container image.
3. The sessions table displays sessions collected from the selected element of your Kubernetes infrastructure. You can view it in fullscreen by selecting the button in the table’s upper right corner. You can sort the table by any of its fields.

You can filter the data using the KQL search bar and date picker at the top of the page.

From the sessions table’s Actions column, you can take the following investigative actions:

* View details
* [Open in Timeline](/solutions/security/investigate/timeline.md)
* [Run Osquery](/solutions/security/investigate/run-osquery-from-alerts.md)
* [Analyze event](/solutions/security/investigate/visual-event-analyzer.md)
* [Open Session View](/solutions/security/investigate/session-view.md)

Session View displays Kubernetes metadata under the **Metadata** tab of the Detail panel:

:::{image} /solutions/images/security-d4c-metadata-tab.png
:alt: The Detail panel's metadata tab
:::

The **Metadata** tab is organized into these expandable sections:

* **Metadata:** `hostname`, `id`, `ip`, `mac`, `name`, Host OS information
* **Cloud:** `instance.name`, `provider`, `region`, `account.id`, `project.id`
* **Container:** `id`, `name`, `image.name`, `image.tag`, `image.hash.all`
* **Orchestrator:** `resource.ip`, `resource.name`, `resource.type`, `namespace`, `cluster.id`, `cluster.name`, `parent.type`


## Setup [_setup]

To get data for this dashboard, set up [Cloud Workload Protection for Kubernetes](/solutions/security/cloud/d4c/get-started-with-d4c.md) for the clusters you want to display on the dashboard.

::::{important}
This dashboard uses data from the `logs-*` index pattern, which is included by default in the [`securitySolution:defaultIndex` advanced setting](../../get-started/configure-advanced-settings.md). To collect data from multiple {{es}} clusters (as in a cross-cluster deployment), update `logs-*` to `*:logs-*`.
::::
63 changes: 63 additions & 0 deletions solutions/security/cloud/d4c/d4c-overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
mapped_pages:
- https://www.elastic.co/guide/en/security/current/d4c-overview.html
applies_to:
stack: beta 9.3
serverless:
security: beta
products:
- id: security
---

# Cloud workload protection for Kubernetes [d4c-overview]

Cloud workload protection for Kubernetes uses Elastic's Defend for Containers (D4C) integration to provide cloud-native runtime protections for containerized environments by identifying and optionally blocking unexpected system behavior in Kubernetes containers.


## Use cases [d4c-use-cases]


### Threat detection & threat hunting [_threat_detection_threat_hunting]

D4C for Kubernetes sends system events from your containers to {{es}}. Many of {{elastic-sec}}'s prebuilt security rules are designed to detect malicious behavior in container runtimes. These can help you detect events that should never occur in containers, such as reverse shell executions, privilege escalation, container escape attempts, and more.


### Drift detection & prevention [_drift_detection_prevention]

Cloud-native containers should be immutable, meaning that their file systems should not change during normal operations. By leveraging this principle, security teams can detect unusual system behavior with a high degree of accuracy, without relying on more resource-intensive techniques like memory scanning or attack signature detection. Elastic’s Drift Detection mechanism has a low rate of false positives, so you can deploy it in most environments without worrying about creating excessive alerts.


### Workload protection policies [_workload_protection_policies]

D4C for Kubernetes uses a flexible policy language to restrict container workloads to a set of allowlisted capabilities chosen by you. When employed with Drift and Threat Detection, this can provide multiple layers of defense.


## Support matrix [_support_matrix]

| | EKS 1.24-1.27 (AL2022) | GKE 1.24-1.27 (COS) |
| --- | --- | --- |
| Process event exports | ✓ | ✓ |
| Network event exports | ✓ | ✓ |
| File event exports | ✓ | ✓ |
| File blocking | ✓ | ✓ |
| Process blocking | ✓ | ✓ |
| Network blocking | ✗ | ✗ |
| Drift prevention | ✓ | ✓ |
| Mount point awareness | ✓ | ✓ |


## How D4C for Kubernetes works [_how_cwp_for_kubernetes_works]

When you set up the D4C integration, it gets deployed by {{agent}}. Specifically, the {{agent}} is installed as a DaemonSet on your Kubernetes clusters, where it enables D4C to use eBPF Linux Security Modules ([LSM](https://docs.kernel.org/bpf/prog_lsm.md)) and tracepoint probes to record system events. Events are evaluated against LSM hook points, enabling {{agent}} to evaluate system activity against your policy before allowing it to proceed.

Your D4C integration policy determines which system behaviors (for example, process execution or file creation or deletion) will result in which actions. *Selectors* and *responses* define each policy. Selectors define the conditions which cause the associated responses to run. Responses are associated with one or more selectors, and specify one or more actions (such as `log`, `alert`, or `block`) that should occur when the conditions defined in an associated selector are met.

Check notice on line 53 in solutions/security/cloud/d4c/d4c-overview.md

View workflow job for this annotation

GitHub Actions / preview / vale

Elastic.FutureTense: 'will result' might be in future tense. Write in the present tense to describe the state of the product as it is now.

The default [D4C policy](d4c-policies.md) sends data about all running processes to your {{es}} cluster. This data is used by {{elastic-sec}}'s prebuilt detection rules to detect malicious behavior in container workloads.

::::{note}
To learn how to set up Defend for Containers (D4C) for Kubernetes, refer to the [Get started with Defend for Containers for Kubernetes](get-started-with-d4c.md).
::::




102 changes: 102 additions & 0 deletions solutions/security/cloud/d4c/d4c-policies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
---
mapped_pages:
- https://www.elastic.co/guide/en/security/current/d4c-policy-guide.html
applies_to:
stack: beta 9.3
serverless:
security: beta
products:
- id: security
---

# Container workload protection policies [d4c-policy-guide]

To unlock the full functionality of the Defend for Containers (D4C) integration, you’ll need to understand its policy syntax. This enables you to construct policies that precisely allow expected container behaviors and prevent unexpected behaviors—thereby hardening your container workloads' security posture.

D4C integration policies consist of *selectors* and *responses*. Each policy must contain at least one selector and one response. Currently, the system supports two types of selectors and responses: `file` and `process`. Selectors define which system operations to match and can include multiple conditions (grouped using a logical `AND`) to precisely select events. Responses define which actions to take when a system operation matches the conditions specified in an associated selector.

The default policy described on this page provides an example that’s useful for understanding D4C policies in general. Following the description, you’ll find a comprehensive glossary of selector conditions, response fields, and actions.


## Default policies: [d4c-default-policies]

The default D4C integration policy includes two selector-response pairs. It is designed to implement core container workload protection capabilities:

* **Threat Detection:** The first selector-response pair is designed to stream process telemetry data to your {{es}} cluster so {{elastic-sec}} can evaluate it to detect threats. Both the selector and response are named `allProcesses`. The selector selects all fork and exec events. The associated response specifies that selected events should be logged.
* **Drift Detection & Prevention:** The second selector-response pair is designed to create alerts when container drift is detected. Both the selector and response are named `executableChanges`. The selector selects all `createExecutable` and `modifyExecutable` events. The associated response specifies that the selected events should create alerts, which will be sent to your {{es}} cluster. You can modify the response to block drift operations by setting it to block.

:::{image} /solutions/images/security-d4c-policy-editor.png
:alt: The defend for containers policy editor with the default policies
:::


## Selectors [d4c-selectors-glossary]

A selector requires a name and at least one operation. It will select all events of the specified operation types, unless you also include *conditions* to narrow down the selection. Some conditions are available for both `file` and `process` selectors, while others only available for one type of selector.

Check notice on line 35 in solutions/security/cloud/d4c/d4c-policies.md

View workflow job for this annotation

GitHub Actions / preview / vale

Elastic.FutureTense: 'will select' might be in future tense. Write in the present tense to describe the state of the product as it is now.


### Common conditions [_common_conditions]

These conditions are available for both `file` and `process` selectors.

| Name | Description |
| --- | --- |
| containerImageFullName | A list of full container image names to match on. For example: `docker.io/nginx`. |
| containerImageName | A list of container image names to match on. For example: `nginx`. |
| containerImageTag | A list of container image tags to match on. For example: `latest`. |
| kubernetesClusterId | A list of Kubernetes cluster IDs to match on. For consistency with KSPM, the `kube-system` namespace’s UID is used as a cluster ID. |
| kubernetesClusterName | A list of Kubernetes cluster names to match on. |
| kubernetesNamespace | A list of Kubernetes namespaces to match on. |
| kubernetesPodName | A list of Kubernetes pod names to match on. Trailing wildcards supported. |
| kubernetesPodLabel | A list of resource labels. Trailing wildcards supported (value only), for example: `key1:val*`. |


### File-selector conditions [_file_selector_conditions]

These conditions are available only for `file` selectors.

| Name | Description |
| --- | --- |
| operation | The list of system operations to match on. Options include `createExecutable`, `modifyExecutable`, `createFile`, `modifyFile`, `deleteFile`. |
| ignoreVolumeMounts | If set, ignores file operations on *all* volume mounts. |
| ignoreVolumeFiles | If set, ignores operations on file mounts only. For example: mounted files, `configMaps`, and secrets. |
| targetFilePath | A list of file paths to include. Paths are absolute and wildcards are supported. The `*` wildcard matches any sequence of characters within a single directory, while the `**` wildcard matches any sequence of characters across multiple directories and subdirectories. |

::::{note}
In order to ensure precise targeting of file integrity monitoring operations, a `TargetFilePath` is required whenever the `deleteFile`, `modifyFile`, or `createFile` operations are used within a selector.

Check notice on line 66 in solutions/security/cloud/d4c/d4c-policies.md

View workflow job for this annotation

GitHub Actions / preview / vale

Elastic.Wordiness: Consider using 'to' instead of 'In order to'.
::::



### Process-selector conditions [_process_selector_conditions]

These conditions are available only for `process` selectors.

| Name | Description |
| --- | --- |
| operation | The list of system operations to match on. Options include `fork` and `exec`. |
| processExecutable | A list of executables (full path included) to match on. For example: `/usr/bin/cat`. Wildcard support is same as targetFilePath above. |
| processName | A list of process names (executable basename) to match on. For example: `bash`, `vi`, `cat`. |
| sessionLeaderInteractive | If set to `true`, will only match on interactive sessions (defined as sessions with a controlling TTY). |

Check notice on line 80 in solutions/security/cloud/d4c/d4c-policies.md

View workflow job for this annotation

GitHub Actions / preview / vale

Elastic.FutureTense: 'will only' might be in future tense. Write in the present tense to describe the state of the product as it is now.


### Response fields [_response_fields]

A policy can include one or more responses. Each response is comprised of the following fields:

| Field | Description |
| --- | --- |
| match | An array of one or more selectors of the same type (`file` or `process`). |
| exclude | Optional. An array of one or more selectors to use as exclusions to everything in `match`. |
| actions | An array of actions to perform when at least one `match` selector matches and none of the `exclude` selectors match. Options include `log`, `alert`, and `block`. |


### Response actions [_response_actions]

D4C responses can include the following actions:

| Action | Description |
| --- | --- |
| log | Sends events to the `logs-cloud_defend.file-*` data stream for file responses, and the `logs-cloud_defend.process-*` data stream for process responses. |
| alert | Writes events (file or process) to the logs-cloud_defend.alerts-* data stream. |
| block | Prevents the system operation from proceeding. This blocking action happens prior to the execution of the event. It is required that the alert action be set if block is enabled.<br><br>**Note:** Currently, block is only supported on file operations.<br> |
91 changes: 91 additions & 0 deletions solutions/security/cloud/d4c/get-started-with-d4c.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
mapped_pages:
- https://www.elastic.co/guide/en/security/current/d4c-get-started.html
applies_to:
stack: beta 9.3
serverless:
security: beta
products:
- id: security
---

# Get started with Defend for Containers for Kubernetes [d4c-get-started]

This page describes how to set up Defend for Containers (D4C) for Kubernetes.

::::{admonition} Requirements
* Kubernetes node operating systems must have Linux kernels 5.10.16 or higher.

Check notice on line 17 in solutions/security/cloud/d4c/get-started-with-d4c.md

View workflow job for this annotation

GitHub Actions / preview / vale

Elastic.Versions: Use 'or later' instead of 'or higher' when referring to versions.
* {{stack}} version 9.3 or higher.

Check notice on line 18 in solutions/security/cloud/d4c/get-started-with-d4c.md

View workflow job for this annotation

GitHub Actions / preview / vale

Elastic.Versions: Use 'or later' instead of 'or higher' when referring to versions.

::::



## Initial setup [_initial_setup]

First, you’ll need to deploy Elastic’s Defend for Containers integration to the Kubernetes clusters you wish to monitor.

1. Find **Container Workload Security** in the navigation menu or use the [global search field](/explore-analyze/find-and-organize/find-apps-and-objects.md). Click **Add D4C Integration**.
2. Name the integration. The default name, which you can change, is `cloud_defend-1`.
3. (Optional) Adjust the **Selectors** and **Responses** sections in the [integration’s policy](d4c-policies.md) to modify the core container workload protection capabilities that the D4C integration policy will implement. You can change these later, if needed.
4. Under **Where to add this integration**, select an existing or new agent policy.
5. Click **Save & Continue**, then **Add {{agent}} to your hosts**.
6. On the {{agent}} policy page, click **Add agent** to open the Add agent flyout.
7. In the flyout, go to step 3 (**Install {{agent}} on your host**) and select the **Kubernetes** tab.
8. Download or copy the manifest (`elastic-agent-managed-kubernetes.yml`).
9. Open the manifest using your favorite editor, and uncomment the `#capabilities` section:

```console
#capabilities:
# add:
# - BPF # (Since Linux 5.8) allows loading of BPF programs, create most map types, load BTF, iterate programs and maps.
# - PERFMON # (Since Linux 5.8) allows attaching of BPF programs used for performance metrics and observability operations.
# - SYS_RESOURCE # Allow use of special resources or raising of resource limits. Used by 'Defend for Containers' to modify 'rlimit_memlock'
# - SYS_ADMIN # Required if using Defend for Containers on Azure Kubernetes Service (AKS)
```

10. From the directory where you saved the manifest, run the command `kubectl apply -f elastic-agent-managed-kubernetes.yml`.
11. Wait for the **Confirm agent enrollment** dialogue to show that data has started flowing from your newly-installed agent, then click **Close**.


## Get started with threat detection [d4c-get-started-threat]

The [default D4C policy](d4c-policies.md#d4c-default-policies) provides threat detection capabilities. It is designed to send process telemetry events (`fork` and `exec`) to {{es}}.

To detect threats using this data, you’ll need active [detection rules](/solutions/security/detect-and-alert.md). You can use Elastic's prebuilt rules that are designed for this data or create [custom rules](/solutions/security/detect-and-alert/create-detection-rule.md).

To set up threat detection, install and enable Elastic's prebuilt rules that use data ingested by D4C:

1. Find **Detection rules (SIEM)** in the navigation menu or use the [global search field](/explore-analyze/find-and-organize/find-apps-and-objects.md). Click **Add Elastic rules**.
2. Click the **Tags** filter next to the search bar, and search for the `Data Source: Elastic Defend for Containers` tag.
3. Select all the displayed rules, then click **Install *x* selected rule(s)**.
4. Return to the **Rules** page. Click the **Tags** filter next to the search bar, and search for the `Data Source: Elastic Defend for Containers` tag.
5. Select all the rules with the tag, and then click **Bulk actions > Enable**.


## Get started with drift detection and prevention [d4c-get-started-drift]

{{elastic-sec}} defines container drift as the creation or modification of an executable within a container. Blocking drift restricts the number of attack vectors available to bad actors by prohibiting them from using external tools.

The [default D4C policy](d4c-policies.md#d4c-default-policies) provides drift detection and prevention capabilities. Before you enable drift detection, do the following:

- Make sure the default D4C policy is active.
- Make sure you've installed and enabled the "Container Workload Protection" prebuilt rule. The steps for installing and enabling prebuilt rules are above.

To enable drift prevention, create a new policy:

1. Find **Container Workload Security** in the navigation menu or use the [global search field](/explore-analyze/find-and-organize/find-apps-and-objects.md), then select your integration.
2. Under **Selectors**, click **Add selector > File Selector**. By default, it selects the operations `createExecutable` and `modifyExecutable`.
3. Name the selector, for example: `blockDrift`.
4. Scroll down to the **Responses** section and click **Add response > File Response**.
5. Under **Match selectors**, add the name of your new selector, for example: `blockDrift`.
6. Select the **Alert** and **Block** actions.
7. Click **Save integration**.

::::{important}
Before you enable blocking, we strongly recommend you observe a production workload that’s using the default D4C policy to ensure that the workload does not create or modify executables as part of its normal operation.
::::

## Policy validation [d4c-get-started-validation]

To ensure the stability of your production workloads, you should test policy changes before implementing them in production workloads. We also recommend you test policy changes on a simulated environment with workloads similar to production. This approach allows you to test that policy changes prevent undesirable behavior without disrupting your production workloads.
Loading