---
title: Container adds high-risk capabilities
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: >-
  Docs > Datadog Security > Code Security > Infrastructure as Code (IaC)
  Security > IaC Security Rules > Container adds high-risk capabilities
---

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

# Container adds high-risk capabilities

{% callout %}
# Important note for users on the following Datadog sites: app.ddog-gov.com, us2.ddog-gov.com

{% alert level="danger" %}
This product is not supported for your selected [Datadog site](https://docs.datadoghq.com/getting_started/site.md). ({% placeholder "user-datadog-site-name" /%}).
{% /alert %}

{% /callout %}

## Metadata{% #metadata %}

**Id:** `dockercompose-container-capabilities-unrestricted` 

**Platform:** DockerCompose

**Severity:** Medium

**Category:** Resource Management

#### Learn More{% #learn-more %}

- [Provider Reference](https://docs.docker.com/reference/compose-file/services/#cap_add)

### Description{% #description %}

Granting containers high-risk Linux capabilities such as `SYS_ADMIN`, `NET_ADMIN`, `BPF`, or `ALL` expands the attack surface by allowing container processes to interact with privileged kernel interfaces, load kernel modules, or gain full root-equivalent access to the host. A compromised container with these capabilities can escape isolation and affect the entire host. The `cap_add` list should not include `ALL`, `BPF`, `DAC_READ_SEARCH`, `NET_ADMIN`, `SYS_ADMIN`, `SYS_MODULE`, or `SYS_PTRACE` unless explicitly required and documented.

## Compliant Code Examples{% #compliant-code-examples %}

```yaml
services:
  benign:
    image: alpine
    cap_add: [CHOWN, SETUID]
  no_drop_all:
    image: alpine
  dropped:
    image: alpine
    cap_drop: [ALL]
```

## Non-Compliant Code Examples{% #non-compliant-code-examples %}

```yaml
services:
  all_caps:
    image: alpine
    cap_add: [ALL]
  admin_caps:
    image: alpine
    cap_add:
      - SYS_ADMIN
      - CHOWN
  ebpf:
    image: alpine
    cap_add: [BPF]
  prefixed_admin:
    image: alpine
    cap_add: [CAP_SYS_ADMIN]
```
