CL-0005: ports: 8080:80 binds 0.0.0.0, past UFW¶
Severity: MEDIUM (how it is derived)
A published port with no bind address listens on every interface of the host,
IPv4 and IPv6 (0.0.0.0 and [::]), and Docker's own iptables rules let traffic reach it even where UFW or
firewalld would block it. Bind it to 127.0.0.1, or to the one address that
should reach it.
Fix¶
services:
web:
image: nginx:1.27-alpine
ports:
- "127.0.0.1:8080:80" # was "8080:80"
Long syntax:
ports:
- target: 80
published: 8080
host_ip: 127.0.0.1
- Let compose-lint write it.
fixprints the change as a diff and writes nothing until you add--apply. It warns first, because binding to127.0.0.1stops other machines reaching the port:
compose-lint fix --only CL-0005 compose.yaml # show the diff
compose-lint fix --only CL-0005 --apply compose.yaml # write it
⚠ behavior-changing · CL-0005: Binding to 127.0.0.1 drops the port's reachability from other hosts; intended LAN or remote access breaks — front public exposure with a reverse proxy and TLS instead.
- If other machines on your network must reach it, bind to the host's LAN address instead. Only that interface listens, and loopback is refused:
# List the host's addresses (Linux)
ip -4 -brief addr
ports:
- "192.168.1.10:8080:80" # the host's LAN address
A service the internet must reach belongs behind a reverse proxy (Traefik, Caddy, nginx) that terminates TLS; bind only the proxy's ports publicly.
- Recreate the service and check where it listens:
docker compose up -d web
docker compose port web 80
# 127.0.0.1:8080 (was 0.0.0.0:8080)
curl -sS -o /dev/null -w '%{http_code}\n' http://127.0.0.1:8080/
# 200
The same request to the host's LAN address now fails with
Failed to connect. From another machine it fails too; behind firewalld
the answer is the firewall's reject, the same as for any port the zone does
not open.
- Check the finding is gone:
compose-lint -q compose.yaml | grep CL-0005 # prints nothing once fixed
Verified against Docker 29.7.2: before the fix the port answered on both
loopback and the LAN address; bound to 127.0.0.1 it answered only on
loopback, and bound to the LAN address only there. The firewall bypass was
measured from a second machine on the same LAN, against a host running
firewalld (iptables backend) whose zone opened only ssh: a plain process
listening on 0.0.0.0 was refused, while a Docker port published with no bind
address served the request. The same held under UFW 0.36.2 (default deny
incoming, only ssh allowed) on Ubuntu 24.04 with Docker 29.9.1: the unbound
publish served a request from outside the host, a plain listener did not, and
a 127.0.0.1: publish was unreachable.
For systemic mitigation, configure the DOCKER-USER iptables chain on the host so that Docker's bypass of UFW/firewalld becomes per-rule rather than per-service. This is documented in Docker and iptables. Per-service binding is whack-a-mole; the chain-level rule is the durable fix.
Swarm caveat¶
host_ip in the long syntax is not always honored under Swarm mode — Swarm uses an ingress mesh and may publish ports on all manager nodes regardless. If you're targeting Swarm, port publishing is a Swarm concern; this rule still flags the file but treat the fix as Swarm-specific.
Tested on: Docker 29.7.2 with Compose 5.5.0, on a host without AppArmor (Yama ptrace_scope 1); the Fix steps above were re-run there in October 2026. Not tested: Swarm mode.
When to suppress¶
- Public-facing service on a VPS where the cloud provider's firewall is the security boundary and
0.0.0.0is intended. Suppress with areason:naming the firewall layer (e.g.reason: "GCP firewall enforces ingress; UFW disabled by design").
What it detects¶
Port mappings that don't specify a bind address or that bind to a wildcard, in both short syntax ("8080:80", "0.0.0.0:8080:80", "[::]:8080:80") and long syntax (published: without host_ip:, or with host_ip: "0.0.0.0" / host_ip: "::"). A bare short-syntax port with no colon ("80", 3001, a "3000-3005" range) is also flagged: Docker still publishes it, assigning a random (ephemeral) host port bound to all interfaces (docker compose config normalizes - "80" to a published target, and docker compose up binds it on 0.0.0.0). The long-syntax spelling of the same publish, a mapping with target: and no published:, is flagged the same way: Compose renders - target: 80 and - "80" to the identical entry. So is an ephemeral publish with an explicit wildcard or empty address ("0.0.0.0::80", "::81", "[::]::82", ":9000"). Bind it with 127.0.0.1::80 to keep the ephemeral port on localhost. A long-syntax host_ip: that is written but empty, null or not a string (including an empty ${VAR:-}) is not flagged: Compose refuses the file (invalid ip address:, must be a string), so no port is published.
A short-syntax port is split the way Docker's own parser splits it: the last field is the container port, the one before it the host port, and everything before that is the address, colons and all. That is how an unbracketed IPv6 address (":::8080:80", "0:0:0:0:0:0:0:0:8080:80") is read as an address, and why "::1:8080:80" is a loopback bind. The bind address is decided by parsing it, not by matching the spelling: every way of writing the unspecified address is the same address and publishes on every interface — 0.0.0.0, ::, [::], [::0], [0:0:0:0:0:0:0:0], [::ffff:0.0.0.0]. Specific bind addresses including loopback (127.0.0.1, [::1]) are not flagged, and a value that is not an address at all (a hostname) is not treated as a wildcard.
The host port's number is not graded. CIS Docker Benchmark 5.8 asks that
privileged ports (below 1024) not be mapped into containers, and KICS carries a
query for it. Docker publishes a port from the host side, so no capability in
the container is involved; 80:80 and 443:443 are the ordinary shape of an
edge service, and the only change that would clear such a finding is to move
the service off the port it exists to serve. The bind address is graded by this
rule whatever the port number.
Why it matters¶
Docker publishes ports by manipulating iptables directly, bypassing host firewalls like UFW and firewalld. A port published without a bind address is accessible on all network interfaces, potentially exposing services to the public internet even when host firewall rules would otherwise block the traffic.
ATT&CK coverage¶
No adversary technique maps to this rule. That is a finding about the rule, not an omission — see below.
It does enable T1190 Exploit Public-Facing Application, but enabling is not the same as being a technique: the misconfiguration widens the attack surface an adversary can reach rather than supplying a step they execute.
See also¶
- CL-0008 —
network_mode: host(port-publish controls don't apply at all) - Hardening guide, step 3 — where this rule fits when hardening a whole file
Severity derivation¶
Derivation (see severity model):
- Baseline: A — the attacker already has code execution in this container, as the workload uid
- Precondition: Second flaw — an exposed port is only a compromise if the service behind it has an exploitable defect or a weak credential
- Impact: Single container — the service the port belongs to
- Qualifier/modifier: pre-foothold reach — no foothold anywhere is required to reach the port, which is what this modifier prices
- Derived: Second flaw × Single container + pre-foothold reach = HIGH
- Shipped: MEDIUM — override
detection-precision— the dangerous case is the binding that was not meant to be public, and the file does not say which is which. An exposed datastore is serious; an exposed web server is the design. Well-known datastore and admin ports are a usable proxy, so the path off this override is a split rather than a smarter matcher (ADR-020 Appendix B) - Evidence:
_cl0005— a bare published port binds all interfaces, verified live. Docker publishes ports by writing iptables rules directly, so the binding is reachable even where UFW or firewalld would deny it
References: - OWASP Docker Security Rule #5a - CIS Docker Benchmark 5.14 — Ensure that incoming container traffic is bound to a specific host interface
A reference means the rule relates to that source. It does not mean a file with no finding complies with it. The CIS, OWASP and ATT&CK mapping for every rule, and the tags SARIF output carries for it, are on Standards mapping.