Check if security group is nil, fixes #2507