evilsocket / opensnitch

OpenSnitch is a GNU/Linux interactive application firewall inspired by Little Snitch.
GNU General Public License v3.0
9.86k stars 486 forks source link

Intercept forwarded rule not working with docker and local network #1079

Open red-gecko27 opened 5 months ago

red-gecko27 commented 5 months ago

Describe the bug When I enable the system rule "Intercept forwarded connections (docker, etc)" I can no longer access my Docker containers on the local network even when it is in the "disabled" status on the graphical interface.

Include the following information:

To Reproduce

I am using eBPF, and there are no errors in /var/log/opensnitchd.log.

My iptables:

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy DROP)
target     prot opt source               destination         
DOCKER-USER  all  --  anywhere             anywhere            
DOCKER-ISOLATION-STAGE-1  all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
DOCKER     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         

Chain DOCKER (1 references)
target     prot opt source               destination         
ACCEPT     tcp  --  anywhere             172.17.0.2           tcp dpt:http

Chain DOCKER-ISOLATION-STAGE-1 (1 references)
target     prot opt source               destination         
DOCKER-ISOLATION-STAGE-2  all  --  anywhere             anywhere            
RETURN     all  --  anywhere             anywhere            

Chain DOCKER-ISOLATION-STAGE-2 (1 references)
target     prot opt source               destination         
DROP       all  --  anywhere             anywhere            
RETURN     all  --  anywhere             anywhere            

Chain DOCKER-USER (1 references)
target     prot opt source               destination         
RETURN     all  --  anywhere             anywhere 
gustavo-iniguez-goya commented 5 months ago

hey @red-gecko27 !

Thank you for the detailed report. I've reproduced the problem and there're 2 workarounds:

  1. Modify the forwarding rule to intercept connections originated only from your containers network (typically 172.17.0.0/16).

Double click on the fw rule -> change "Match conntrack state(s)" to "Source IP" and enter the network, then add a new condition by clicking on the [+] button and add "Match conntrack state(s)" -> new (like in the following image).

  1. Enable [x] Debug invalid connections under Preferences -> Nodes -> General You can create a rule then to allow connections to the container IP + port.

In this scenario, as it's an inbound connection, it doesn't belong to any app yet, thus the connection is discarded by default.