The Docker UFW bypass is not a theoretical vulnerability. It's a misconfiguration that has exposed production databases, Redis instances, and internal APIs to the public internet thousands of times — on servers whose owners believed their firewall was protecting them.
How it happens
Linux packet routing evaluates iptables chains in order: PREROUTING → DOCKER → FORWARD → INPUT. UFW manages the INPUT chain. When a packet arrives destined for a Docker container port, Docker's rules in the FORWARD chain accept it before the packet ever reaches UFW's INPUT rules.
The result: a developer runs ufw deny 6379 to block Redis. They check ufw status and see the deny rule listed. They assume they're protected. Their Redis instance is publicly accessible anyway — through the DOCKER chain that UFW never touches.
Documented exposure patterns
Redis (:6379), MongoDB (:27017), PostgreSQL (:5432), and MySQL (:3306) bound to 0.0.0.0 via Docker port mappings are consistently found by Shodan scans. Unauthenticated Redis instances in particular have been used for cryptomining by scanning for port 6379 and issuing CONFIG SET commands to write SSH keys to ~/.ssh/authorized_keys.
Internal services (admin panels, metrics endpoints, internal APIs) deployed in Docker with ports: "PORT:PORT" and no authentication, intended to be "protected by the firewall", are accessible from the public internet. The firewall appears active. The service is reachable.
Ollama and other local LLM servers running in Docker with ports: "11434:11434" are discoverable via Shodan on port 11434. Exposed instances allow anyone to run inference on the host's hardware at no cost to the attacker.
The attack timeline
ports: "6379:6379". Adds ufw deny 6379. Checks status — looks protected.Verification — check right now
# From another machine (mobile data, NOT your home network): curl http://YOUR_SERVER_IP:6379 nc -zv YOUR_SERVER_IP 6379 # Or from the server itself — check what Docker exposed: sudo iptables -L DOCKER --line-numbers | grep ACCEPT
The fix
# Before — exposed to internet: ports: - "6379:6379" # After — localhost only: ports: - "127.0.0.1:6379:6379"
sudo iptables -I DOCKER-USER -j DROP sudo iptables -I DOCKER-USER -s 127.0.0.1 -j ACCEPT sudo apt install iptables-persistent && sudo netfilter-persistent save
Related
- What is Docker UFW bypass?
- Docker UFW bypass fix guide
- UFW Docker bypass fix guide
- Docker bypasses UFW — explained
Paste your ufw status verbose output to detect Docker bypass risk and exposed ports on your server.