---
title: Kernel capabilities in Linux should only be granted when necessary
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: >-
  Docs > Datadog Security > OOTB Rules > Kernel capabilities in Linux should
  only be granted when necessary
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# Kernel capabilities in Linux should only be granted when necessary
Classification:complianceFramework:cis-dockerControl:5.4 
## Description{% #description %}

Containers should keep only the Linux capabilities they need, and drop NET_RAW.

## Rationale{% #rationale %}

Every capability widens what a process in the container can do to the kernel. NET_RAW, granted by default, lets a container craft raw packets, spoof addresses and reach other containers despite network restrictions.

## Audit{% #audit %}

Inspect the containers:

```bash
docker ps --quiet --all | xargs docker inspect --format '{{ .Name }}: CapAdd={{ .HostConfig.CapAdd }} CapDrop={{ .HostConfig.CapDrop }}'
```

Datadog passes the rule when a container is unprivileged, drops NET_RAW or ALL, and adds only capabilities of Docker's default set, and fails it otherwise.

## Remediation{% #remediation %}

Drop every capability and add back the ones the workload needs:

```bash
docker run --cap-drop=ALL --cap-add=CHOWN <image>
```

## Impact{% #impact %}

A workload that needs a capability fails until it is added back.

## Default value{% #default-value %}

Docker grants 14 capabilities, NET_RAW among them.

## References{% #references %}

1. [https://docs.docker.com/engine/security/#linux-kernel-capabilities](https://docs.docker.com/engine/security/#linux-kernel-capabilities)
1. [https://docs.docker.com/compose/compose-file/compose-file-v3/#cap_add-cap_drop](https://docs.docker.com/compose/compose-file/compose-file-v3/#cap_add-cap_drop)
1. [https://docs.docker.com/reference/cli/docker/service/create/#options](https://docs.docker.com/reference/cli/docker/service/create/#options)
1. [https://docs.docker.com/reference/cli/docker/container/run/#configure-namespaced-kernel-parameters-sysctls-at-runtime](https://docs.docker.com/reference/cli/docker/container/run/#configure-namespaced-kernel-parameters-sysctls-at-runtime)
