iptables not dropping existing connections when rule disabled

tomas.florian

New Member
May 14, 2021
1
0
1
25
I noticed that when I make a restrictive change to a firewall, the traffic keeps coming through.

Example:
  1. Enable firewall (cluster,host,vm,network interface)
  2. Create firewall entry for vm:
    • Line 0: dport TCP: 22 ACCEPT
    • Input policy: DROP
  3. Connect to the host protected by this firewall on port 22
  4. Disable line 0 rule (by unchecking checkbox), so that all inbound traffic is dropped by default
  5. This works, but only for brand new connections. Existing connections are never(?) cut. (I tried waiting as long as 2 hours)
  6. To cut the connection I tried to do "conntrack -F" but even this doesn't cut it.
  7. pve-firewall restart #doesn't help either
    pve-firewall status
    Status: enabled/running (pending changes)
  8. I even tried disconnecting the VM network for 5 minutes, and then connecting it back, even like that the connection is not cut and just resumes where it left off (still logged into SSH)
It is interesting that when I try the same thing on ICMP (pings), conntrack -F does cut it off
It is also interesting to see that iptables changes happen almost right away, and yet those correct rules are obviously not being followed.

Unless I'm using the system completely wrong, this is a security vulnerability. In any scenario where the goal is to disable an ACCEPT rule to cut off existing undesirable traffic, then the firewall has zero effect. What's more, it gives the administrator a false sense of confidence because when they disable a rule, there is no indication in the GUI that the rule was disabled only for new connections, and that current connections will be maintained indefinitely (they even survive a network disconnection!)

The only workaround I found was to reboot the VM.

There must be a better solution than this.

My environment:
- pve-manager/7.0-11/63d82f4e
- 2 node cluster
- Linux bridge networking on single subnet
 
Last edited:
I'm reviving such an old thread but I'm encountering the same thing and was wondering if you ever found a solution?