Security groups in cloud environments act as virtual firewalls for VM instances, controlling inbound and outbound traffic based on specified rules. From Andrew Ramdayal's guide: "Network security groups are used to control inbound and outbound traffic to cloud resources within a VPC. They act as a virtual firewall for associated instances..."