CL-0008: network_mode: host — risks and alternatives¶
Severity: HIGH (how it is derived)
network_mode: host puts the container on the host's own network stack: every
interface, every port, and the services the host keeps on 127.0.0.1. Remove
it and publish the ports the service needs.
Fix¶
Remove network_mode: host and use bridge networking with explicit port mappings:
services:
web:
image: nginx:1.27-alpine
ports:
- "127.0.0.1:8080:80" # host port 8080 on loopback, nginx's port 80
networks:
- app-network
networks:
app-network:
-
Publish what clients reach, bound to an address. Each port the service listens on for outside clients needs a
ports:entry; bind it to127.0.0.1or the host's LAN address (CL-0005). Under host networking the service was on whatever address the application bound, andports:could not narrow it. Bind the published port deliberately: the host firewall did filter the host-network listener, and it does not filter a published port. -
If the service talked to something on the host, give it a route to the host instead of the host's network. Add the host's gateway name, and make sure the host service listens on an address the bridge can reach:
services:
app:
image: myapp:1.0
extra_hosts:
- "host.docker.internal:host-gateway" # the host, seen from the bridge
The app then connects to host.docker.internal. A host service bound to the
Docker bridge's address (ip -4 addr show docker0) answered from a bridge
container; the same service bound only to 127.0.0.1 did not, which is the
isolation this change is buying.
- Check the container has its own network:
docker compose up -d web
docker compose exec web ip -o -4 addr | awk '{print $2}'
# lo
# eth0
Under network_mode: host the same command listed every host interface
(wlan0, docker0 and each bridge on the test host).
- Check the finding is gone:
compose-lint -q compose.yaml | grep CL-0008 # prints nothing once fixed
Verified against Docker 29.7.2 with nginx:1.27-alpine and busybox:1.37.
Only workloads that genuinely need to see host traffic (network monitoring, certain VPN agents, eBPF-based tools) require host networking.
network_mode: host is not a version of CL-0005's firewall bypass. Port-publish rules don't apply, so anything the container binds is an ordinary listener on the host's interfaces, and the host's INPUT rules filter it. With the INPUT policy set to drop, a host-network listener stopped answering from another machine while a port published on the same host still answered (observed on Docker 29.9.3 with the iptables backend, November 2026). What host networking removes is the container's own network namespace: the service's bind address is no longer yours to set in the Compose file, and the container reaches everything the host does.
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: an AppArmor or SELinux host.
When to suppress¶
- Network-monitoring sidecars (cAdvisor, node-exporter, Netdata) that legitimately need host-namespace visibility.
- Userspace VPN agents that manage host routing tables.
In both cases suppress with a reason: naming the workload, and pair with cap_drop, read_only, and no-new-privileges to harden whatever isolation remains.
What it detects¶
Any service with network_mode: host. Other network modes (bridge, service:, custom networks) are not flagged.
A service with no networks: key is not flagged either. Compose attaches it to
the project's own <project>_default network, a user-defined bridge created for
that project, so the host's default docker0 bridge that CIS Docker Benchmark
5.30 asks not to use is avoided by construction. Whether two services of one
project should be able to reach each other is a design decision the file does
not settle, and no rule grades intra-project reachability.
Why it matters¶
Host network mode disables Docker's network isolation entirely. The container:
- Shares the host's IP address and all network interfaces
- Can bind to any port on the host without publishing
- Can observe and capture all host network traffic
- Can communicate with services bound to
127.0.0.1on the host - Bypasses Docker network policies and inter-container firewalling
This is a significant isolation bypass — any network-based security boundary between the container and the host is removed.
ATT&CK coverage¶
Remediating this finding contributes to mitigating the following MITRE ATT&CK techniques (pinned to ATT&CK v18). compose-lint is a static analyser, so this is mitigation coverage — it detects nothing at runtime.
| Technique | Tactic |
|---|---|
| T1046 Network Service Discovery | Discovery |
See also¶
- CL-0005 — port binding (irrelevant under host networking; the container is already on the host's interfaces)
- CL-0010 — sibling host-namespace sharing for PID/IPC/UTS/userns
- Hardening guide, step 11 — 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: Technique — the host network namespace is handed over immediately, but turning that into impact takes a published technique: packet capture, ARP spoofing, or abusing a service that trusts
127.0.0.1 - Impact: Cross-container — the reach is every interface and every other container's routed traffic, plus host-loopback services. It is a pivot, not host control
- Qualifier/modifier: none
- Derived: Technique × Cross-container = HIGH
- Shipped: HIGH
- Evidence:
_cl0008— a host-network container sees the host's interfaces, verified live
References: - CIS Docker Benchmark 5.10 — Ensure that the host's network namespace is not shared
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.