Re:I discovered thousands of open databases on AWS
by wiredfool on Tuesday March 15, 2022 @06:22AM
(#30683603)
Even better, docker-compose doesn't do IPV6 (well). But if you have an IPV6 address, it will NAT all the incoming IPV6 traffic on the open ports to IPV4 using the internal network gateway address.
So, if you're doing any filtering for internal network addresses == internal traffic, congratulations, now your inbound external IPV6 traffic is recognized as internal.
Re:I discovered thousands of open databases on AWS
by withinboredom on Tuesday March 15, 2022 @01:02PM
(#30687816)
And even better 0.0.0.0 isn’t the default on Docker For Mac, leading devs to a false sense of security who develop on Macs.
Re:I discovered thousands of open databases on AWS
by qwertox on Tuesday March 15, 2022 @06:15AM
(#30683543)
Is there any additional information on this?
Assuming I add a rule via
`iptables -I INPUT -s 123.123.123.123 -p tcp --dport 8080 -j DROP`
and on interface:port 0.0.0.0:8080 of the host is a container listening which got run as
`docker run -d -p 0.0.0.0:8080:8080 some/server:latest`
Will that container still be accessible to 123.123.123.132?
Re:I discovered thousands of open databases on AWS
by l33tman on Tuesday March 15, 2022 @06:30AM
(#30683659)
I think so, this has been discussed in many HN threads and it always surprises a lot of people how big of a hole this is. I was certainly not aware of it the first time I read about it. Docker inserts its own iptables rules before your drop rule I think to handle its virtual interfaces.
Re:I discovered thousands of open databases on AWS
by remram on Tuesday March 15, 2022 @09:11AM
(#30684778)
The Docker container is using a separate network namespace with a separate virtual interface that packets are routed to. The "PREROUTING" chain runs before the "INPUT" chain so yes, the rules you put in "INPUT" won't apply.
Re:I discovered thousands of open databases on AWS
by rzzzt on Tuesday March 15, 2022 @10:15AM
(#30685562)
Its rules also go into the "nat" table instead of the "filter" table. Use "iptables -L -t nat" to display them.
Re:I discovered thousands of open databases on AWS
by remram on Wednesday March 16, 2022 @11:23AM
(#30699936)
Or iptables-save (note the nat and filter sections)
Re:I discovered thousands of open databases on AWS
by malka on Tuesday March 15, 2022 @08:50AM
(#30684589)
Yes. Docker will create specific rules for the lifetime of the container.
I was bit by this once. Be very careful with docker. Do not rely blindly on your firewall of it runs on the same machine.
Re:I discovered thousands of open databases on AWS
by michaelcampbell on Tuesday March 15, 2022 @09:13AM
(#30684799)
Well, trick question since you typo'd the IP, but "yes" to the spirit. I ran into exactly the case described https://www.techrepublic.com/article/how-to-fix-the-docker-a..., albeit with mysql instead of mongo.
Re:I discovered thousands of open databases on AWS
by efdee on Tuesday March 15, 2022 @07:13AM
(#30683946)
Strange, I've never seen this before. I've been running Docker for years on one of my pet project machines, but while Docker is exposing the ports on 0.0.0.0 my iptables firewall blocks all of them.
I'm not using --iptables=false but I'm not discounting the possibility that maybe I've configured this on a more global level somewhere.
Re:I discovered thousands of open databases on AWS
by tluyben2 on Tuesday March 15, 2022 @09:49AM
(#30685217)
That is still strange ; as you can read from others, docker refreshes it’s own iptable rules which then can mess with your own. Maybe you were lucky but seems unlikely to have that much luck. Be careful anyway; if you opened a port, it’ll be on 0.0.0.0 and docker does rearrange your iptables when the container(s) start. Especially default redis and mongo are good foot-shooters.
Re:I discovered thousands of open databases on AWS
by efdee on Tuesday March 15, 2022 @12:53PM
(#30687660)
I don't quite understand it either. I just triple checked though, the ports are filtered from the outside. I do have a bunch of "docker network isolation" things going on in my iptables setup, so maybe that's why.
Re:I discovered thousands of open databases on AWS
by sethammons on Tuesday March 15, 2022 @09:24AM
(#30684919)
We unknowingly did this at work. We had firewalls in place and docker was more than happy to open up redis to the world. Big lesson learned.
I accidentally opened up a Redis test-instance to the world like this.