Page MenuHomeVyOS Platform

chain FW_CONNTRACK incorrectly use accept as action
Closed, InvalidPublicBUG

Description

Looking through the output of "sudo nft -s list ruleset" in VyOS 1.5-rolling-202310110022 the following can be observed:

table ip vyos_conntrack {
...
        chain VYOS_CT_IGNORE {                                             
                return                                                
        }                                                                                    
                                                                          
        chain VYOS_CT_TIMEOUT {                                                           
                return                                       
        }                                                    
                                                                    
        chain PREROUTING {                                             
                type filter hook prerouting priority raw; policy accept;                     
                counter jump VYOS_CT_HELPER                               
                counter jump VYOS_CT_IGNORE                                               
                counter jump VYOS_CT_TIMEOUT
                counter jump FW_CONNTRACK                                  
                counter jump NAT_CONNTRACK       
                counter jump WLB_CONNTRACK                               
                notrack                                                                      
        }                                                                                    
                                                                                       
        chain OUTPUT {                                                                 
                type filter hook output priority raw; policy accept;                    
                counter jump VYOS_CT_HELPER                                             
                counter jump VYOS_CT_IGNORE                                             
                counter jump VYOS_CT_TIMEOUT                         
                counter jump FW_CONNTRACK                           
                counter jump NAT_CONNTRACK                                 
                notrack                                                                      
        }                                                                                    
                                                                                                 
        chain VYOS_CT_HELPER {                                                            
                return                                                     
        }                                 
                                                                        
        chain FW_CONNTRACK {                                                                 
                accept                                                                       
        }                                                                                        
                                                                                       
        chain NAT_CONNTRACK {                                                           
                return                                                                  
        }                                                                               
                                                                        
        chain WLB_CONNTRACK {                                           
                return                                                     
        }                                                               
}                                                                                            
table ip6 vyos_conntrack {
...
        chain VYOS_CT_IGNORE {                                          
                return                                                                       
        }                                                                 
                                                                                          
        chain VYOS_CT_TIMEOUT {                                         
                return                                                  
        }                                                               
                                                                        
        chain PREROUTING {                                                                   
                type filter hook prerouting priority raw; policy accept;  
                counter jump VYOS_CT_HELPER                                               
                counter jump VYOS_CT_IGNORE                             
                counter jump VYOS_CT_TIMEOUT                               
                counter jump FW_CONNTRACK                               
                counter jump NAT_CONNTRACK                               
                notrack                                                                      
        }                                                                                    
                                                                                       
        chain OUTPUT {                                                                 
                type filter hook output priority raw; policy accept;                    
                counter jump VYOS_CT_HELPER                                             
                counter jump VYOS_CT_IGNORE                                             
                counter jump VYOS_CT_TIMEOUT                            
                counter jump FW_CONNTRACK                               
                counter jump NAT_CONNTRACK                                 
                notrack                                                                      
        }                                                                                    
                                                                                                 
        chain VYOS_CT_HELPER {                                                            
                return                                                     
        }                                                               
                                                                        
        chain FW_CONNTRACK {                                                                 
                accept                                                                       
        }                                                                                        
                                                                                          
        chain NAT_CONNTRACK {                                           
                return                                                     
        }                                                                
}

My interpretation of above is that when "jump FW_CONNTRACK" occurs the action is "accept" which means that the chains that comes after FW_CONNTRACK (in chain PREROUTING and OUTPUT) are never evaluated:

counter jump NAT_CONNTRACK       
counter jump WLB_CONNTRACK

Suggested fix:

chain FW_CONNTRACK {
        return
}

Details

Difficulty level
Unknown (require assessment)
Version
VyOS 1.5-rolling-202310110022
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Unspecified (possibly destroys the router)
Issue type
Bug (incorrect behavior)

Event Timeline

sarthurdev added a subscriber: sarthurdev.

That is how the conntrack enabling system works. FW_CONNTRACK verdict is set to accept when it is determined the firewall needs conntracking (state rules, flowtable etc.), same for NAT_/WLB_ chains. If none require conntrack - all chains will be return and it falls down the chain to the final notrack and conntrack is not enabled.

But the NAT_CONNTRACK and WLB_CONNTRACK chains are never evaluted because FW_CONNTRACK always set action to accept?

That is once entering FW_CONNTRACK since its "accept" it will never return back to the chain PREROUTING or chain OUTPUT for further processing.

Whats the purpose of the NAT_CONNTRACK and WLB_CONNTRACK chains if they are never evaluated?

If you don't use the firewall (statefully at least) then it will go through the FW_CONNTRACK chain and the NAT_CONNTRACK and/or WLB_CONNTRACK chains will be reached, or fall through to the notrack.

Each chain's verdict is set to accept or return based on the requirements of each config script. If the firewall requires stateful checks, there's no reason for it to also check NAT/WLB - conntrack is required.

Check!

Then this task can be set to closed and invalid :-)