OpenNebula / one

The open source Cloud & Edge Computing Platform bringing real freedom to your Enterprise Cloud 🚀
http://opennebula.io
Apache License 2.0
1.26k stars 485 forks source link

VM is left unprotected when there is an error in the Security Group rules #6759

Open OpenNebulaSupport opened 1 month ago

OpenNebulaSupport commented 1 month ago

Description The network Security Groups (SG) are composed of rules to play the role fo a firewall to the VM guest they are mapped to iptables and ipset rules on the hosts. When an operator defines an SG rule incompatible with iptables, the VNN_MAD deletes all the iptable chains for the given VM NIC and logs an error that is visible as a notification for the given VM. Simultaneously, the VM is left running vulnerable without any form of firewall protection and an inexperienced operator could not pay enough attention. It is possible to even edit the SG rules and then not look at the VM's tab in Sunstone to notice the raised errors...

To Reproduce

Expected behavior Any solution that does not leave the VM open and vulnerable to the internet in case of buggy SG rule is better than the current behavior. The simplest that I'd think of is, when there is a SG defined, in case of an error the append all DROP rule in the iptables chain. Because it is better to have the VM blocked needing further attention to fix it than leave it open to become hacked.

Details

Progress Status

rsmontero commented 1 week ago

See comments here: https://github.com/OpenNebula/one/pull/6760#issuecomment-2488937377

rsmontero commented 4 days ago

Updating the issue here:

Actions

The "bug" is actually in SecurityGroup::is_valid() . This needs to be extended when first port in range is greater than last, the range needs to be properly sorted.