For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/default_rules/v5z-8zy-27i.md. A documentation index is available at /llms.txt.

Privileged port mapping for containers should be restricted to increase security

docker

Classification:

compliance

Framework:

cis-docker

Control:

5.8

Description

Containers should publish their ports on host ports above 1023.

Rationale

Ports below 1024 are reserved for root on the host. A container that publishes one claims a port that clients trust as a system service.

Audit

Inspect the containers:

docker ps --quiet | xargs docker inspect --format '{{ .Name }}: Ports={{ .NetworkSettings.Ports }}'

Datadog checks the running containers. It passes the rule when every published host port is 1024 or above, and fails it otherwise. A load balancer that must listen on 80 or 443 fails, and needs a manual review.

Remediation

Publish the container port on a host port of 1024 or above:

docker run -p 8080:80 <image>

Impact

None.

Default value

Docker publishes the host ports that the command asks for.

References

  1. https://docs.docker.com/engine/network/